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.
21 /* Machine dependent parameters. Some tuning parameters can be found */
22 /* near the top of gc_private.h. */
24 /* Machine specific parts contributed by various people. See README file. */
26 /* First a unified test for Linux: */
27 # if defined(linux) || defined(__linux__)
31 /* And one for NetBSD: */
32 # if defined(__NetBSD__)
36 /* And one for OpenBSD: */
37 # if defined(__OpenBSD__)
41 /* And one for FreeBSD: */
42 # if defined(__FreeBSD__)
46 /* Determine the machine type: */
47 # if defined(__arm__) || defined(__thumb__)
49 # if !defined(LINUX) && !defined(NETBSD)
51 # define mach_type_known
54 # if defined(sun) && defined(mc68000)
57 # define mach_type_known
59 # if defined(hp9000s300)
62 # define mach_type_known
64 # if defined(OPENBSD) && defined(m68k)
66 # define mach_type_known
68 # if defined(OPENBSD) && defined(__sparc__)
70 # define mach_type_known
72 # if defined(NETBSD) && defined(m68k)
74 # define mach_type_known
76 # if defined(NETBSD) && defined(__powerpc__)
78 # define mach_type_known
80 # if defined(NETBSD) && defined(__arm__)
82 # define mach_type_known
91 # define mach_type_known
93 # if defined(mips) || defined(__mips) || defined(_mips)
95 # if defined(nec_ews) || defined(_nec_ews)
98 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
99 # if defined(ultrix) || defined(__ultrix)
102 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
103 || defined(__SYSTYPE_SVR4__)
104 # define IRIX5 /* or IRIX 6.X */
106 # define RISCOS /* or IRIX 4.X */
110 # define mach_type_known
112 # if defined(sequent) && (defined(i386) || defined(__i386__))
115 # define mach_type_known
117 # if defined(sun) && (defined(i386) || defined(__i386__))
120 # define mach_type_known
122 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
125 # define mach_type_known
129 # define mach_type_known
131 # if defined(sun) && (defined(sparc) || defined(__sparc))
133 /* Test for SunOS 5.x */
140 # define mach_type_known
142 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
143 && !defined(__OpenBSD__) && !(__NetBSD__)
146 # define mach_type_known
150 # define mach_type_known
152 # if defined(__NetBSD__) && defined(__sparc__)
154 # define mach_type_known
156 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
157 /* The above test may need refinement */
159 # if defined(_SCO_ELF)
164 # define mach_type_known
166 # if defined(_AUX_SOURCE)
169 # define mach_type_known
171 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
172 || defined(hppa) || defined(__hppa__)
177 # define mach_type_known
179 # if defined(__ia64) && defined(_HPUX_SOURCE)
182 # define mach_type_known
184 # if defined(__BEOS__) && defined(_X86_)
187 # define mach_type_known
189 # if defined(LINUX) && (defined(i386) || defined(__i386__))
191 # define mach_type_known
193 # if defined(LINUX) && defined(__x86_64__)
195 # define mach_type_known
197 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
199 # define mach_type_known
201 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
203 # define mach_type_known
205 # if defined(LINUX) && defined(__mc68000__)
207 # define mach_type_known
209 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
211 # define mach_type_known
213 # if defined(LINUX) && defined(__arm__)
215 # define mach_type_known
217 # if defined(LINUX) && defined(__sh__)
219 # define mach_type_known
221 # if defined(__alpha) || defined(__alpha__)
223 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
224 # define OSF1 /* a.k.a Digital Unix */
226 # define mach_type_known
228 # if defined(_AMIGA) && !defined(AMIGA)
233 # define mach_type_known
235 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
238 # define mach_type_known
240 # if defined(__MWERKS__) && defined(__powerc)
243 # define mach_type_known
245 # if defined(macosx) || \
246 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
249 # define mach_type_known
251 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
254 --> Not really supported, but at least we recognize it.
256 # if defined(NeXT) && defined(mc68000)
259 # define mach_type_known
261 # if defined(NeXT) && (defined(i386) || defined(__i386__))
264 # define mach_type_known
266 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
269 # define mach_type_known
271 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
273 # define mach_type_known
275 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
277 # define mach_type_known
279 # if defined(bsdi) && (defined(i386) || defined(__i386__))
282 # define mach_type_known
284 # if !defined(mach_type_known) && defined(__386BSD__)
287 # define mach_type_known
289 # if defined(_CX_UX) && defined(_M88K)
292 # define mach_type_known
297 # define mach_type_known
299 # if defined(_WIN32_WCE)
300 /* SH3, SH4, MIPS already defined for corresponding architectures */
301 # if defined(SH3) || defined(SH4)
311 # define mach_type_known
313 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
314 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
316 # define MSWIN32 /* or Win32s */
317 # define mach_type_known
320 # if defined(__DJGPP__)
323 # define DJGPP /* MSDOS running the DJGPP port of GCC */
325 # define mach_type_known
327 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
330 # define mach_type_known
332 # if defined(__MINGW32__)
335 # define mach_type_known
337 # if defined(__BORLANDC__)
340 # define mach_type_known
342 # if defined(_UTS) && !defined(mach_type_known)
345 # define mach_type_known
349 # define mach_type_known
351 # if defined(__embedded__) && defined(PPC)
354 # define mach_type_known
357 # if defined(__WATCOMC__) && defined(__386__)
359 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
360 # if defined(__OS2__)
363 # if defined(__WINDOWS_386__) || defined(__NT__)
370 # define mach_type_known
372 # if defined(__s390__) && defined(LINUX)
374 # define mach_type_known
376 # if defined(__GNU__)
377 # if defined(__i386__)
378 /* The Debian Hurd running on generic PC */
381 # define mach_type_known
385 /* Feel free to add more clauses here */
387 /* Or manually define the machine type here. A machine type is */
388 /* characterized by the architecture. Some */
389 /* machine types are further subdivided by OS. */
390 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
391 /* Note that SGI IRIX is treated identically to RISCOS. */
392 /* SYSV on an M68K actually means A/UX. */
393 /* The distinction in these cases is usually the stack starting address */
394 # ifndef mach_type_known
395 --> unknown machine type
397 /* Mapping is: M68K ==> Motorola 680X0 */
398 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
399 /* MACOS and AMIGA variants) */
400 /* I386 ==> Intel 386 */
401 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
402 /* FREEBSD, THREE86BSD, MSWIN32, */
403 /* BSDI,SUNOS5, NEXT, other variants) */
404 /* NS32K ==> Encore Multimax */
405 /* MIPS ==> R2000 or R3000 */
406 /* (RISCOS, ULTRIX variants) */
407 /* VAX ==> DEC VAX */
408 /* (BSD, ULTRIX variants) */
409 /* RS6000 ==> IBM RS/6000 AIX3.X */
410 /* RT ==> IBM PC/RT */
411 /* HP_PA ==> HP9000/700 & /800 */
413 /* SPARC ==> SPARC v7/v8/v9 */
414 /* (SUNOS4, SUNOS5, LINUX, */
415 /* DRSNX variants) */
416 /* ALPHA ==> DEC Alpha */
417 /* (OSF1 and LINUX variants) */
418 /* M88K ==> Motorola 88XX0 */
419 /* (CX_UX and DGUX) */
420 /* S370 ==> 370-like machine */
421 /* running Amdahl UTS4 */
422 /* S390 ==> 390-like machine */
424 /* ARM32 ==> Intel StrongARM */
425 /* IA64 ==> Intel IPF */
427 /* (LINUX and HPUX) */
428 /* IA64_32 ==> IA64 w/32 bit ABI */
430 /* SH ==> Hitachi SuperH */
431 /* (LINUX & MSWINCE) */
432 /* X86_64 ==> AMD x86-64 */
436 * For each architecture and OS, the following need to be defined:
438 * CPP_WORD_SZ is a simple integer constant representing the word size.
439 * in bits. We assume byte addressibility, where a byte has 8 bits.
440 * We also assume CPP_WORD_SZ is either 32 or 64.
441 * (We care about the length of pointers, not hardware
442 * bus widths. Thus a 64 bit processor with a C compiler that uses
443 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
445 * MACH_TYPE is a string representation of the machine type.
446 * OS_TYPE is analogous for the OS.
448 * ALIGNMENT is the largest N, such that
449 * all pointer are guaranteed to be aligned on N byte boundaries.
450 * defining it to be 1 will always work, but perform poorly.
452 * DATASTART is the beginning of the data segment.
453 * On UNIX systems, the collector will scan the area between DATASTART
454 * and DATAEND for root pointers.
456 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
457 * RTH suggests gaining access to linker script synth'd values with
458 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
459 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
460 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
461 * without any special options.
463 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
466 * STACKBOTTOM is the cool end of the stack, which is usually the
467 * highest address in the stack.
468 * Under PCR or OS/2, we have other ways of finding thread stacks.
469 * For each machine, the following should:
470 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
471 * 2) define exactly one of
472 * STACKBOTTOM (should be defined to be an expression)
475 * If either of the last two macros are defined, then STACKBOTTOM is computed
476 * during collector startup using one of the following two heuristics:
477 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
478 * the next multiple of STACK_GRAN.
479 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
480 * in small steps (decrement if STACK_GROWS_UP), and read the value
481 * at each location. Remember the value when the first
482 * Segmentation violation or Bus error is signalled. Round that
483 * to the nearest plausible page boundary, and use that instead
486 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
487 * the value of environ is a pointer that can serve as STACKBOTTOM.
488 * I expect that HEURISTIC2 can be replaced by this approach, which
489 * interferes far less with debugging. However it has the disadvantage
490 * that it's confused by a putenv call before the collector is initialized.
491 * This could be dealt with by intercepting putenv ...
493 * If no expression for STACKBOTTOM can be found, and neither of the above
494 * heuristics are usable, the collector can still be used with all of the above
495 * undefined, provided one of the following is done:
496 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
497 * without reference to STACKBOTTOM. This is appropriate for use in
498 * conjunction with thread packages, since there will be multiple stacks.
499 * (Allocating thread stacks in the heap, and treating them as ordinary
500 * heap data objects is also possible as a last resort. However, this is
501 * likely to introduce significant amounts of excess storage retention
502 * unless the dead parts of the thread stacks are periodically cleared.)
503 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
504 * If the author of the client code controls the main program, this is
505 * easily accomplished by introducing a new main program, setting
506 * GC_stackbottom to the address of a local variable, and then calling
507 * the original main program. The new main program would read something
510 * # include "gc_private.h"
512 * main(argc, argv, envp)
514 * char **argv, **envp;
518 * GC_stackbottom = (ptr_t)(&dummy);
519 * return(real_main(argc, argv, envp));
523 * Each architecture may also define the style of virtual dirty bit
524 * implementation to be used:
525 * MPROTECT_VDB: Write protect the heap and catch faults.
526 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
528 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
529 * defined GC_register_dynamic_libraries() for the architecture.
531 * An architecture may define PREFETCH(x) to preload the cache with *x.
532 * This defaults to a no-op.
534 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
536 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
537 * clear the two words at GC_malloc-aligned address x. By default,
538 * word stores of 0 are used instead.
541 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
542 * to push the relevant registers onto the stack. This generally makes
543 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
545 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
546 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
547 # define HAVE_BUILTIN_UNWIND_INIT
550 # define STACK_GRAN 0x1000000
552 # define MACH_TYPE "M68K"
555 # define OS_TYPE "OPENBSD"
558 # define DATASTART ((ptr_t)(etext))
561 # define OS_TYPE "NETBSD"
564 # define DATASTART ((ptr_t)(etext))
567 # define OS_TYPE "LINUX"
568 # define STACKBOTTOM ((ptr_t)0xf0000000)
569 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
571 # define DYNAMIC_LOADING
572 # include <features.h>
573 # if defined(__GLIBC__)&& __GLIBC__>=2
574 # define LINUX_DATA_START
576 extern char **__environ;
577 # define DATASTART ((ptr_t)(&__environ))
578 /* hideous kludge: __environ is the first */
579 /* word in crt0.o, and delimits the start */
580 /* of the data segment, no matter which */
581 /* ld options were passed through. */
582 /* We could use _etext instead, but that */
583 /* would include .rodata, which may */
584 /* contain large read-only data tables */
585 /* that we'd rather not scan. */
586 # endif /* !GLIBC2 */
588 # define DATAEND (_end)
591 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
595 # define OS_TYPE "SUNOS4"
597 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
598 # define HEURISTIC1 /* differs */
599 # define DYNAMIC_LOADING
602 # define OS_TYPE "HP"
604 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
605 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
606 /* empirically determined. seems to work. */
608 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
611 # define OS_TYPE "SYSV"
613 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
615 +((word)etext & 0x1fff))
616 /* This only works for shared-text binaries with magic number 0413.
617 The other sorts of SysV binaries put the data at the end of the text,
618 in which case the default of etext would work. Unfortunately,
619 handling both would require having the magic-number available.
622 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
623 /* The stack starts at the top of memory, but */
624 /* 0x0 cannot be used as setjump_test complains */
625 /* that the stack direction is incorrect. Two */
626 /* bytes down from 0x0 should be safe enough. */
628 # include <sys/mmu.h>
629 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
632 # define OS_TYPE "AMIGA"
633 /* STACKBOTTOM and DATASTART handled specially */
635 # define DATAEND /* not needed */
636 # define GETPAGESIZE() 4096
642 # define OS_TYPE "MACOS"
643 /* see os_dep.c for details of global data segments. */
644 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
645 # define DATAEND /* not needed */
646 # define GETPAGESIZE() 4096
649 # define OS_TYPE "NEXT"
650 # define DATASTART ((ptr_t) get_etext())
651 # define STACKBOTTOM ((ptr_t) 0x4000000)
652 # define DATAEND /* not needed */
657 # define MACH_TYPE "POWERPC"
659 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
663 # define OS_TYPE "MACOS"
664 /* see os_dep.c for details of global data segments. */
665 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
666 # define DATAEND /* not needed */
669 # define ALIGNMENT 4 /* Guess. Can someone verify? */
670 /* This was 2, but that didn't sound right. */
671 # define OS_TYPE "LINUX"
672 # define DYNAMIC_LOADING
673 # define LINUX_STACKBOTTOM
674 /* Stack usually starts at 0x80000000 */
675 # define LINUX_DATA_START
677 # define DATAEND (_end)
680 /* There are reasons to suspect this may not be reliable. */
682 # define OS_TYPE "MACOSX"
683 # define DATASTART ((ptr_t) get_etext())
684 # define STACKBOTTOM ((ptr_t) 0xc0000000)
685 # define DATAEND /* not needed */
688 # define GETPAGESIZE() getpagesize()
692 # define OS_TYPE "NETBSD"
695 # define DATASTART GC_data_start
696 # define DYNAMIC_LOADING
700 # define OS_TYPE "NOSYS"
701 extern void __end[], __dso_handle[];
702 # define DATASTART (__dso_handle) /* OK, that's ugly. */
703 # define DATAEND (__end)
704 /* Stack starts at 0xE0000000 for the simulator. */
706 # define STACK_GRAN 0x10000000
712 # define MACH_TYPE "VAX"
713 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
715 # define DATASTART ((ptr_t)(etext))
717 # define OS_TYPE "BSD"
719 /* HEURISTIC2 may be OK, but it's hard to test. */
722 # define OS_TYPE "ULTRIX"
723 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
728 # define MACH_TYPE "RT"
730 # define DATASTART ((ptr_t) 0x10000000)
731 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
735 # define MACH_TYPE "SPARC"
736 # if defined(__arch64__) || defined(__sparcv9)
738 # define CPP_WORDSZ 64
739 # define ELF_CLASS ELFCLASS64
741 # define ALIGNMENT 4 /* Required by hardware */
742 # define CPP_WORDSZ 32
744 # define ALIGN_DOUBLE
746 # define OS_TYPE "SUNOS5"
749 extern char * GC_SysVGetDataStart();
750 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
751 # define DATAEND (_end)
752 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
754 /* Otherwise we now use calloc. Mmap may result in the */
755 /* heap interleaved with thread stacks, which can result in */
756 /* excessive blacklisting. Sbrk is unusable since it */
757 /* doesn't interact correctly with the system malloc. */
760 # define HEAP_START (ptr_t)0x40000000
762 # define HEAP_START DATAEND
765 /* HEURISTIC1 reportedly no longer works under 2.7. */
766 /* HEURISTIC2 probably works, but this appears to be preferable. */
767 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
768 /* installations that's undefined. We work around this with a */
770 # include <sys/vmparam.h>
772 /* This should work everywhere, but doesn't. */
773 # define STACKBOTTOM USRSTACK
778 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
779 /* getpagesize() appeared to be missing from at least one */
780 /* Solaris 5.4 installation. Weird. */
781 # define DYNAMIC_LOADING
784 # define OS_TYPE "SUNOS4"
785 /* [If you have a weak stomach, don't read this.] */
786 /* We would like to use: */
787 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
788 /* This fails occasionally, due to an ancient, but very */
789 /* persistent ld bug. etext is set 32 bytes too high. */
790 /* We instead read the text segment size from the a.out */
791 /* header, which happens to be mapped into our address space */
792 /* at the start of the text segment. The detective work here */
793 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
794 /* Serpette of INRIA. */
795 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
796 # define TEXTSTART 0x2000
797 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
798 # define MPROTECT_VDB
800 # define DYNAMIC_LOADING
803 # define OS_TYPE "DRSNX"
804 extern char * GC_SysVGetDataStart();
806 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
807 # define MPROTECT_VDB
808 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
809 # define DYNAMIC_LOADING
812 # define OS_TYPE "LINUX"
814 # define DYNAMIC_LOADING
816 Linux Sparc/a.out not supported
820 # define DATAEND (_end)
823 /* libc_stack_end is not set reliably for sparc64 */
824 # define STACKBOTTOM ((ptr_t) 0x80000000000)
825 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
827 # define LINUX_STACKBOTTOM
828 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
832 # define OS_TYPE "OPENBSD"
833 # define STACKBOTTOM ((ptr_t) 0xf8000000)
835 # define DATASTART ((ptr_t)(etext))
838 # define OS_TYPE "NETBSD"
841 # define DATASTART GC_data_start
842 # define DYNAMIC_LOADING
845 # define DATASTART ((ptr_t)(etext))
851 # define MACH_TYPE "I386"
852 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
853 /* except Borland. The -a4 option fixes */
855 /* Ivan Demakov: For Watcom the option is -zp4. */
856 # ifndef SMALL_CONFIG
857 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
858 /* improvement on Pentiums. */
860 # ifdef HAVE_BUILTIN_UNWIND_INIT
861 # define USE_GENERIC_PUSH_REGS
864 # define OS_TYPE "SEQUENT"
866 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
867 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
870 # define OS_TYPE "BEOS"
872 # define GETPAGESIZE() B_PAGE_SIZE
874 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
877 # define OS_TYPE "SUNOS5"
878 extern int _etext[], _end[];
879 extern char * GC_SysVGetDataStart();
880 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
881 # define DATAEND (_end)
882 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
883 /* but reportedly breaks under 2.8. It appears that the stack */
884 /* base is a property of the executable, so this should not break */
885 /* old executables. */
886 /* HEURISTIC2 probably works, but this appears to be preferable. */
888 # define STACKBOTTOM USRSTACK
889 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
890 /* It appears to be fixed in 2.8 and 2.9. */
891 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
894 # define DYNAMIC_LOADING
895 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
897 /* Otherwise we now use calloc. Mmap may result in the */
898 /* heap interleaved with thread stacks, which can result in */
899 /* excessive blacklisting. Sbrk is unusable since it */
900 /* doesn't interact correctly with the system malloc. */
903 # define HEAP_START (ptr_t)0x40000000
905 # define HEAP_START DATAEND
909 # define OS_TYPE "SCO"
911 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
913 +((word)etext & 0xfff))
914 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
917 # define OS_TYPE "SCO_ELF"
919 # define DATASTART ((ptr_t)(etext))
920 # define STACKBOTTOM ((ptr_t) 0x08048000)
921 # define DYNAMIC_LOADING
922 # define ELF_CLASS ELFCLASS32
926 /* The Intel compiler doesn't like inline assembly */
927 # define USE_GENERIC_PUSH_REGS
929 # define OS_TYPE "LINUX"
930 # define LINUX_STACKBOTTOM
934 # define STACK_GRAN 0x10000000
935 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
936 /* different kernel configurations. In particular, systems */
937 /* with 2GB physical memory will usually move the user */
938 /* address space limit, and hence initial SP to 0x80000000. */
940 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
941 # define MPROTECT_VDB
943 /* We seem to get random errors in incremental mode, */
944 /* possibly because Linux threads is itself a malloc client */
945 /* and can't deal with the signals. */
948 # define DYNAMIC_LOADING
949 # ifdef UNDEFINED /* includes ro data */
951 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
953 # include <features.h>
954 # if defined(__GLIBC__) && __GLIBC__ >= 2
955 # define LINUX_DATA_START
957 extern char **__environ;
958 # define DATASTART ((ptr_t)(&__environ))
959 /* hideous kludge: __environ is the first */
960 /* word in crt0.o, and delimits the start */
961 /* of the data segment, no matter which */
962 /* ld options were passed through. */
963 /* We could use _etext instead, but that */
964 /* would include .rodata, which may */
965 /* contain large read-only data tables */
966 /* that we'd rather not scan. */
969 # define DATAEND (_end)
972 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
974 # ifdef USE_I686_PREFETCH
975 # define PREFETCH(x) \
976 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
977 /* Empirically prefetcht0 is much more effective at reducing */
978 /* cache miss stalls for the targetted load instructions. But it */
979 /* seems to interfere enough with other cache traffic that the net */
980 /* result is worse than prefetchnta. */
982 /* Using prefetches for write seems to have a slight negative */
983 /* impact on performance, at least for a PIII/500. */
984 # define PREFETCH_FOR_WRITE(x) \
985 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
988 # ifdef USE_3DNOW_PREFETCH
989 # define PREFETCH(x) \
990 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
991 # define PREFETCH_FOR_WRITE(x) \
992 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
996 # define OS_TYPE "CYGWIN32"
997 extern int _data_start__[];
998 extern int _data_end__[];
999 extern int _bss_start__[];
1000 extern int _bss_end__[];
1001 /* For binutils 2.9.1, we have */
1002 /* DATASTART = _data_start__ */
1003 /* DATAEND = _bss_end__ */
1004 /* whereas for some earlier versions it was */
1005 /* DATASTART = _bss_start__ */
1006 /* DATAEND = _data_end__ */
1007 /* To get it right for both, we take the */
1008 /* minumum/maximum of the two. */
1009 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1010 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1011 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1012 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1014 # define STACK_GRAN 0x10000
1018 # define OS_TYPE "OS2"
1019 /* STACKBOTTOM and DATASTART are handled specially in */
1020 /* os_dep.c. OS2 actually has the right */
1022 # define DATAEND /* not needed */
1023 # define USE_GENERIC_PUSH_REGS
1026 # define OS_TYPE "MSWIN32"
1027 /* STACKBOTTOM and DATASTART are handled specially in */
1029 # ifndef __WATCOMC__
1030 # define MPROTECT_VDB
1032 # define DATAEND /* not needed */
1035 # define OS_TYPE "MSWINCE"
1036 # define DATAEND /* not needed */
1039 # define OS_TYPE "DJGPP"
1040 # include "stubinfo.h"
1043 extern int __djgpp_stack_limit;
1044 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1045 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1047 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1048 /* This may not be right. */
1051 # define OS_TYPE "OPENBSD"
1054 # define OS_TYPE "FREEBSD"
1055 # ifndef GC_FREEBSD_THREADS
1056 # define MPROTECT_VDB
1058 # define SIG_SUSPEND SIGUSR1
1059 # define SIG_THR_RESTART SIGUSR2
1060 # define FREEBSD_STACKBOTTOM
1062 # define DYNAMIC_LOADING
1064 /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */
1065 extern char etext[];
1066 extern char edata[];
1068 # define NEED_FIND_LIMIT
1069 # define DATASTART ((ptr_t)(etext))
1070 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1071 # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2))
1072 # define DATASTART2 ((ptr_t)(edata))
1073 # define DATAEND2 ((ptr_t)(end))
1076 # define OS_TYPE "NETBSD"
1078 # define DYNAMIC_LOADING
1082 # define OS_TYPE "THREE86BSD"
1085 # define OS_TYPE "BSDI"
1087 # if defined(OPENBSD) || defined(NETBSD) \
1088 || defined(THREE86BSD) || defined(BSDI)
1090 extern char etext[];
1091 # define DATASTART ((ptr_t)(etext))
1094 # define OS_TYPE "NEXT"
1095 # define DATASTART ((ptr_t) get_etext())
1096 # define STACKBOTTOM ((ptr_t)0xc0000000)
1097 # define DATAEND /* not needed */
1100 # define OS_TYPE "DOS4GW"
1101 extern long __nullarea;
1103 extern char *_STACKTOP;
1104 /* Depending on calling conventions Watcom C either precedes
1105 or does not precedes with undescore names of C-variables.
1106 Make sure startup code variables always have the same names. */
1107 #pragma aux __nullarea "*";
1108 #pragma aux _end "*";
1109 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1110 /* confused? me too. */
1111 # define DATASTART ((ptr_t) &__nullarea)
1112 # define DATAEND ((ptr_t) &_end)
1115 # define OS_TYPE "HURD"
1116 # define STACK_GROWS_DOWN
1118 extern int __data_start[];
1119 # define DATASTART ( (ptr_t) (__data_start))
1121 # define DATAEND ( (ptr_t) (_end))
1122 /* # define MPROTECT_VDB Not quite working yet? */
1123 # define DYNAMIC_LOADING
1128 # define MACH_TYPE "NS32K"
1129 # define ALIGNMENT 4
1130 extern char **environ;
1131 # define DATASTART ((ptr_t)(&environ))
1132 /* hideous kludge: environ is the first */
1133 /* word in crt0.o, and delimits the start */
1134 /* of the data segment, no matter which */
1135 /* ld options were passed through. */
1136 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1140 # define MACH_TYPE "MIPS"
1142 /* This was developed for a linuxce style platform. Probably */
1143 /* needs to be tweaked for workstation class machines. */
1144 # define OS_TYPE "LINUX"
1145 # define DYNAMIC_LOADING
1147 # define DATAEND (_end)
1148 extern int __data_start[];
1149 # define DATASTART ((ptr_t)(__data_start))
1150 # define ALIGNMENT 4
1151 # define USE_GENERIC_PUSH_REGS
1152 # define LINUX_STACKBOTTOM
1156 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1157 extern int _fdata[], _end[];
1158 # define DATASTART ((ptr_t)_fdata)
1159 # define DATAEND ((ptr_t)_end)
1160 # define CPP_WORDSZ _MIPS_SZPTR
1161 # define ALIGNMENT (_MIPS_SZPTR/8)
1163 extern int etext[], edata[], end[];
1164 extern int _DYNAMIC_LINKING[], _gp[];
1165 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1166 + ((word)etext & 0xffff)))
1167 # define DATAEND (edata)
1168 # define DATASTART2 (_DYNAMIC_LINKING \
1169 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1171 # define DATAEND2 (end)
1172 # define ALIGNMENT 4
1174 # define OS_TYPE "EWS4800"
1175 # define USE_GENERIC_PUSH_REGS 1
1179 # define DATASTART (ptr_t)0x10000000
1180 /* Could probably be slightly higher since */
1181 /* startup code allocates lots of stuff. */
1182 # define OS_TYPE "ULTRIX"
1183 # define ALIGNMENT 4
1187 # define DATASTART (ptr_t)0x10000000
1188 # define OS_TYPE "RISCOS"
1189 # define ALIGNMENT 4 /* Required by hardware */
1193 extern int _fdata[];
1194 # define DATASTART ((ptr_t)(_fdata))
1196 # define HEAP_START (ptr_t)0x30000000
1198 # define HEAP_START DATASTART
1200 /* Lowest plausible heap address. */
1201 /* In the MMAP case, we map there. */
1202 /* In either case it is used to identify */
1203 /* heap sections so they're not */
1204 /* considered as roots. */
1205 # define OS_TYPE "IRIX5"
1206 # define MPROTECT_VDB
1208 # define CPP_WORDSZ _MIPS_SZPTR
1209 # define ALIGNMENT (_MIPS_SZPTR/8)
1210 # if CPP_WORDSZ != 64
1211 # define ALIGN_DOUBLE
1214 # define ALIGNMENT 4
1215 # define ALIGN_DOUBLE
1217 # define DYNAMIC_LOADING
1220 # define OS_TYPE "MSWINCE"
1221 # define ALIGNMENT 4
1222 # define DATAEND /* not needed */
1224 # if defined(NETBSD)
1225 # define OS_TYPE "NETBSD"
1226 # define ALIGNMENT 4
1228 # define USE_GENERIC_PUSH_REGS
1229 extern int _fdata[];
1230 # define DATASTART ((ptr_t)(_fdata))
1232 # define DATAEND ((ptr_t)(_end))
1233 # define DYNAMIC_LOADING
1238 # define MACH_TYPE "RS6000"
1240 # define ALIGNMENT 8
1241 # define CPP_WORDSZ 64
1243 # define ALIGNMENT 4
1244 # define CPP_WORDSZ 32
1246 extern int _data[], _end[];
1247 # define DATASTART ((ptr_t)((ulong)_data))
1248 # define DATAEND ((ptr_t)((ulong)_end))
1250 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1251 # define USE_GENERIC_PUSH_REGS
1252 # define DYNAMIC_LOADING
1253 /* For really old versions of AIX, this may have to be removed. */
1257 # define MACH_TYPE "HP_PA"
1259 # define CPP_WORDSZ 64
1260 # define ALIGNMENT 8
1262 # define CPP_WORDSZ 32
1263 # define ALIGNMENT 4
1264 # define ALIGN_DOUBLE
1266 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1267 # ifndef LINUX /* For now. */
1268 # define MPROTECT_VDB
1271 # define GENERIC_COMPARE_AND_SWAP
1272 /* No compare-and-swap instruction. Use pthread mutexes */
1273 /* when we absolutely have to. */
1274 # ifdef PARALLEL_MARK
1275 # define USE_MARK_BYTES
1276 /* Minimize compare-and-swap usage. */
1279 # define STACK_GROWS_UP
1281 # define OS_TYPE "HPUX"
1282 extern int __data_start[];
1283 # define DATASTART ((ptr_t)(__data_start))
1285 /* The following appears to work for 7xx systems running HP/UX */
1286 /* 9.xx Furthermore, it might result in much faster */
1287 /* collections than HEURISTIC2, which may involve scanning */
1288 /* segments that directly precede the stack. It is not the */
1289 /* default, since it may not work on older machine/OS */
1290 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1292 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1294 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1295 /* to this. Note that the GC must be initialized before the */
1296 /* first putenv call. */
1297 extern char ** environ;
1298 # define STACKBOTTOM ((ptr_t)environ)
1300 # define DYNAMIC_LOADING
1301 # include <unistd.h>
1302 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1304 # define PREFETCH(x) { \
1305 register long addr = (long)(x); \
1306 (void) _asm ("LDW", 0, 0, addr, 0); \
1311 # define OS_TYPE "LINUX"
1312 # define LINUX_STACKBOTTOM
1313 # define DYNAMIC_LOADING
1314 # define LINUX_DATA_START
1316 # define DATAEND (_end)
1321 # define MACH_TYPE "ALPHA"
1322 # define ALIGNMENT 8
1324 # define OS_TYPE "NETBSD"
1326 # define DATASTART GC_data_start
1327 # define ELFCLASS32 32
1328 # define ELFCLASS64 64
1329 # define ELF_CLASS ELFCLASS64
1330 # define CPP_WORDSZ 64
1331 # define DYNAMIC_LOADING
1334 # define OS_TYPE "OPENBSD"
1336 # define CPP_WORDSZ 64
1337 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1338 # define DATASTART GC_data_start
1339 # define ELFCLASS32 32
1340 # define ELFCLASS64 64
1341 # define ELF_CLASS ELFCLASS64
1342 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1343 # define DATASTART ((ptr_t) 0x140000000)
1347 # define OS_TYPE "FREEBSD"
1348 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1349 # define SIG_SUSPEND SIGUSR1
1350 # define SIG_THR_RESTART SIGUSR2
1351 # define FREEBSD_STACKBOTTOM
1353 # define DYNAMIC_LOADING
1355 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1356 extern char etext[];
1357 extern char edata[];
1359 # define NEED_FIND_LIMIT
1360 # define DATASTART ((ptr_t)(etext))
1361 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1362 # define DATASTART2 ((ptr_t)(edata))
1363 # define DATAEND2 ((ptr_t)(end))
1364 # define CPP_WORDSZ 64
1367 # define OS_TYPE "OSF1"
1368 # define DATASTART ((ptr_t) 0x140000000)
1370 # define DATAEND ((ptr_t) _end)
1371 extern char ** environ;
1372 /* round up from the value of environ to the nearest page boundary */
1373 /* Probably breaks if putenv is called before collector */
1374 /* initialization. */
1375 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1376 /* # define HEURISTIC2 */
1377 /* Normally HEURISTIC2 is too conervative, since */
1378 /* the text segment immediately follows the stack. */
1379 /* Hence we give an upper pound. */
1380 /* This is currently unused, since we disabled HEURISTIC2 */
1381 extern int __start[];
1382 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1383 # define CPP_WORDSZ 64
1384 # define MPROTECT_VDB
1385 # define DYNAMIC_LOADING
1388 # define OS_TYPE "LINUX"
1389 # define CPP_WORDSZ 64
1390 # define STACKBOTTOM ((ptr_t) 0x120000000)
1392 # define SEARCH_FOR_DATA_START
1393 # define DATASTART GC_data_start
1394 # define DYNAMIC_LOADING
1396 # define DATASTART ((ptr_t) 0x140000000)
1399 # define DATAEND (_end)
1400 # define MPROTECT_VDB
1401 /* Has only been superficially tested. May not */
1402 /* work on all versions. */
1407 # define MACH_TYPE "IA64"
1408 # define USE_GENERIC_PUSH_REGS
1409 /* We need to get preserved registers in addition to register */
1410 /* windows. That's easiest to do with setjmp. */
1411 # ifdef PARALLEL_MARK
1412 # define USE_MARK_BYTES
1413 /* Compare-and-exchange is too expensive to use for */
1414 /* setting mark bits. */
1418 # define CPP_WORDSZ 32
1419 # define ALIGN_DOUBLE
1420 /* Requires 8 byte alignment for malloc */
1421 # define ALIGNMENT 4
1426 # define CPP_WORDSZ 64
1427 # define ALIGN_DOUBLE
1428 /* Requires 16 byte alignment for malloc */
1429 # define ALIGNMENT 8
1431 # define OS_TYPE "HPUX"
1432 extern int __data_start[];
1433 # define DATASTART ((ptr_t)(__data_start))
1434 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1435 /* to this. Note that the GC must be initialized before the */
1436 /* first putenv call. */
1437 extern char ** environ;
1438 # define STACKBOTTOM ((ptr_t)environ)
1439 # define DYNAMIC_LOADING
1440 # include <unistd.h>
1441 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1442 /* The following was empirically determined, and is probably */
1443 /* not very robust. */
1444 /* Note that the backing store base seems to be at a nice */
1445 /* address minus one page. */
1446 # define BACKING_STORE_DISPLACEMENT 0x1000000
1447 # define BACKING_STORE_ALIGNMENT 0x1000
1448 # define BACKING_STORE_BASE \
1449 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1450 & ~(BACKING_STORE_ALIGNMENT - 1))
1453 # define CPP_WORDSZ 64
1454 # define ALIGN_DOUBLE
1455 /* Requires 16 byte alignment for malloc */
1456 # define ALIGNMENT 8
1457 # define OS_TYPE "LINUX"
1458 /* The following works on NUE and older kernels: */
1459 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1460 /* This does not work on NUE: */
1461 # define LINUX_STACKBOTTOM
1462 /* We also need the base address of the register stack */
1463 /* backing store. This is computed in */
1464 /* GC_linux_register_stack_base based on the following */
1466 # define BACKING_STORE_ALIGNMENT 0x100000
1467 # define BACKING_STORE_DISPLACEMENT 0x80000000
1468 extern char * GC_register_stackbottom;
1469 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1470 # define SEARCH_FOR_DATA_START
1471 # define DATASTART GC_data_start
1473 # define DYNAMIC_LOADING
1475 /* In the Intel compiler environment, we seem to end up with */
1476 /* statically linked executables and an undefined reference */
1479 # define MPROTECT_VDB
1480 /* Requires Linux 2.3.47 or later. */
1482 # define DATAEND (_end)
1484 # define PREFETCH(x) \
1485 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1486 # define PREFETCH_FOR_WRITE(x) \
1487 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1488 # define CLEAR_DOUBLE(x) \
1489 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1495 # define MACH_TYPE "M88K"
1496 # define ALIGNMENT 4
1497 # define ALIGN_DOUBLE
1500 # define OS_TYPE "CX_UX"
1501 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1504 # define OS_TYPE "DGUX"
1505 extern char * GC_SysVGetDataStart();
1506 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1508 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1512 # define MACH_TYPE "S370"
1513 # define ALIGNMENT 4 /* Required by hardware */
1514 # define USE_GENERIC_PUSH_REGS
1516 # define OS_TYPE "UTS4"
1518 extern int _etext[];
1520 extern char * GC_SysVGetDataStart();
1521 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1522 # define DATAEND (_end)
1528 # define MACH_TYPE "S390"
1529 # define USE_GENERIC_PUSH_REGS
1531 # define ALIGNMENT 4
1532 # define CPP_WORDSZ 32
1534 # define ALIGNMENT 8
1535 # define CPP_WORDSZ 64
1536 # define HBLKSIZE 4096
1539 # define OS_TYPE "LINUX"
1540 # define LINUX_STACKBOTTOM
1541 # define DYNAMIC_LOADING
1542 extern int __data_start[];
1543 # define DATASTART ((ptr_t)(__data_start))
1545 # define DATAEND (_end)
1546 # define CACHE_LINE_SIZE 256
1547 # define GETPAGESIZE() 4096
1552 # define ALIGNMENT 4
1553 extern int _etext[];
1554 # define DATASTART ((ptr_t)(_etext))
1559 # define CPP_WORDSZ 32
1560 # define MACH_TYPE "ARM32"
1561 # define ALIGNMENT 4
1563 # define OS_TYPE "NETBSD"
1566 # define DATASTART GC_data_start
1567 # define DYNAMIC_LOADING
1569 extern char etext[];
1570 # define DATASTART ((ptr_t)(etext))
1572 # define USE_GENERIC_PUSH_REGS
1575 # define OS_TYPE "LINUX"
1578 # define STACK_GRAN 0x10000000
1579 # define USE_GENERIC_PUSH_REGS
1581 # define DYNAMIC_LOADING
1582 # include <features.h>
1583 # if defined(__GLIBC__) && __GLIBC__ >= 2
1584 # define LINUX_DATA_START
1586 extern char **__environ;
1587 # define DATASTART ((ptr_t)(&__environ))
1588 /* hideous kludge: __environ is the first */
1589 /* word in crt0.o, and delimits the start */
1590 /* of the data segment, no matter which */
1591 /* ld options were passed through. */
1592 /* We could use _etext instead, but that */
1593 /* would include .rodata, which may */
1594 /* contain large read-only data tables */
1595 /* that we'd rather not scan. */
1598 # define DATAEND (_end)
1601 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1605 # define OS_TYPE "MSWINCE"
1606 # define DATAEND /* not needed */
1609 /* __data_start is usually defined in the target linker script. */
1610 extern int __data_start[];
1611 # define DATASTART (ptr_t)(__data_start)
1612 # define USE_GENERIC_PUSH_REGS
1613 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1614 extern void *__stack_base__;
1615 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1620 # define MACH_TYPE "SH"
1621 # define ALIGNMENT 4
1623 # define OS_TYPE "MSWINCE"
1624 # define DATAEND /* not needed */
1627 # define OS_TYPE "LINUX"
1628 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1629 # define USE_GENERIC_PUSH_REGS
1630 # define DYNAMIC_LOADING
1631 # define LINUX_DATA_START
1633 # define DATAEND (_end)
1638 # define MACH_TYPE "SH4"
1639 # define OS_TYPE "MSWINCE"
1640 # define ALIGNMENT 4
1641 # define DATAEND /* not needed */
1645 # define MACH_TYPE "X86_64"
1646 # define ALIGNMENT 8
1647 # define CPP_WORDSZ 64
1648 # define HBLKSIZE 4096
1649 # define CACHE_LINE_SIZE 64
1650 # define USE_GENERIC_PUSH_REGS
1652 # define OS_TYPE "LINUX"
1653 # define LINUX_STACKBOTTOM
1654 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1655 # define MPROTECT_VDB
1657 /* We seem to get random errors in incremental mode, */
1658 /* possibly because Linux threads is itself a malloc client */
1659 /* and can't deal with the signals. */
1662 # define DYNAMIC_LOADING
1663 # ifdef UNDEFINED /* includes ro data */
1664 extern int _etext[];
1665 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1667 # include <features.h>
1668 # define LINUX_DATA_START
1670 # define DATAEND (_end)
1673 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1675 # define PREFETCH(x) \
1676 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1677 # define PREFETCH_FOR_WRITE(x) \
1678 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1682 #ifdef LINUX_DATA_START
1683 /* Some Linux distributions arrange to define __data_start. Some */
1684 /* define data_start as a weak symbol. The latter is technically */
1685 /* broken, since the user program may define data_start, in which */
1686 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1687 /* We assume gcc. */
1688 # pragma weak __data_start
1689 extern int __data_start[];
1690 # pragma weak data_start
1691 extern int data_start[];
1692 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1695 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1696 /* Rld appears to allocate some memory with its own allocator, and */
1697 /* some through malloc, which might be redirected. To make this */
1698 /* work with collectable memory, we have to scan memory allocated */
1699 /* by rld's internal malloc. */
1700 # define USE_PROC_FOR_LIBRARIES
1703 # ifndef STACK_GROWS_UP
1704 # define STACK_GROWS_DOWN
1708 # define CPP_WORDSZ 32
1717 # define DATAEND (end)
1720 # if defined(SVR4) && !defined(GETPAGESIZE)
1721 # include <unistd.h>
1722 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1725 # ifndef GETPAGESIZE
1726 # if defined(SUNOS5) || defined(IRIX5)
1727 # include <unistd.h>
1729 # define GETPAGESIZE() getpagesize()
1732 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1733 /* OS has SVR4 generic features. Probably others also qualify. */
1737 # if defined(SUNOS5) || defined(DRSNX)
1738 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1741 /* OS has SUNOS5 style signal handlers. */
1749 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1750 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1751 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1752 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1755 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1760 # undef DYNAMIC_LOADING
1765 # undef MPROTECT_VDB
1770 /* Postponed for now. */
1772 # undef MPROTECT_VDB
1775 # ifdef SMALL_CONFIG
1776 /* Presumably not worth the space it takes. */
1778 # undef MPROTECT_VDB
1782 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1785 # ifdef PARALLEL_MARK
1786 # undef MPROTECT_VDB /* For now. */
1789 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1790 # define DEFAULT_VDB
1794 # define PREFETCH(x)
1795 # define NO_PREFETCH
1798 # ifndef PREFETCH_FOR_WRITE
1799 # define PREFETCH_FOR_WRITE(x)
1800 # define NO_PREFETCH_FOR_WRITE
1803 # ifndef CACHE_LINE_SIZE
1804 # define CACHE_LINE_SIZE 32 /* Wild guess */
1808 # define REGISTER_LIBRARIES_EARLY
1809 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
1810 /* lock. This isn't safe after the world has stopped. So we must */
1811 /* call GC_register_dynamic_libraries before stopping the world. */
1812 /* For performance reasons, this may be beneficial on other */
1813 /* platforms as well, though it should be avoided in win32. */
1816 # if defined(SEARCH_FOR_DATA_START) && defined(GC_PRIVATE_H)
1817 extern ptr_t GC_data_start;
1820 # ifndef CLEAR_DOUBLE
1821 # define CLEAR_DOUBLE(x) \
1822 ((word*)x)[0] = 0; \
1824 # endif /* CLEAR_DOUBLE */
1826 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1827 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1828 # define GC_SOLARIS_THREADS
1831 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1832 --> inconsistent configuration
1834 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1835 --> inconsistent configuration
1837 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1838 --> inconsistent configuration
1840 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1841 --> inconsistent configuration
1843 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1844 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1845 /* the necessary code is mostly there, but nobody has actually made */
1846 /* sure the right combination of pieces is compiled in, etc. */
1847 --> inconsistent configuration
1850 # if defined(PCR) || defined(SRC_M3) || \
1851 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1852 defined(GC_PTHREADS)
1856 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1857 || defined(LINT) || defined(MSWINCE) \
1858 || (defined(I386) && defined(__LCC__))
1859 /* Use setjmp based hack to mark from callee-save registers. */
1860 /* The define should move to the individual platform */
1862 # define USE_GENERIC_PUSH_REGS
1866 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1867 /* include assembly code to do it well. */
1870 /* Can we save call chain in objects for debugging? */
1871 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1872 /* to reasonable values for the platform. */
1873 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1874 /* build time, though we feel free to adjust it slightly. */
1875 /* Define NEED_CALLINFO if we either save the call stack or */
1876 /* GC_ADD_CALLER is defined. */
1878 # include <features.h>
1879 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1880 # define HAVE_BUILTIN_BACKTRACE
1885 # define CAN_SAVE_CALL_STACKS
1886 # define CAN_SAVE_CALL_ARGS
1888 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1889 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1890 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1891 # define CAN_SAVE_CALL_STACKS
1892 # define CAN_SAVE_CALL_ARGS
1894 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1895 # define CAN_SAVE_CALL_STACKS
1898 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1899 && defined(CAN_SAVE_CALL_STACKS)
1900 # define SAVE_CALL_CHAIN
1902 # ifdef SAVE_CALL_CHAIN
1903 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1904 # define NARGS SAVE_CALL_NARGS
1906 # define NARGS 0 /* Number of arguments to save for each call. */
1909 # ifdef SAVE_CALL_CHAIN
1910 # ifndef SAVE_CALL_COUNT
1911 # define NFRAMES 6 /* Number of frames to save. Even for */
1912 /* alignment reasons. */
1914 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1916 # define NEED_CALLINFO
1917 # endif /* SAVE_CALL_CHAIN */
1918 # ifdef GC_ADD_CALLER
1921 # define NEED_CALLINFO
1924 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1925 # define DBG_HDRS_ALL
1928 # endif /* GCCONFIG_H */