2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / boehm-gc / include / private / gcconfig.h
blob65e71479892c22e0d5e255ce2f19a5f3f023c86f
1 /*
2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
5 * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
18 * This header is private to the gc. It is almost always included from
19 * gc_priv.h. However it is possible to include it by itself if just the
20 * configuration macros are needed. In that
21 * case, a few declarations relying on types declared in gc_priv.h will be
22 * omitted.
25 #ifndef GCCONFIG_H
27 # define GCCONFIG_H
29 # ifndef GC_PRIVATE_H
30 /* Fake ptr_t declaration, just to avoid compilation errors. */
31 /* This avoids many instances if "ifndef GC_PRIVATE_H" below. */
32 typedef struct GC_undefined_struct * ptr_t;
33 # endif
35 /* Machine dependent parameters. Some tuning parameters can be found */
36 /* near the top of gc_private.h. */
38 /* Machine specific parts contributed by various people. See README file. */
40 /* First a unified test for Linux: */
41 # if defined(linux) || defined(__linux__)
42 # ifndef LINUX
43 # define LINUX
44 # endif
45 # endif
47 /* And one for NetBSD: */
48 # if defined(__NetBSD__)
49 # define NETBSD
50 # endif
52 /* And one for OpenBSD: */
53 # if defined(__OpenBSD__)
54 # define OPENBSD
55 # endif
57 /* And one for FreeBSD: */
58 # if defined(__FreeBSD__)
59 # define FREEBSD
60 # endif
62 /* Determine the machine type: */
63 # if defined(__arm__) || defined(__thumb__)
64 # define ARM32
65 # if !defined(LINUX) && !defined(NETBSD)
66 # define NOSYS
67 # define mach_type_known
68 # endif
69 # endif
70 # if defined(sun) && defined(mc68000)
71 # define M68K
72 # define SUNOS4
73 # define mach_type_known
74 # endif
75 # if defined(hp9000s300)
76 # define M68K
77 # define HP
78 # define mach_type_known
79 # endif
80 # if defined(OPENBSD) && defined(m68k)
81 # define M68K
82 # define mach_type_known
83 # endif
84 # if defined(OPENBSD) && defined(__sparc__)
85 # define SPARC
86 # define mach_type_known
87 # endif
88 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
89 # define M68K
90 # define mach_type_known
91 # endif
92 # if defined(NETBSD) && defined(__powerpc__)
93 # define POWERPC
94 # define mach_type_known
95 # endif
96 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
97 # define ARM32
98 # define mach_type_known
99 # endif
100 # if defined(vax)
101 # define VAX
102 # ifdef ultrix
103 # define ULTRIX
104 # else
105 # define BSD
106 # endif
107 # define mach_type_known
108 # endif
109 # if defined(__NetBSD__) && defined(__vax__)
110 # define VAX
111 # define mach_type_known
112 # endif
113 # if defined(mips) || defined(__mips) || defined(_mips)
114 # define MIPS
115 # if defined(nec_ews) || defined(_nec_ews)
116 # define EWS4800
117 # endif
118 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
119 # if defined(ultrix) || defined(__ultrix)
120 # define ULTRIX
121 # else
122 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
123 || defined(__SYSTYPE_SVR4__)
124 # define IRIX5 /* or IRIX 6.X */
125 # else
126 # define RISCOS /* or IRIX 4.X */
127 # endif
128 # endif
129 # endif /* !LINUX */
130 # define mach_type_known
131 # endif
132 # if defined(DGUX) && (defined(i386) || defined(__i386__))
133 # define I386
134 # ifndef _USING_DGUX
135 # define _USING_DGUX
136 # endif
137 # define mach_type_known
138 # endif
139 # if defined(sequent) && (defined(i386) || defined(__i386__))
140 # define I386
141 # define SEQUENT
142 # define mach_type_known
143 # endif
144 # if defined(sun) && (defined(i386) || defined(__i386__))
145 # define I386
146 # define SUNOS5
147 # define mach_type_known
148 # endif
149 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
150 # define I386
151 # define OS2
152 # define mach_type_known
153 # endif
154 # if defined(ibm032)
155 # define RT
156 # define mach_type_known
157 # endif
158 # if defined(sun) && (defined(sparc) || defined(__sparc))
159 # define SPARC
160 /* Test for SunOS 5.x */
161 # include <errno.h>
162 # ifdef ECHRNG
163 # define SUNOS5
164 # else
165 # define SUNOS4
166 # endif
167 # define mach_type_known
168 # endif
169 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
170 && !defined(__OpenBSD__) && !(__NetBSD__)
171 # define SPARC
172 # define DRSNX
173 # define mach_type_known
174 # endif
175 # if defined(_IBMR2)
176 # define RS6000
177 # define mach_type_known
178 # endif
179 # if defined(__NetBSD__) && defined(__sparc__)
180 # define SPARC
181 # define mach_type_known
182 # endif
183 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
184 /* The above test may need refinement */
185 # define I386
186 # if defined(_SCO_ELF)
187 # define SCO_ELF
188 # else
189 # define SCO
190 # endif
191 # define mach_type_known
192 # endif
193 # if defined(_AUX_SOURCE)
194 # define M68K
195 # define SYSV
196 # define mach_type_known
197 # endif
198 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
199 || defined(hppa) || defined(__hppa__)
200 # define HP_PA
201 # ifndef LINUX
202 # define HPUX
203 # endif
204 # define mach_type_known
205 # endif
206 # if defined(__ia64) && defined(_HPUX_SOURCE)
207 # define IA64
208 # define HPUX
209 # define mach_type_known
210 # endif
211 # if defined(__BEOS__) && defined(_X86_)
212 # define I386
213 # define BEOS
214 # define mach_type_known
215 # endif
216 # if defined(LINUX) && (defined(i386) || defined(__i386__))
217 # define I386
218 # define mach_type_known
219 # endif
220 # if defined(LINUX) && defined(__x86_64__)
221 # define X86_64
222 # define mach_type_known
223 # endif
224 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
225 # define IA64
226 # define mach_type_known
227 # endif
228 # if defined(LINUX) && defined(__arm__)
229 # define ARM32
230 # define mach_type_known
231 # endif
232 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || defined(powerpc64) || defined(__powerpc64__))
233 # define POWERPC
234 # define mach_type_known
235 # endif
236 # if defined(LINUX) && defined(__mc68000__)
237 # define M68K
238 # define mach_type_known
239 # endif
240 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
241 # define SPARC
242 # define mach_type_known
243 # endif
244 # if defined(LINUX) && defined(__arm__)
245 # define ARM32
246 # define mach_type_known
247 # endif
248 # if defined(LINUX) && defined(__sh__)
249 # define SH
250 # define mach_type_known
251 # endif
252 # if defined(__alpha) || defined(__alpha__)
253 # define ALPHA
254 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
255 # define OSF1 /* a.k.a Digital Unix */
256 # endif
257 # define mach_type_known
258 # endif
259 # if defined(_AMIGA) && !defined(AMIGA)
260 # define AMIGA
261 # endif
262 # ifdef AMIGA
263 # define M68K
264 # define mach_type_known
265 # endif
266 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
267 # define M68K
268 # define MACOS
269 # define mach_type_known
270 # endif
271 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
272 # define POWERPC
273 # define MACOS
274 # define mach_type_known
275 # endif
276 # if defined(macosx) || \
277 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
278 # define DARWIN
279 # define POWERPC
280 # define mach_type_known
281 # endif
282 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
283 # define DARWIN
284 # define I386
285 --> Not really supported, but at least we recognize it.
286 # endif
287 # if defined(NeXT) && defined(mc68000)
288 # define M68K
289 # define NEXT
290 # define mach_type_known
291 # endif
292 # if defined(NeXT) && (defined(i386) || defined(__i386__))
293 # define I386
294 # define NEXT
295 # define mach_type_known
296 # endif
297 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
298 # define I386
299 # define OPENBSD
300 # define mach_type_known
301 # endif
302 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
303 # define I386
304 # define mach_type_known
305 # endif
306 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
307 # define I386
308 # define mach_type_known
309 # endif
310 # if defined(bsdi) && (defined(i386) || defined(__i386__))
311 # define I386
312 # define BSDI
313 # define mach_type_known
314 # endif
315 # if !defined(mach_type_known) && defined(__386BSD__)
316 # define I386
317 # define THREE86BSD
318 # define mach_type_known
319 # endif
320 # if defined(_CX_UX) && defined(_M88K)
321 # define M88K
322 # define CX_UX
323 # define mach_type_known
324 # endif
325 # if defined(DGUX) && defined(m88k)
326 # define M88K
327 /* DGUX defined */
328 # define mach_type_known
329 # endif
330 # if defined(_WIN32_WCE)
331 /* SH3, SH4, MIPS already defined for corresponding architectures */
332 # if defined(SH3) || defined(SH4)
333 # define SH
334 # endif
335 # if defined(x86)
336 # define I386
337 # endif
338 # if defined(ARM)
339 # define ARM32
340 # endif
341 # define MSWINCE
342 # define mach_type_known
343 # else
344 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
345 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
346 # define I386
347 # define MSWIN32 /* or Win32s */
348 # define mach_type_known
349 # endif
350 # endif
351 # if defined(__DJGPP__)
352 # define I386
353 # ifndef DJGPP
354 # define DJGPP /* MSDOS running the DJGPP port of GCC */
355 # endif
356 # define mach_type_known
357 # endif
358 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
359 # define I386
360 # define CYGWIN32
361 # define mach_type_known
362 # endif
363 # if defined(__MINGW32__)
364 # define I386
365 # define MSWIN32
366 # define mach_type_known
367 # endif
368 # if defined(__BORLANDC__)
369 # define I386
370 # define MSWIN32
371 # define mach_type_known
372 # endif
373 # if defined(_UTS) && !defined(mach_type_known)
374 # define S370
375 # define UTS4
376 # define mach_type_known
377 # endif
378 # if defined(__pj__)
379 # define PJ
380 # define mach_type_known
381 # endif
382 # if defined(__embedded__) && defined(PPC)
383 # define POWERPC
384 # define NOSYS
385 # define mach_type_known
386 # endif
387 /* Ivan Demakov */
388 # if defined(__WATCOMC__) && defined(__386__)
389 # define I386
390 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
391 # if defined(__OS2__)
392 # define OS2
393 # else
394 # if defined(__WINDOWS_386__) || defined(__NT__)
395 # define MSWIN32
396 # else
397 # define DOS4GW
398 # endif
399 # endif
400 # endif
401 # define mach_type_known
402 # endif
403 # if defined(__s390__) && defined(LINUX)
404 # define S390
405 # define mach_type_known
406 # endif
407 # if defined(__GNU__)
408 # if defined(__i386__)
409 /* The Debian Hurd running on generic PC */
410 # define HURD
411 # define I386
412 # define mach_type_known
413 # endif
414 # endif
416 /* Feel free to add more clauses here */
418 /* Or manually define the machine type here. A machine type is */
419 /* characterized by the architecture. Some */
420 /* machine types are further subdivided by OS. */
421 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
422 /* Note that SGI IRIX is treated identically to RISCOS. */
423 /* SYSV on an M68K actually means A/UX. */
424 /* The distinction in these cases is usually the stack starting address */
425 # ifndef mach_type_known
426 --> unknown machine type
427 # endif
428 /* Mapping is: M68K ==> Motorola 680X0 */
429 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
430 /* MACOS and AMIGA variants) */
431 /* I386 ==> Intel 386 */
432 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
433 /* FREEBSD, THREE86BSD, MSWIN32, */
434 /* BSDI,SUNOS5, NEXT, other variants) */
435 /* NS32K ==> Encore Multimax */
436 /* MIPS ==> R2000 or R3000 */
437 /* (RISCOS, ULTRIX variants) */
438 /* VAX ==> DEC VAX */
439 /* (BSD, ULTRIX variants) */
440 /* RS6000 ==> IBM RS/6000 AIX3.X */
441 /* RT ==> IBM PC/RT */
442 /* HP_PA ==> HP9000/700 & /800 */
443 /* HP/UX, LINUX */
444 /* SPARC ==> SPARC v7/v8/v9 */
445 /* (SUNOS4, SUNOS5, LINUX, */
446 /* DRSNX variants) */
447 /* ALPHA ==> DEC Alpha */
448 /* (OSF1 and LINUX variants) */
449 /* M88K ==> Motorola 88XX0 */
450 /* (CX_UX and DGUX) */
451 /* S370 ==> 370-like machine */
452 /* running Amdahl UTS4 */
453 /* S390 ==> 390-like machine */
454 /* running LINUX */
455 /* ARM32 ==> Intel StrongARM */
456 /* IA64 ==> Intel IPF */
457 /* (e.g. Itanium) */
458 /* (LINUX and HPUX) */
459 /* SH ==> Hitachi SuperH */
460 /* (LINUX & MSWINCE) */
461 /* X86_64 ==> AMD x86-64 */
462 /* POWERPC ==> IBM/Apple PowerPC */
463 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
464 /* LINUX, NETBSD, NOSYS variants) */
468 * For each architecture and OS, the following need to be defined:
470 * CPP_WORD_SZ is a simple integer constant representing the word size.
471 * in bits. We assume byte addressibility, where a byte has 8 bits.
472 * We also assume CPP_WORD_SZ is either 32 or 64.
473 * (We care about the length of pointers, not hardware
474 * bus widths. Thus a 64 bit processor with a C compiler that uses
475 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
477 * MACH_TYPE is a string representation of the machine type.
478 * OS_TYPE is analogous for the OS.
480 * ALIGNMENT is the largest N, such that
481 * all pointer are guaranteed to be aligned on N byte boundaries.
482 * defining it to be 1 will always work, but perform poorly.
484 * DATASTART is the beginning of the data segment.
485 * On some platforms SEARCH_FOR_DATA_START is defined.
486 * SEARCH_FOR_DATASTART will cause GC_data_start to
487 * be set to an address determined by accessing data backwards from _end
488 * until an unmapped page is found. DATASTART will be defined to be
489 * GC_data_start.
490 * On UNIX-like systems, the collector will scan the area between DATASTART
491 * and DATAEND for root pointers.
493 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
494 * RTH suggests gaining access to linker script synth'd values with
495 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
496 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
497 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
498 * without any special options.
500 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
501 * the pointer size.
503 * STACKBOTTOM is the cool end of the stack, which is usually the
504 * highest address in the stack.
505 * Under PCR or OS/2, we have other ways of finding thread stacks.
506 * For each machine, the following should:
507 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
508 * 2) define exactly one of
509 * STACKBOTTOM (should be defined to be an expression)
510 * LINUX_STACKBOTTOM
511 * HEURISTIC1
512 * HEURISTIC2
513 * If STACKBOTTOM is defined, then it's value will be used directly as the
514 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
515 * with a method appropriate for most Linux systems. Currently we look
516 * first for __libc_stack_end, and if that fails read it from /proc.
517 * If either of the last two macros are defined, then STACKBOTTOM is computed
518 * during collector startup using one of the following two heuristics:
519 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
520 * the next multiple of STACK_GRAN.
521 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
522 * in small steps (decrement if STACK_GROWS_UP), and read the value
523 * at each location. Remember the value when the first
524 * Segmentation violation or Bus error is signalled. Round that
525 * to the nearest plausible page boundary, and use that instead
526 * of STACKBOTTOM.
528 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
529 * the value of environ is a pointer that can serve as STACKBOTTOM.
530 * I expect that HEURISTIC2 can be replaced by this approach, which
531 * interferes far less with debugging. However it has the disadvantage
532 * that it's confused by a putenv call before the collector is initialized.
533 * This could be dealt with by intercepting putenv ...
535 * If no expression for STACKBOTTOM can be found, and neither of the above
536 * heuristics are usable, the collector can still be used with all of the above
537 * undefined, provided one of the following is done:
538 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
539 * without reference to STACKBOTTOM. This is appropriate for use in
540 * conjunction with thread packages, since there will be multiple stacks.
541 * (Allocating thread stacks in the heap, and treating them as ordinary
542 * heap data objects is also possible as a last resort. However, this is
543 * likely to introduce significant amounts of excess storage retention
544 * unless the dead parts of the thread stacks are periodically cleared.)
545 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
546 * If the author of the client code controls the main program, this is
547 * easily accomplished by introducing a new main program, setting
548 * GC_stackbottom to the address of a local variable, and then calling
549 * the original main program. The new main program would read something
550 * like:
552 * # include "gc_private.h"
554 * main(argc, argv, envp)
555 * int argc;
556 * char **argv, **envp;
558 * int dummy;
560 * GC_stackbottom = (ptr_t)(&dummy);
561 * return(real_main(argc, argv, envp));
565 * Each architecture may also define the style of virtual dirty bit
566 * implementation to be used:
567 * MPROTECT_VDB: Write protect the heap and catch faults.
568 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
570 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
571 * defined GC_register_dynamic_libraries() for the architecture.
573 * An architecture may define PREFETCH(x) to preload the cache with *x.
574 * This defaults to a no-op.
576 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
578 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
579 * clear the two words at GC_malloc-aligned address x. By default,
580 * word stores of 0 are used instead.
582 * HEAP_START may be defined as the initial address hint for mmap-based
583 * allocation.
586 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
587 * to push the relevant registers onto the stack. This generally makes
588 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
590 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
591 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
592 # define HAVE_BUILTIN_UNWIND_INIT
593 # endif
595 # define STACK_GRAN 0x1000000
596 # ifdef M68K
597 # define MACH_TYPE "M68K"
598 # define ALIGNMENT 2
599 # ifdef OPENBSD
600 # define OS_TYPE "OPENBSD"
601 # define HEURISTIC2
602 extern char etext[];
603 # define DATASTART ((ptr_t)(etext))
604 # endif
605 # ifdef NETBSD
606 # define OS_TYPE "NETBSD"
607 # define HEURISTIC2
608 # ifdef __ELF__
609 # define DATASTART GC_data_start
610 # define DYNAMIC_LOADING
611 # else
612 extern char etext[];
613 # define DATASTART ((ptr_t)(etext))
614 # endif
615 # endif
616 # ifdef LINUX
617 # define OS_TYPE "LINUX"
618 # define STACKBOTTOM ((ptr_t)0xf0000000)
619 # define USE_GENERIC_PUSH_REGS
620 /* We never got around to the assembly version. */
621 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
622 # ifdef __ELF__
623 # define DYNAMIC_LOADING
624 # include <features.h>
625 # if defined(__GLIBC__)&& __GLIBC__>=2
626 # define SEARCH_FOR_DATA_START
627 # else /* !GLIBC2 */
628 extern char **__environ;
629 # define DATASTART ((ptr_t)(&__environ))
630 /* hideous kludge: __environ is the first */
631 /* word in crt0.o, and delimits the start */
632 /* of the data segment, no matter which */
633 /* ld options were passed through. */
634 /* We could use _etext instead, but that */
635 /* would include .rodata, which may */
636 /* contain large read-only data tables */
637 /* that we'd rather not scan. */
638 # endif /* !GLIBC2 */
639 extern int _end[];
640 # define DATAEND (_end)
641 # else
642 extern int etext[];
643 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
644 # endif
645 # endif
646 # ifdef SUNOS4
647 # define OS_TYPE "SUNOS4"
648 extern char etext[];
649 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
650 # define HEURISTIC1 /* differs */
651 # define DYNAMIC_LOADING
652 # endif
653 # ifdef HP
654 # define OS_TYPE "HP"
655 extern char etext[];
656 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
657 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
658 /* empirically determined. seems to work. */
659 # include <unistd.h>
660 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
661 # endif
662 # ifdef SYSV
663 # define OS_TYPE "SYSV"
664 extern etext[];
665 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
666 & ~0x3fffff) \
667 +((word)etext & 0x1fff))
668 /* This only works for shared-text binaries with magic number 0413.
669 The other sorts of SysV binaries put the data at the end of the text,
670 in which case the default of etext would work. Unfortunately,
671 handling both would require having the magic-number available.
672 -- Parag
674 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
675 /* The stack starts at the top of memory, but */
676 /* 0x0 cannot be used as setjump_test complains */
677 /* that the stack direction is incorrect. Two */
678 /* bytes down from 0x0 should be safe enough. */
679 /* --Parag */
680 # include <sys/mmu.h>
681 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
682 # endif
683 # ifdef AMIGA
684 # define OS_TYPE "AMIGA"
685 /* STACKBOTTOM and DATASTART handled specially */
686 /* in os_dep.c */
687 # define DATAEND /* not needed */
688 # define GETPAGESIZE() 4096
689 # endif
690 # ifdef MACOS
691 # ifndef __LOWMEM__
692 # include <LowMem.h>
693 # endif
694 # define OS_TYPE "MACOS"
695 /* see os_dep.c for details of global data segments. */
696 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
697 # define DATAEND /* not needed */
698 # define GETPAGESIZE() 4096
699 # endif
700 # ifdef NEXT
701 # define OS_TYPE "NEXT"
702 # define DATASTART ((ptr_t) get_etext())
703 # define STACKBOTTOM ((ptr_t) 0x4000000)
704 # define DATAEND /* not needed */
705 # endif
706 # endif
708 # ifdef POWERPC
709 # define MACH_TYPE "POWERPC"
710 # ifdef MACOS
711 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
712 # ifndef __LOWMEM__
713 # include <LowMem.h>
714 # endif
715 # define OS_TYPE "MACOS"
716 /* see os_dep.c for details of global data segments. */
717 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
718 # define DATAEND /* not needed */
719 # endif
720 # ifdef LINUX
721 # if (defined (powerpc64) || defined(__powerpc64__))
722 # define ALIGNMENT 8
723 # define CPP_WORDSZ 64
724 # else
725 # define ALIGNMENT 4
726 # endif
727 # define OS_TYPE "LINUX"
728 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
729 /* executable on a 64 bit kernel. */
730 # define LINUX_STACKBOTTOM
731 # define DYNAMIC_LOADING
732 # define SEARCH_FOR_DATA_START
733 extern int _end[];
734 # define DATAEND (_end)
735 # endif
736 # ifdef DARWIN
737 # define ALIGNMENT 4
738 # define OS_TYPE "DARWIN"
739 # define DYNAMIC_LOADING
740 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
741 These aren't used when dyld support is enabled (it is by default) */
742 # define DATASTART ((ptr_t) get_etext())
743 # define DATAEND ((ptr_t) get_end())
744 # define STACKBOTTOM ((ptr_t) 0xc0000000)
745 # define USE_MMAP
746 # define USE_MMAP_ANON
747 # define USE_ASM_PUSH_REGS
748 /* This is potentially buggy. It needs more testing. See the comments in
749 os_dep.c */
750 # define MPROTECT_VDB
751 # include <unistd.h>
752 # define GETPAGESIZE() getpagesize()
753 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
754 /* The performance impact of prefetches is untested */
755 # define PREFETCH(x) \
756 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
757 # define PREFETCH_FOR_WRITE(x) \
758 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
759 # endif
760 /* There seems to be some issues with trylock hanging on darwin. This
761 should be looked into some more */
762 # define NO_PTHREAD_TRYLOCK
763 # endif
764 # ifdef NETBSD
765 # define ALIGNMENT 4
766 # define OS_TYPE "NETBSD"
767 # define HEURISTIC2
768 extern char etext[];
769 # define DATASTART GC_data_start
770 # define DYNAMIC_LOADING
771 # endif
772 # ifdef NOSYS
773 # define ALIGNMENT 4
774 # define OS_TYPE "NOSYS"
775 extern void __end[], __dso_handle[];
776 # define DATASTART (__dso_handle) /* OK, that's ugly. */
777 # define DATAEND (__end)
778 /* Stack starts at 0xE0000000 for the simulator. */
779 # undef STACK_GRAN
780 # define STACK_GRAN 0x10000000
781 # define HEURISTIC1
782 # endif
783 # endif
785 # ifdef VAX
786 # define MACH_TYPE "VAX"
787 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
788 extern char etext[];
789 # define DATASTART ((ptr_t)(etext))
790 # ifdef BSD
791 # define OS_TYPE "BSD"
792 # define HEURISTIC1
793 /* HEURISTIC2 may be OK, but it's hard to test. */
794 # endif
795 # ifdef ULTRIX
796 # define OS_TYPE "ULTRIX"
797 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
798 # endif
799 # endif
801 # ifdef RT
802 # define MACH_TYPE "RT"
803 # define ALIGNMENT 4
804 # define DATASTART ((ptr_t) 0x10000000)
805 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
806 # endif
808 # ifdef SPARC
809 # define MACH_TYPE "SPARC"
810 # if defined(__arch64__) || defined(__sparcv9)
811 # define ALIGNMENT 8
812 # define CPP_WORDSZ 64
813 # define ELF_CLASS ELFCLASS64
814 # else
815 # define ALIGNMENT 4 /* Required by hardware */
816 # define CPP_WORDSZ 32
817 # endif
818 # define ALIGN_DOUBLE
819 # ifdef SUNOS5
820 # define OS_TYPE "SUNOS5"
821 extern int _etext[];
822 extern int _end[];
823 extern ptr_t GC_SysVGetDataStart();
824 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
825 # define DATAEND (_end)
826 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
827 # define USE_MMAP
828 /* Otherwise we now use calloc. Mmap may result in the */
829 /* heap interleaved with thread stacks, which can result in */
830 /* excessive blacklisting. Sbrk is unusable since it */
831 /* doesn't interact correctly with the system malloc. */
832 # endif
833 # ifdef USE_MMAP
834 # define HEAP_START (ptr_t)0x40000000
835 # else
836 # define HEAP_START DATAEND
837 # endif
838 # define PROC_VDB
839 /* HEURISTIC1 reportedly no longer works under 2.7. */
840 /* HEURISTIC2 probably works, but this appears to be preferable. */
841 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
842 /* installations that's undefined. We work around this with a */
843 /* gross hack: */
844 # include <sys/vmparam.h>
845 # ifdef USERLIMIT
846 /* This should work everywhere, but doesn't. */
847 # define STACKBOTTOM USRSTACK
848 # else
849 # define HEURISTIC2
850 # endif
851 # include <unistd.h>
852 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
853 /* getpagesize() appeared to be missing from at least one */
854 /* Solaris 5.4 installation. Weird. */
855 # define DYNAMIC_LOADING
856 # endif
857 # ifdef SUNOS4
858 # define OS_TYPE "SUNOS4"
859 /* [If you have a weak stomach, don't read this.] */
860 /* We would like to use: */
861 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
862 /* This fails occasionally, due to an ancient, but very */
863 /* persistent ld bug. etext is set 32 bytes too high. */
864 /* We instead read the text segment size from the a.out */
865 /* header, which happens to be mapped into our address space */
866 /* at the start of the text segment. The detective work here */
867 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
868 /* Serpette of INRIA. */
869 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
870 # define TEXTSTART 0x2000
871 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
872 # define MPROTECT_VDB
873 # define HEURISTIC1
874 # define DYNAMIC_LOADING
875 # endif
876 # ifdef DRSNX
877 # define OS_TYPE "DRSNX"
878 extern ptr_t GC_SysVGetDataStart();
879 extern int etext[];
880 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
881 # define MPROTECT_VDB
882 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
883 # define DYNAMIC_LOADING
884 # endif
885 # ifdef LINUX
886 # define OS_TYPE "LINUX"
887 # ifdef __ELF__
888 # define DYNAMIC_LOADING
889 # else
890 Linux Sparc/a.out not supported
891 # endif
892 extern int _end[];
893 extern int _etext[];
894 # define DATAEND (_end)
895 # define SVR4
896 extern ptr_t GC_SysVGetDataStart();
897 # ifdef __arch64__
898 # define DATASTART GC_SysVGetDataStart(0x100000, _etext)
899 /* libc_stack_end is not set reliably for sparc64 */
900 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
901 # else
902 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
903 # define LINUX_STACKBOTTOM
904 # endif
905 # endif
906 # ifdef OPENBSD
907 # define OS_TYPE "OPENBSD"
908 # define STACKBOTTOM ((ptr_t) 0xf8000000)
909 extern int etext[];
910 # define DATASTART ((ptr_t)(etext))
911 # endif
912 # ifdef NETBSD
913 # define OS_TYPE "NETBSD"
914 # define HEURISTIC2
915 # ifdef __ELF__
916 # define DATASTART GC_data_start
917 # define DYNAMIC_LOADING
918 # else
919 extern char etext[];
920 # define DATASTART ((ptr_t)(etext))
921 # endif
922 # endif
923 # endif
925 # ifdef I386
926 # define MACH_TYPE "I386"
927 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
928 /* except Borland. The -a4 option fixes */
929 /* Borland. */
930 /* Ivan Demakov: For Watcom the option is -zp4. */
931 # ifndef SMALL_CONFIG
932 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
933 /* improvement on Pentiums. */
934 # endif
935 # ifdef HAVE_BUILTIN_UNWIND_INIT
936 # define USE_GENERIC_PUSH_REGS
937 # endif
938 # ifdef SEQUENT
939 # define OS_TYPE "SEQUENT"
940 extern int etext[];
941 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
942 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
943 # endif
944 # ifdef BEOS
945 # define OS_TYPE "BEOS"
946 # include <OS.h>
947 # define GETPAGESIZE() B_PAGE_SIZE
948 extern int etext[];
949 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
950 # endif
951 # ifdef SUNOS5
952 # define OS_TYPE "SUNOS5"
953 extern int _etext[], _end[];
954 extern ptr_t GC_SysVGetDataStart();
955 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
956 # define DATAEND (_end)
957 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
958 /* but reportedly breaks under 2.8. It appears that the stack */
959 /* base is a property of the executable, so this should not break */
960 /* old executables. */
961 /* HEURISTIC2 probably works, but this appears to be preferable. */
962 # include <sys/vm.h>
963 # define STACKBOTTOM USRSTACK
964 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
965 /* It appears to be fixed in 2.8 and 2.9. */
966 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
967 # define PROC_VDB
968 # endif
969 # define DYNAMIC_LOADING
970 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
971 # define USE_MMAP
972 /* Otherwise we now use calloc. Mmap may result in the */
973 /* heap interleaved with thread stacks, which can result in */
974 /* excessive blacklisting. Sbrk is unusable since it */
975 /* doesn't interact correctly with the system malloc. */
976 # endif
977 # ifdef USE_MMAP
978 # define HEAP_START (ptr_t)0x40000000
979 # else
980 # define HEAP_START DATAEND
981 # endif
982 # endif
983 # ifdef SCO
984 # define OS_TYPE "SCO"
985 extern int etext[];
986 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
987 & ~0x3fffff) \
988 +((word)etext & 0xfff))
989 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
990 # endif
991 # ifdef SCO_ELF
992 # define OS_TYPE "SCO_ELF"
993 extern int etext[];
994 # define DATASTART ((ptr_t)(etext))
995 # define STACKBOTTOM ((ptr_t) 0x08048000)
996 # define DYNAMIC_LOADING
997 # define ELF_CLASS ELFCLASS32
998 # endif
999 # ifdef DGUX
1000 # define OS_TYPE "DGUX"
1001 extern int _etext, _end;
1002 extern ptr_t GC_SysVGetDataStart();
1003 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1004 # define DATAEND (&_end)
1005 # define STACK_GROWS_DOWN
1006 # define HEURISTIC2
1007 # include <unistd.h>
1008 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1009 # define DYNAMIC_LOADING
1010 # ifndef USE_MMAP
1011 # define USE_MMAP
1012 # endif /* USE_MMAP */
1013 # define MAP_FAILED (void *) -1
1014 # ifdef USE_MMAP
1015 # define HEAP_START (ptr_t)0x40000000
1016 # else /* USE_MMAP */
1017 # define HEAP_START DATAEND
1018 # endif /* USE_MMAP */
1019 # endif /* DGUX */
1021 # ifdef LINUX
1022 # ifndef __GNUC__
1023 /* The Intel compiler doesn't like inline assembly */
1024 # define USE_GENERIC_PUSH_REGS
1025 # endif
1026 # define OS_TYPE "LINUX"
1027 # define LINUX_STACKBOTTOM
1028 # if 0
1029 # define HEURISTIC1
1030 # undef STACK_GRAN
1031 # define STACK_GRAN 0x10000000
1032 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1033 /* different kernel configurations. In particular, systems */
1034 /* with 2GB physical memory will usually move the user */
1035 /* address space limit, and hence initial SP to 0x80000000. */
1036 # endif
1037 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1038 # define MPROTECT_VDB
1039 # else
1040 /* We seem to get random errors in incremental mode, */
1041 /* possibly because Linux threads is itself a malloc client */
1042 /* and can't deal with the signals. */
1043 # endif
1044 # define HEAP_START 0x1000
1045 /* This encourages mmap to give us low addresses, */
1046 /* thus allowing the heap to grow to ~3GB */
1047 # ifdef __ELF__
1048 # define DYNAMIC_LOADING
1049 # ifdef UNDEFINED /* includes ro data */
1050 extern int _etext[];
1051 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1052 # endif
1053 # include <features.h>
1054 # if defined(__GLIBC__) && __GLIBC__ >= 2
1055 # define SEARCH_FOR_DATA_START
1056 # else
1057 extern char **__environ;
1058 # define DATASTART ((ptr_t)(&__environ))
1059 /* hideous kludge: __environ is the first */
1060 /* word in crt0.o, and delimits the start */
1061 /* of the data segment, no matter which */
1062 /* ld options were passed through. */
1063 /* We could use _etext instead, but that */
1064 /* would include .rodata, which may */
1065 /* contain large read-only data tables */
1066 /* that we'd rather not scan. */
1067 # endif
1068 extern int _end[];
1069 # define DATAEND (_end)
1070 # else
1071 extern int etext[];
1072 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1073 # endif
1074 # ifdef USE_I686_PREFETCH
1075 # define PREFETCH(x) \
1076 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1077 /* Empirically prefetcht0 is much more effective at reducing */
1078 /* cache miss stalls for the targetted load instructions. But it */
1079 /* seems to interfere enough with other cache traffic that the net */
1080 /* result is worse than prefetchnta. */
1081 # if 0
1082 /* Using prefetches for write seems to have a slight negative */
1083 /* impact on performance, at least for a PIII/500. */
1084 # define PREFETCH_FOR_WRITE(x) \
1085 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1086 # endif
1087 # endif
1088 # ifdef USE_3DNOW_PREFETCH
1089 # define PREFETCH(x) \
1090 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1091 # define PREFETCH_FOR_WRITE(x) \
1092 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1093 # endif
1094 # endif
1095 # ifdef CYGWIN32
1096 # define OS_TYPE "CYGWIN32"
1097 extern int _data_start__[];
1098 extern int _data_end__[];
1099 extern int _bss_start__[];
1100 extern int _bss_end__[];
1101 /* For binutils 2.9.1, we have */
1102 /* DATASTART = _data_start__ */
1103 /* DATAEND = _bss_end__ */
1104 /* whereas for some earlier versions it was */
1105 /* DATASTART = _bss_start__ */
1106 /* DATAEND = _data_end__ */
1107 /* To get it right for both, we take the */
1108 /* minumum/maximum of the two. */
1109 # ifndef MAX
1110 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1111 # endif
1112 # ifndef MIN
1113 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1114 # endif
1115 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1116 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1117 # undef STACK_GRAN
1118 # define STACK_GRAN 0x10000
1119 # define HEURISTIC1
1120 # endif
1121 # ifdef OS2
1122 # define OS_TYPE "OS2"
1123 /* STACKBOTTOM and DATASTART are handled specially in */
1124 /* os_dep.c. OS2 actually has the right */
1125 /* system call! */
1126 # define DATAEND /* not needed */
1127 # define USE_GENERIC_PUSH_REGS
1128 # endif
1129 # ifdef MSWIN32
1130 # define OS_TYPE "MSWIN32"
1131 /* STACKBOTTOM and DATASTART are handled specially in */
1132 /* os_dep.c. */
1133 # ifndef __WATCOMC__
1134 # define MPROTECT_VDB
1135 # endif
1136 # define DATAEND /* not needed */
1137 # endif
1138 # ifdef MSWINCE
1139 # define OS_TYPE "MSWINCE"
1140 # define DATAEND /* not needed */
1141 # endif
1142 # ifdef DJGPP
1143 # define OS_TYPE "DJGPP"
1144 # include "stubinfo.h"
1145 extern int etext[];
1146 extern int _stklen;
1147 extern int __djgpp_stack_limit;
1148 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1149 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1150 + _stklen)) */
1151 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1152 /* This may not be right. */
1153 # endif
1154 # ifdef OPENBSD
1155 # define OS_TYPE "OPENBSD"
1156 # endif
1157 # ifdef FREEBSD
1158 # define OS_TYPE "FREEBSD"
1159 # ifndef GC_FREEBSD_THREADS
1160 # define MPROTECT_VDB
1161 # endif
1162 # define SIG_SUSPEND SIGUSR1
1163 # define SIG_THR_RESTART SIGUSR2
1164 # define FREEBSD_STACKBOTTOM
1165 # ifdef __ELF__
1166 # define DYNAMIC_LOADING
1167 # endif
1168 extern char etext[];
1169 extern char * GC_FreeBSDGetDataStart();
1170 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1171 # endif
1172 # ifdef NETBSD
1173 # define OS_TYPE "NETBSD"
1174 # ifdef __ELF__
1175 # define DYNAMIC_LOADING
1176 # endif
1177 # endif
1178 # ifdef THREE86BSD
1179 # define OS_TYPE "THREE86BSD"
1180 # endif
1181 # ifdef BSDI
1182 # define OS_TYPE "BSDI"
1183 # endif
1184 # if defined(OPENBSD) || defined(NETBSD) \
1185 || defined(THREE86BSD) || defined(BSDI)
1186 # define HEURISTIC2
1187 extern char etext[];
1188 # define DATASTART ((ptr_t)(etext))
1189 # endif
1190 # ifdef NEXT
1191 # define OS_TYPE "NEXT"
1192 # define DATASTART ((ptr_t) get_etext())
1193 # define STACKBOTTOM ((ptr_t)0xc0000000)
1194 # define DATAEND /* not needed */
1195 # endif
1196 # ifdef DOS4GW
1197 # define OS_TYPE "DOS4GW"
1198 extern long __nullarea;
1199 extern char _end;
1200 extern char *_STACKTOP;
1201 /* Depending on calling conventions Watcom C either precedes
1202 or does not precedes with undescore names of C-variables.
1203 Make sure startup code variables always have the same names. */
1204 #pragma aux __nullarea "*";
1205 #pragma aux _end "*";
1206 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1207 /* confused? me too. */
1208 # define DATASTART ((ptr_t) &__nullarea)
1209 # define DATAEND ((ptr_t) &_end)
1210 # endif
1211 # ifdef HURD
1212 # define OS_TYPE "HURD"
1213 # define STACK_GROWS_DOWN
1214 # define HEURISTIC2
1215 extern int __data_start[];
1216 # define DATASTART ( (ptr_t) (__data_start))
1217 extern int _end[];
1218 # define DATAEND ( (ptr_t) (_end))
1219 /* # define MPROTECT_VDB Not quite working yet? */
1220 # define DYNAMIC_LOADING
1221 # endif
1222 # endif
1224 # ifdef NS32K
1225 # define MACH_TYPE "NS32K"
1226 # define ALIGNMENT 4
1227 extern char **environ;
1228 # define DATASTART ((ptr_t)(&environ))
1229 /* hideous kludge: environ is the first */
1230 /* word in crt0.o, and delimits the start */
1231 /* of the data segment, no matter which */
1232 /* ld options were passed through. */
1233 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1234 # endif
1236 # ifdef MIPS
1237 # define MACH_TYPE "MIPS"
1238 # ifdef LINUX
1239 /* This was developed for a linuxce style platform. Probably */
1240 /* needs to be tweaked for workstation class machines. */
1241 # define OS_TYPE "LINUX"
1242 # define DYNAMIC_LOADING
1243 extern int _end[];
1244 # define DATAEND (_end)
1245 extern int __data_start[];
1246 # define DATASTART ((ptr_t)(__data_start))
1247 # define ALIGNMENT 4
1248 # define USE_GENERIC_PUSH_REGS
1249 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1250 # define LINUX_STACKBOTTOM
1251 # else
1252 # define STACKBOTTOM 0x80000000
1253 # endif
1254 # endif /* Linux */
1255 # ifdef EWS4800
1256 # define HEURISTIC2
1257 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1258 extern int _fdata[], _end[];
1259 # define DATASTART ((ptr_t)_fdata)
1260 # define DATAEND ((ptr_t)_end)
1261 # define CPP_WORDSZ _MIPS_SZPTR
1262 # define ALIGNMENT (_MIPS_SZPTR/8)
1263 # else
1264 extern int etext[], edata[], end[];
1265 extern int _DYNAMIC_LINKING[], _gp[];
1266 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1267 + ((word)etext & 0xffff)))
1268 # define DATAEND (edata)
1269 # define DATASTART2 (_DYNAMIC_LINKING \
1270 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1271 : (ptr_t)edata)
1272 # define DATAEND2 (end)
1273 # define ALIGNMENT 4
1274 # endif
1275 # define OS_TYPE "EWS4800"
1276 # define USE_GENERIC_PUSH_REGS 1
1277 # endif
1278 # ifdef ULTRIX
1279 # define HEURISTIC2
1280 # define DATASTART (ptr_t)0x10000000
1281 /* Could probably be slightly higher since */
1282 /* startup code allocates lots of stuff. */
1283 # define OS_TYPE "ULTRIX"
1284 # define ALIGNMENT 4
1285 # endif
1286 # ifdef RISCOS
1287 # define HEURISTIC2
1288 # define DATASTART (ptr_t)0x10000000
1289 # define OS_TYPE "RISCOS"
1290 # define ALIGNMENT 4 /* Required by hardware */
1291 # endif
1292 # ifdef IRIX5
1293 # define HEURISTIC2
1294 extern int _fdata[];
1295 # define DATASTART ((ptr_t)(_fdata))
1296 # ifdef USE_MMAP
1297 # define HEAP_START (ptr_t)0x30000000
1298 # else
1299 # define HEAP_START DATASTART
1300 # endif
1301 /* Lowest plausible heap address. */
1302 /* In the MMAP case, we map there. */
1303 /* In either case it is used to identify */
1304 /* heap sections so they're not */
1305 /* considered as roots. */
1306 # define OS_TYPE "IRIX5"
1307 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1308 /* of recent breakage. */
1309 # ifdef _MIPS_SZPTR
1310 # define CPP_WORDSZ _MIPS_SZPTR
1311 # define ALIGNMENT (_MIPS_SZPTR/8)
1312 # if CPP_WORDSZ != 64
1313 # define ALIGN_DOUBLE
1314 # endif
1315 # else
1316 # define ALIGNMENT 4
1317 # define ALIGN_DOUBLE
1318 # endif
1319 # define DYNAMIC_LOADING
1320 # endif
1321 # ifdef MSWINCE
1322 # define OS_TYPE "MSWINCE"
1323 # define ALIGNMENT 4
1324 # define DATAEND /* not needed */
1325 # endif
1326 # if defined(NETBSD)
1327 # define OS_TYPE "NETBSD"
1328 # define ALIGNMENT 4
1329 # define HEURISTIC2
1330 # define USE_GENERIC_PUSH_REGS
1331 # ifdef __ELF__
1332 extern int etext[];
1333 # define DATASTART GC_data_start
1334 # define NEED_FIND_LIMIT
1335 # define DYNAMIC_LOADING
1336 # else
1337 # define DATASTART ((ptr_t) 0x10000000)
1338 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1339 # endif /* _ELF_ */
1340 # endif
1341 # endif
1343 # ifdef RS6000
1344 # define MACH_TYPE "RS6000"
1345 # ifdef ALIGNMENT
1346 # undef ALIGNMENT
1347 # endif
1348 # ifdef IA64
1349 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1350 # endif
1351 # ifdef __64BIT__
1352 # define ALIGNMENT 8
1353 # define CPP_WORDSZ 64
1354 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1355 # else
1356 # define ALIGNMENT 4
1357 # define CPP_WORDSZ 32
1358 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1359 # endif
1360 /* From AIX linker man page:
1361 _text Specifies the first location of the program.
1362 _etext Specifies the first location after the program.
1363 _data Specifies the first location of the data.
1364 _edata Specifies the first location after the initialized data
1365 _end or end Specifies the first location after all data.
1367 extern int _data[], _end[];
1368 # define DATASTART ((ptr_t)((ulong)_data))
1369 # define DATAEND ((ptr_t)((ulong)_end))
1370 extern int errno;
1371 # define USE_GENERIC_PUSH_REGS
1372 # define DYNAMIC_LOADING
1373 /* For really old versions of AIX, this may have to be removed. */
1374 # endif
1376 # ifdef HP_PA
1377 # define MACH_TYPE "HP_PA"
1378 # ifdef __LP64__
1379 # define CPP_WORDSZ 64
1380 # define ALIGNMENT 8
1381 # else
1382 # define CPP_WORDSZ 32
1383 # define ALIGNMENT 4
1384 # define ALIGN_DOUBLE
1385 # endif
1386 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1387 # ifndef LINUX /* For now. */
1388 # define MPROTECT_VDB
1389 # endif
1390 # else
1391 # define GENERIC_COMPARE_AND_SWAP
1392 /* No compare-and-swap instruction. Use pthread mutexes */
1393 /* when we absolutely have to. */
1394 # ifdef PARALLEL_MARK
1395 # define USE_MARK_BYTES
1396 /* Minimize compare-and-swap usage. */
1397 # endif
1398 # endif
1399 # define STACK_GROWS_UP
1400 # ifdef HPUX
1401 # define OS_TYPE "HPUX"
1402 extern int __data_start[];
1403 # define DATASTART ((ptr_t)(__data_start))
1404 # if 0
1405 /* The following appears to work for 7xx systems running HP/UX */
1406 /* 9.xx Furthermore, it might result in much faster */
1407 /* collections than HEURISTIC2, which may involve scanning */
1408 /* segments that directly precede the stack. It is not the */
1409 /* default, since it may not work on older machine/OS */
1410 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1411 /* this.) */
1412 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1413 # else
1414 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1415 /* to this. Note that the GC must be initialized before the */
1416 /* first putenv call. */
1417 extern char ** environ;
1418 # define STACKBOTTOM ((ptr_t)environ)
1419 # endif
1420 # define DYNAMIC_LOADING
1421 # include <unistd.h>
1422 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1423 # ifndef __GNUC__
1424 # define PREFETCH(x) { \
1425 register long addr = (long)(x); \
1426 (void) _asm ("LDW", 0, 0, addr, 0); \
1428 # endif
1429 # endif /* HPUX */
1430 # ifdef LINUX
1431 # define OS_TYPE "LINUX"
1432 # define LINUX_STACKBOTTOM
1433 # define DYNAMIC_LOADING
1434 # define SEARCH_FOR_DATA_START
1435 extern int _end[];
1436 # define DATAEND (&_end)
1437 # endif /* LINUX */
1438 # endif /* HP_PA */
1440 # ifdef ALPHA
1441 # define MACH_TYPE "ALPHA"
1442 # define ALIGNMENT 8
1443 # define CPP_WORDSZ 64
1444 # ifndef LINUX
1445 # define USE_GENERIC_PUSH_REGS
1446 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1447 /* fp registers in some cases when the target is a 21264. The assembly */
1448 /* code doesn't handle that yet, and version dependencies make that a */
1449 /* bit tricky. Do the easy thing for now. */
1450 # endif
1451 # ifdef NETBSD
1452 # define OS_TYPE "NETBSD"
1453 # define HEURISTIC2
1454 # define DATASTART GC_data_start
1455 # define ELFCLASS32 32
1456 # define ELFCLASS64 64
1457 # define ELF_CLASS ELFCLASS64
1458 # define DYNAMIC_LOADING
1459 # endif
1460 # ifdef OPENBSD
1461 # define OS_TYPE "OPENBSD"
1462 # define HEURISTIC2
1463 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1464 # define DATASTART GC_data_start
1465 # define ELFCLASS32 32
1466 # define ELFCLASS64 64
1467 # define ELF_CLASS ELFCLASS64
1468 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1469 # define DATASTART ((ptr_t) 0x140000000)
1470 # endif
1471 # endif
1472 # ifdef FREEBSD
1473 # define OS_TYPE "FREEBSD"
1474 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1475 # define SIG_SUSPEND SIGUSR1
1476 # define SIG_THR_RESTART SIGUSR2
1477 # define FREEBSD_STACKBOTTOM
1478 # ifdef __ELF__
1479 # define DYNAMIC_LOADING
1480 # endif
1481 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1482 extern char etext[];
1483 extern char edata[];
1484 extern char end[];
1485 # define NEED_FIND_LIMIT
1486 # define DATASTART ((ptr_t)(&etext))
1487 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1488 # define DATASTART2 ((ptr_t)(&edata))
1489 # define DATAEND2 ((ptr_t)(&end))
1490 # endif
1491 # ifdef OSF1
1492 # define OS_TYPE "OSF1"
1493 # define DATASTART ((ptr_t) 0x140000000)
1494 extern int _end[];
1495 # define DATAEND ((ptr_t) &_end)
1496 extern char ** environ;
1497 /* round up from the value of environ to the nearest page boundary */
1498 /* Probably breaks if putenv is called before collector */
1499 /* initialization. */
1500 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1501 /* # define HEURISTIC2 */
1502 /* Normally HEURISTIC2 is too conervative, since */
1503 /* the text segment immediately follows the stack. */
1504 /* Hence we give an upper pound. */
1505 /* This is currently unused, since we disabled HEURISTIC2 */
1506 extern int __start[];
1507 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1508 # ifndef GC_OSF1_THREADS
1509 /* Unresolved signal issues with threads. */
1510 # define MPROTECT_VDB
1511 # endif
1512 # define DYNAMIC_LOADING
1513 # endif
1514 # ifdef LINUX
1515 # define OS_TYPE "LINUX"
1516 # define STACKBOTTOM ((ptr_t) 0x120000000)
1517 # ifdef __ELF__
1518 # define SEARCH_FOR_DATA_START
1519 # define DYNAMIC_LOADING
1520 # else
1521 # define DATASTART ((ptr_t) 0x140000000)
1522 # endif
1523 extern int _end[];
1524 # define DATAEND (_end)
1525 # define MPROTECT_VDB
1526 /* Has only been superficially tested. May not */
1527 /* work on all versions. */
1528 # endif
1529 # endif
1531 # ifdef IA64
1532 # define MACH_TYPE "IA64"
1533 # define USE_GENERIC_PUSH_REGS
1534 /* We need to get preserved registers in addition to register */
1535 /* windows. That's easiest to do with setjmp. */
1536 # ifdef PARALLEL_MARK
1537 # define USE_MARK_BYTES
1538 /* Compare-and-exchange is too expensive to use for */
1539 /* setting mark bits. */
1540 # endif
1541 # ifdef HPUX
1542 # ifdef _ILP32
1543 # define CPP_WORDSZ 32
1544 # define ALIGN_DOUBLE
1545 /* Requires 8 byte alignment for malloc */
1546 # define ALIGNMENT 4
1547 # else
1548 # ifndef _LP64
1549 ---> unknown ABI
1550 # endif
1551 # define CPP_WORDSZ 64
1552 # define ALIGN_DOUBLE
1553 /* Requires 16 byte alignment for malloc */
1554 # define ALIGNMENT 8
1555 # endif
1556 # define OS_TYPE "HPUX"
1557 extern int __data_start[];
1558 # define DATASTART ((ptr_t)(__data_start))
1559 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1560 /* to this. Note that the GC must be initialized before the */
1561 /* first putenv call. */
1562 extern char ** environ;
1563 # define STACKBOTTOM ((ptr_t)environ)
1564 # define DYNAMIC_LOADING
1565 # include <unistd.h>
1566 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1567 /* The following was empirically determined, and is probably */
1568 /* not very robust. */
1569 /* Note that the backing store base seems to be at a nice */
1570 /* address minus one page. */
1571 # define BACKING_STORE_DISPLACEMENT 0x1000000
1572 # define BACKING_STORE_ALIGNMENT 0x1000
1573 # define BACKING_STORE_BASE \
1574 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1575 & ~(BACKING_STORE_ALIGNMENT - 1))
1576 # endif
1577 # ifdef LINUX
1578 # define CPP_WORDSZ 64
1579 # define ALIGN_DOUBLE
1580 /* Requires 16 byte alignment for malloc */
1581 # define ALIGNMENT 8
1582 # define OS_TYPE "LINUX"
1583 /* The following works on NUE and older kernels: */
1584 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1585 /* This does not work on NUE: */
1586 # define LINUX_STACKBOTTOM
1587 /* We also need the base address of the register stack */
1588 /* backing store. This is computed in */
1589 /* GC_linux_register_stack_base based on the following */
1590 /* constants: */
1591 # define BACKING_STORE_ALIGNMENT 0x100000
1592 # define BACKING_STORE_DISPLACEMENT 0x80000000
1593 extern char * GC_register_stackbottom;
1594 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1595 # define SEARCH_FOR_DATA_START
1596 # ifdef __GNUC__
1597 # define DYNAMIC_LOADING
1598 # else
1599 /* In the Intel compiler environment, we seem to end up with */
1600 /* statically linked executables and an undefined reference */
1601 /* to _DYNAMIC */
1602 # endif
1603 # define MPROTECT_VDB
1604 /* Requires Linux 2.3.47 or later. */
1605 extern int _end[];
1606 # define DATAEND (_end)
1607 # ifdef __GNUC__
1608 # define PREFETCH(x) \
1609 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1610 # define PREFETCH_FOR_WRITE(x) \
1611 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1612 # define CLEAR_DOUBLE(x) \
1613 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1614 # endif
1615 # endif
1616 # endif
1618 # ifdef M88K
1619 # define MACH_TYPE "M88K"
1620 # define ALIGNMENT 4
1621 # define ALIGN_DOUBLE
1622 extern int etext[];
1623 # ifdef CX_UX
1624 # define OS_TYPE "CX_UX"
1625 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1626 # endif
1627 # ifdef DGUX
1628 # define OS_TYPE "DGUX"
1629 extern ptr_t GC_SysVGetDataStart();
1630 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1631 # endif
1632 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1633 # endif
1635 # ifdef S370
1636 /* If this still works, and if anyone cares, this should probably */
1637 /* be moved to the S390 category. */
1638 # define MACH_TYPE "S370"
1639 # define ALIGNMENT 4 /* Required by hardware */
1640 # define USE_GENERIC_PUSH_REGS
1641 # ifdef UTS4
1642 # define OS_TYPE "UTS4"
1643 extern int etext[];
1644 extern int _etext[];
1645 extern int _end[];
1646 extern ptr_t GC_SysVGetDataStart();
1647 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1648 # define DATAEND (_end)
1649 # define HEURISTIC2
1650 # endif
1651 # endif
1653 # ifdef S390
1654 # define MACH_TYPE "S390"
1655 # define USE_GENERIC_PUSH_REGS
1656 # ifndef __s390x__
1657 # define ALIGNMENT 4
1658 # define CPP_WORDSZ 32
1659 # else
1660 # define ALIGNMENT 8
1661 # define CPP_WORDSZ 64
1662 # define HBLKSIZE 4096
1663 # endif
1664 # ifdef LINUX
1665 # define OS_TYPE "LINUX"
1666 # define LINUX_STACKBOTTOM
1667 # define DYNAMIC_LOADING
1668 extern int __data_start[];
1669 # define DATASTART ((ptr_t)(__data_start))
1670 extern int _end[];
1671 # define DATAEND (_end)
1672 # define CACHE_LINE_SIZE 256
1673 # define GETPAGESIZE() 4096
1674 # endif
1675 # endif
1677 # if defined(PJ)
1678 # define ALIGNMENT 4
1679 extern int _etext[];
1680 # define DATASTART ((ptr_t)(_etext))
1681 # define HEURISTIC1
1682 # endif
1684 # ifdef ARM32
1685 # define CPP_WORDSZ 32
1686 # define MACH_TYPE "ARM32"
1687 # define ALIGNMENT 4
1688 # ifdef NETBSD
1689 # define OS_TYPE "NETBSD"
1690 # define HEURISTIC2
1691 # ifdef __ELF__
1692 # define DATASTART GC_data_start
1693 # define DYNAMIC_LOADING
1694 # else
1695 extern char etext[];
1696 # define DATASTART ((ptr_t)(etext))
1697 # endif
1698 # define USE_GENERIC_PUSH_REGS
1699 # endif
1700 # ifdef LINUX
1701 # define OS_TYPE "LINUX"
1702 # define HEURISTIC1
1703 # undef STACK_GRAN
1704 # define STACK_GRAN 0x10000000
1705 # define USE_GENERIC_PUSH_REGS
1706 # ifdef __ELF__
1707 # define DYNAMIC_LOADING
1708 # include <features.h>
1709 # if defined(__GLIBC__) && __GLIBC__ >= 2
1710 # define SEARCH_FOR_DATA_START
1711 # else
1712 extern char **__environ;
1713 # define DATASTART ((ptr_t)(&__environ))
1714 /* hideous kludge: __environ is the first */
1715 /* word in crt0.o, and delimits the start */
1716 /* of the data segment, no matter which */
1717 /* ld options were passed through. */
1718 /* We could use _etext instead, but that */
1719 /* would include .rodata, which may */
1720 /* contain large read-only data tables */
1721 /* that we'd rather not scan. */
1722 # endif
1723 extern int _end[];
1724 # define DATAEND (_end)
1725 # else
1726 extern int etext[];
1727 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1728 # endif
1729 # endif
1730 # ifdef MSWINCE
1731 # define OS_TYPE "MSWINCE"
1732 # define DATAEND /* not needed */
1733 # endif
1734 # ifdef NOSYS
1735 /* __data_start is usually defined in the target linker script. */
1736 extern int __data_start[];
1737 # define DATASTART (ptr_t)(__data_start)
1738 # define USE_GENERIC_PUSH_REGS
1739 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1740 extern void *__stack_base__;
1741 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1742 # endif
1743 #endif
1745 # ifdef SH
1746 # define MACH_TYPE "SH"
1747 # define ALIGNMENT 4
1748 # ifdef MSWINCE
1749 # define OS_TYPE "MSWINCE"
1750 # define DATAEND /* not needed */
1751 # endif
1752 # ifdef LINUX
1753 # define OS_TYPE "LINUX"
1754 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1755 # define USE_GENERIC_PUSH_REGS
1756 # define DYNAMIC_LOADING
1757 # define SEARCH_FOR_DATA_START
1758 extern int _end[];
1759 # define DATAEND (_end)
1760 # endif
1761 # endif
1763 # ifdef SH4
1764 # define MACH_TYPE "SH4"
1765 # define OS_TYPE "MSWINCE"
1766 # define ALIGNMENT 4
1767 # define DATAEND /* not needed */
1768 # endif
1770 # ifdef X86_64
1771 # define MACH_TYPE "X86_64"
1772 # define ALIGNMENT 8
1773 # define CPP_WORDSZ 64
1774 # ifndef HBLKSIZE
1775 # define HBLKSIZE 4096
1776 # endif
1777 # define CACHE_LINE_SIZE 64
1778 # define USE_GENERIC_PUSH_REGS
1779 # ifdef LINUX
1780 # define OS_TYPE "LINUX"
1781 # define LINUX_STACKBOTTOM
1782 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1783 # define MPROTECT_VDB
1784 # else
1785 /* We seem to get random errors in incremental mode, */
1786 /* possibly because Linux threads is itself a malloc client */
1787 /* and can't deal with the signals. */
1788 # endif
1789 # ifdef __ELF__
1790 # define DYNAMIC_LOADING
1791 # ifdef UNDEFINED /* includes ro data */
1792 extern int _etext[];
1793 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1794 # endif
1795 # include <features.h>
1796 # define SEARCH_FOR_DATA_START
1797 extern int _end[];
1798 # define DATAEND (_end)
1799 # else
1800 extern int etext[];
1801 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1802 # endif
1803 # define PREFETCH(x) \
1804 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1805 # define PREFETCH_FOR_WRITE(x) \
1806 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1807 # endif
1808 # endif
1810 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1811 /* Rld appears to allocate some memory with its own allocator, and */
1812 /* some through malloc, which might be redirected. To make this */
1813 /* work with collectable memory, we have to scan memory allocated */
1814 /* by rld's internal malloc. */
1815 # define USE_PROC_FOR_LIBRARIES
1816 #endif
1818 # ifndef STACK_GROWS_UP
1819 # define STACK_GROWS_DOWN
1820 # endif
1822 # ifndef CPP_WORDSZ
1823 # define CPP_WORDSZ 32
1824 # endif
1826 # ifndef OS_TYPE
1827 # define OS_TYPE ""
1828 # endif
1830 # ifndef DATAEND
1831 extern int end[];
1832 # define DATAEND (end)
1833 # endif
1835 # if defined(SVR4) && !defined(GETPAGESIZE)
1836 # include <unistd.h>
1837 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1838 # endif
1840 # ifndef GETPAGESIZE
1841 # if defined(SUNOS5) || defined(IRIX5)
1842 # include <unistd.h>
1843 # endif
1844 # define GETPAGESIZE() getpagesize()
1845 # endif
1847 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1848 /* OS has SVR4 generic features. Probably others also qualify. */
1849 # define SVR4
1850 # endif
1852 # if defined(SUNOS5) || defined(DRSNX)
1853 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1854 /* loader. */
1855 # define SUNOS5DL
1856 /* OS has SUNOS5 style signal handlers. */
1857 # define SUNOS5SIGS
1858 # endif
1860 # if defined(HPUX)
1861 # define SUNOS5SIGS
1862 # endif
1864 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1865 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1866 || defined(DGUX) || defined(BSD) \
1867 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
1868 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1869 # endif
1871 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1872 -> bad word size
1873 # endif
1875 # ifdef PCR
1876 # undef DYNAMIC_LOADING
1877 # undef STACKBOTTOM
1878 # undef HEURISTIC1
1879 # undef HEURISTIC2
1880 # undef PROC_VDB
1881 # undef MPROTECT_VDB
1882 # define PCR_VDB
1883 # endif
1885 # ifdef SRC_M3
1886 /* Postponed for now. */
1887 # undef PROC_VDB
1888 # undef MPROTECT_VDB
1889 # endif
1891 # ifdef SMALL_CONFIG
1892 /* Presumably not worth the space it takes. */
1893 # undef PROC_VDB
1894 # undef MPROTECT_VDB
1895 # endif
1897 # ifdef USE_MUNMAP
1898 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1899 # endif
1901 # ifdef PARALLEL_MARK
1902 # undef MPROTECT_VDB /* For now. */
1903 # endif
1905 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1906 # define DEFAULT_VDB
1907 # endif
1909 # ifndef PREFETCH
1910 # define PREFETCH(x)
1911 # define NO_PREFETCH
1912 # endif
1914 # ifndef PREFETCH_FOR_WRITE
1915 # define PREFETCH_FOR_WRITE(x)
1916 # define NO_PREFETCH_FOR_WRITE
1917 # endif
1919 # ifndef CACHE_LINE_SIZE
1920 # define CACHE_LINE_SIZE 32 /* Wild guess */
1921 # endif
1923 # ifdef LINUX
1924 # define REGISTER_LIBRARIES_EARLY
1925 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
1926 /* lock. This isn't safe after the world has stopped. So we must */
1927 /* call GC_register_dynamic_libraries before stopping the world. */
1928 /* For performance reasons, this may be beneficial on other */
1929 /* platforms as well, though it should be avoided in win32. */
1930 # endif /* LINUX */
1932 # if defined(SEARCH_FOR_DATA_START)
1933 extern ptr_t GC_data_start;
1934 # define DATASTART GC_data_start
1935 # endif
1937 # ifndef CLEAR_DOUBLE
1938 # define CLEAR_DOUBLE(x) \
1939 ((word*)x)[0] = 0; \
1940 ((word*)x)[1] = 0;
1941 # endif /* CLEAR_DOUBLE */
1943 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1944 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1945 # define GC_SOLARIS_THREADS
1946 # endif
1948 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1949 --> inconsistent configuration
1950 # endif
1951 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1952 --> inconsistent configuration
1953 # endif
1954 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1955 --> inconsistent configuration
1956 # endif
1957 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1958 --> inconsistent configuration
1959 # endif
1960 # if defined(GC_AIX_THREADS) && !defined(_AIX)
1961 --> inconsistent configuration
1962 # endif
1963 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
1964 --> inconsistent configuration
1965 # endif
1967 # if defined(PCR) || defined(SRC_M3) || \
1968 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1969 defined(GC_PTHREADS)
1970 # define THREADS
1971 # endif
1973 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(DARWIN) \
1974 || defined(LINT) || defined(MSWINCE) || defined(ARM32) \
1975 || (defined(I386) && defined(__LCC__))
1976 /* Use setjmp based hack to mark from callee-save registers. */
1977 /* The define should move to the individual platform */
1978 /* descriptions. */
1979 # define USE_GENERIC_PUSH_REGS
1980 # endif
1982 # if defined(SPARC)
1983 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1984 /* include assembly code to do it well. */
1985 # endif
1987 /* Can we save call chain in objects for debugging? */
1988 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
1989 /* frame) to reasonable values for the platform. */
1990 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
1991 /* at build time, though we feel free to adjust it slightly. */
1992 /* Define NEED_CALLINFO if we either save the call stack or */
1993 /* GC_ADD_CALLER is defined. */
1994 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
1996 #if defined(SPARC)
1997 # define CAN_SAVE_CALL_ARGS
1998 #endif
1999 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
2000 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2001 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2002 # define CAN_SAVE_CALL_ARGS
2003 #endif
2005 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2006 && defined(GC_CAN_SAVE_CALL_STACKS)
2007 # define SAVE_CALL_CHAIN
2008 # endif
2009 # ifdef SAVE_CALL_CHAIN
2010 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2011 # define NARGS SAVE_CALL_NARGS
2012 # else
2013 # define NARGS 0 /* Number of arguments to save for each call. */
2014 # endif
2015 # endif
2016 # ifdef SAVE_CALL_CHAIN
2017 # ifndef SAVE_CALL_COUNT
2018 # define NFRAMES 6 /* Number of frames to save. Even for */
2019 /* alignment reasons. */
2020 # else
2021 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2022 # endif
2023 # define NEED_CALLINFO
2024 # endif /* SAVE_CALL_CHAIN */
2025 # ifdef GC_ADD_CALLER
2026 # define NFRAMES 1
2027 # define NARGS 0
2028 # define NEED_CALLINFO
2029 # endif
2031 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2032 # define DBG_HDRS_ALL
2033 # endif
2035 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2036 # define POINTER_SHIFT 0
2037 # endif
2039 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2040 # define POINTER_MASK ((GC_word)(-1))
2041 # endif
2043 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2044 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2045 # endif
2047 # if defined(FIXUP_POINTER)
2048 # define NEED_FIXUP_POINTER 1
2049 # else
2050 # define NEED_FIXUP_POINTER 0
2051 # define FIXUP_POINTER(p)
2052 # endif
2054 #ifdef GC_PRIVATE_H
2055 /* This relies on some type definitions from gc_priv.h, from */
2056 /* where it's normally included. */
2057 /* */
2058 /* How to get heap memory from the OS: */
2059 /* Note that sbrk()-like allocation is preferred, since it */
2060 /* usually makes it possible to merge consecutively allocated */
2061 /* chunks. It also avoids unintented recursion with */
2062 /* -DREDIRECT_MALLOC. */
2063 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2064 /* 0 is taken to mean failure. */
2065 /* In the case os USE_MMAP, the argument must also be a */
2066 /* physical page size. */
2067 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2068 /* though we should perhaps take advantage of the case in which */
2069 /* does. */
2070 struct hblk; /* See gc_priv.h. */
2071 # ifdef PCR
2072 char * real_malloc();
2073 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2074 + GC_page_size-1)
2075 # else
2076 # ifdef OS2
2077 void * os2_alloc(size_t bytes);
2078 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2079 + GC_page_size) \
2080 + GC_page_size-1)
2081 # else
2082 # if defined(NEXT) || defined(DOS4GW) || \
2083 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2084 (defined(SUNOS5) && !defined(USE_MMAP))
2085 # define GET_MEM(bytes) HBLKPTR((size_t) \
2086 calloc(1, (size_t)bytes + GC_page_size) \
2087 + GC_page_size-1)
2088 # else
2089 # ifdef MSWIN32
2090 extern ptr_t GC_win32_get_mem();
2091 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2092 # else
2093 # ifdef MACOS
2094 # if defined(USE_TEMPORARY_MEMORY)
2095 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2096 Boolean clearMemory);
2097 # define GET_MEM(bytes) HBLKPTR( \
2098 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2099 + GC_page_size-1)
2100 # else
2101 # define GET_MEM(bytes) HBLKPTR( \
2102 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2103 # endif
2104 # else
2105 # ifdef MSWINCE
2106 extern ptr_t GC_wince_get_mem();
2107 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2108 # else
2109 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2110 extern void *GC_amiga_get_mem(size_t size);
2111 # define GET_MEM(bytes) HBLKPTR((size_t) \
2112 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2113 + GC_page_size-1)
2114 # else
2115 extern ptr_t GC_unix_get_mem();
2116 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2117 # endif
2118 # endif
2119 # endif
2120 # endif
2121 # endif
2122 # endif
2123 # endif
2125 #endif /* GC_PRIVATE_H */
2127 # endif /* GCCONFIG_H */