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 /* Determine the machine type: */
42 # if defined(__XSCALE__)
46 # define mach_type_known
49 # if defined(sun) && defined(mc68000)
52 # define mach_type_known
54 # if defined(hp9000s300)
57 # define mach_type_known
59 # if defined(OPENBSD) && defined(m68k)
61 # define mach_type_known
63 # if defined(OPENBSD) && defined(__sparc__)
65 # define mach_type_known
67 # if defined(NETBSD) && defined(m68k)
69 # define mach_type_known
71 # if defined(NETBSD) && defined(__powerpc__)
73 # define mach_type_known
75 # if defined(NETBSD) && defined(__arm32__)
77 # define mach_type_known
86 # define mach_type_known
88 # if defined(mips) || defined(__mips) || defined(_mips)
90 # if defined(nec_ews) || defined(_nec_ews)
93 # if !defined(LINUX) && !defined(EWS4800)
94 # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
97 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
98 || defined(__SYSTYPE_SVR4__)
99 # define IRIX5 /* or IRIX 6.X */
101 # define RISCOS /* or IRIX 4.X */
105 # if defined(__NetBSD__) && defined(__MIPSEL__)
108 # define mach_type_known
110 # if defined(sequent) && (defined(i386) || defined(__i386__))
113 # define mach_type_known
115 # if defined(sun) && (defined(i386) || defined(__i386__))
118 # define mach_type_known
120 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
123 # define mach_type_known
127 # define mach_type_known
129 # if defined(sun) && (defined(sparc) || defined(__sparc))
131 /* Test for SunOS 5.x */
138 # define mach_type_known
140 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
141 && !defined(__OpenBSD__) && !(__NetBSD__)
144 # define mach_type_known
148 # define mach_type_known
150 # if defined(__NetBSD__) && defined(__sparc__)
152 # define mach_type_known
154 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
155 /* The above test may need refinement */
157 # if defined(_SCO_ELF)
162 # define mach_type_known
164 # if defined(_AUX_SOURCE)
167 # define mach_type_known
169 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
170 || defined(hppa) || defined(__hppa__)
175 # define mach_type_known
177 # if defined(__ia64) && defined(_HPUX_SOURCE)
180 # define mach_type_known
182 # if defined(__BEOS__) && defined(_X86_)
185 # define mach_type_known
187 # if defined(LINUX) && (defined(i386) || defined(__i386__))
189 # define mach_type_known
191 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
193 # define mach_type_known
195 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
197 # define mach_type_known
199 # if defined(LINUX) && defined(__mc68000__)
201 # define mach_type_known
203 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
205 # define mach_type_known
207 # if defined(LINUX) && defined(__arm__)
209 # define mach_type_known
211 # if defined(LINUX) && defined(__sh__)
213 # define mach_type_known
215 # if defined(__alpha) || defined(__alpha__)
217 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD)
218 # define OSF1 /* a.k.a Digital Unix */
220 # define mach_type_known
222 # if defined(_AMIGA) && !defined(AMIGA)
227 # define mach_type_known
229 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
232 # define mach_type_known
234 # if defined(__MWERKS__) && defined(__powerc)
237 # define mach_type_known
239 # if defined(macosx) || \
240 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
243 # define mach_type_known
245 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
248 --> Not really supported, but at least we recognize it.
250 # if defined(NeXT) && defined(mc68000)
253 # define mach_type_known
255 # if defined(NeXT) && (defined(i386) || defined(__i386__))
258 # define mach_type_known
260 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
263 # define mach_type_known
265 # if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
268 # define mach_type_known
270 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
272 # define mach_type_known
274 # if defined(bsdi) && (defined(i386) || defined(__i386__))
277 # define mach_type_known
279 # if !defined(mach_type_known) && defined(__386BSD__)
282 # define mach_type_known
284 # if defined(_CX_UX) && defined(_M88K)
287 # define mach_type_known
292 # define mach_type_known
294 # if defined(_WIN32_WCE)
295 /* SH3, SH4, MIPS already defined for corresponding architectures */
296 # if defined(SH3) || defined(SH4)
306 # define mach_type_known
308 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
309 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
311 # define MSWIN32 /* or Win32s */
312 # define mach_type_known
315 # if defined(__DJGPP__)
318 # define DJGPP /* MSDOS running the DJGPP port of GCC */
320 # define mach_type_known
322 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
325 # define mach_type_known
327 # if defined(__MINGW32__)
330 # define mach_type_known
332 # if defined(__BORLANDC__)
335 # define mach_type_known
337 # if defined(_UTS) && !defined(mach_type_known)
340 # define mach_type_known
344 # define mach_type_known
346 # if defined(__embedded__) && defined(PPC)
349 # define mach_type_known
352 # if defined(__WATCOMC__) && defined(__386__)
354 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
355 # if defined(__OS2__)
358 # if defined(__WINDOWS_386__) || defined(__NT__)
365 # define mach_type_known
367 # if defined(__s390__) && defined(LINUX)
369 # define mach_type_known
371 # if defined(__GNU__)
372 # if defined(__i386__)
373 /* The Debian Hurd running on generic PC */
376 # define mach_type_known
380 /* Feel free to add more clauses here */
382 /* Or manually define the machine type here. A machine type is */
383 /* characterized by the architecture. Some */
384 /* machine types are further subdivided by OS. */
385 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
386 /* Note that SGI IRIX is treated identically to RISCOS. */
387 /* SYSV on an M68K actually means A/UX. */
388 /* The distinction in these cases is usually the stack starting address */
389 # ifndef mach_type_known
390 --> unknown machine type
392 /* Mapping is: M68K ==> Motorola 680X0 */
393 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
394 /* MACOS and AMIGA variants) */
395 /* I386 ==> Intel 386 */
396 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
397 /* FREEBSD, THREE86BSD, MSWIN32, */
398 /* BSDI,SUNOS5, NEXT, other variants) */
399 /* NS32K ==> Encore Multimax */
400 /* MIPS ==> R2000 or R3000 */
401 /* (RISCOS, ULTRIX variants) */
402 /* VAX ==> DEC VAX */
403 /* (BSD, ULTRIX variants) */
404 /* RS6000 ==> IBM RS/6000 AIX3.X */
405 /* RT ==> IBM PC/RT */
406 /* HP_PA ==> HP9000/700 & /800 */
408 /* SPARC ==> SPARC v7/v8/v9 */
409 /* (SUNOS4, SUNOS5, LINUX, */
410 /* DRSNX variants) */
411 /* ALPHA ==> DEC Alpha */
412 /* (OSF1 and LINUX variants) */
413 /* M88K ==> Motorola 88XX0 */
414 /* (CX_UX and DGUX) */
415 /* S370 ==> 370-like machine */
416 /* running Amdahl UTS4 */
417 /* or a 390 running LINUX */
418 /* ARM32 ==> Intel StrongARM */
419 /* IA64 ==> Intel IPF */
421 /* (LINUX and HPUX) */
422 /* IA64_32 ==> IA64 w/32 bit ABI */
424 /* SH ==> Hitachi SuperH */
425 /* (LINUX & MSWINCE) */
429 * For each architecture and OS, the following need to be defined:
431 * CPP_WORD_SZ is a simple integer constant representing the word size.
432 * in bits. We assume byte addressibility, where a byte has 8 bits.
433 * We also assume CPP_WORD_SZ is either 32 or 64.
434 * (We care about the length of pointers, not hardware
435 * bus widths. Thus a 64 bit processor with a C compiler that uses
436 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
438 * MACH_TYPE is a string representation of the machine type.
439 * OS_TYPE is analogous for the OS.
441 * ALIGNMENT is the largest N, such that
442 * all pointer are guaranteed to be aligned on N byte boundaries.
443 * defining it to be 1 will always work, but perform poorly.
445 * DATASTART is the beginning of the data segment.
446 * On UNIX systems, the collector will scan the area between DATASTART
447 * and DATAEND for root pointers.
449 * DATAEND, if not &end.
451 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
454 * STACKBOTTOM is the cool end of the stack, which is usually the
455 * highest address in the stack.
456 * Under PCR or OS/2, we have other ways of finding thread stacks.
457 * For each machine, the following should:
458 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
459 * 2) define exactly one of
460 * STACKBOTTOM (should be defined to be an expression)
463 * If either of the last two macros are defined, then STACKBOTTOM is computed
464 * during collector startup using one of the following two heuristics:
465 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
466 * the next multiple of STACK_GRAN.
467 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
468 * in small steps (decrement if STACK_GROWS_UP), and read the value
469 * at each location. Remember the value when the first
470 * Segmentation violation or Bus error is signalled. Round that
471 * to the nearest plausible page boundary, and use that instead
474 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
475 * the value of environ is a pointer that can serve as STACKBOTTOM.
476 * I expect that HEURISTIC2 can be replaced by this approach, which
477 * interferes far less with debugging. However it has the disadvantage
478 * that it's confused by a putenv call before the collector is initialized.
479 * This could be dealt with by intercepting putenv ...
481 * If no expression for STACKBOTTOM can be found, and neither of the above
482 * heuristics are usable, the collector can still be used with all of the above
483 * undefined, provided one of the following is done:
484 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
485 * without reference to STACKBOTTOM. This is appropriate for use in
486 * conjunction with thread packages, since there will be multiple stacks.
487 * (Allocating thread stacks in the heap, and treating them as ordinary
488 * heap data objects is also possible as a last resort. However, this is
489 * likely to introduce significant amounts of excess storage retention
490 * unless the dead parts of the thread stacks are periodically cleared.)
491 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
492 * If the author of the client code controls the main program, this is
493 * easily accomplished by introducing a new main program, setting
494 * GC_stackbottom to the address of a local variable, and then calling
495 * the original main program. The new main program would read something
498 * # include "gc_private.h"
500 * main(argc, argv, envp)
502 * char **argv, **envp;
506 * GC_stackbottom = (ptr_t)(&dummy);
507 * return(real_main(argc, argv, envp));
511 * Each architecture may also define the style of virtual dirty bit
512 * implementation to be used:
513 * MPROTECT_VDB: Write protect the heap and catch faults.
514 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
516 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
517 * defined GC_register_dynamic_libraries() for the architecture.
519 * An architecture may define PREFETCH(x) to preload the cache with *x.
520 * This defaults to a no-op.
522 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
524 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
525 * clear the two words at GC_malloc-aligned address x. By default,
526 * word stores of 0 are used instead.
529 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
530 * to push the relevant registers onto the stack. This generally makes
531 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
533 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
534 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
535 # define HAVE_BUILTIN_UNWIND_INIT
538 # define STACK_GRAN 0x1000000
540 # define MACH_TYPE "M68K"
543 # define OS_TYPE "OPENBSD"
546 # define DATASTART ((ptr_t)(&etext))
549 # define OS_TYPE "NETBSD"
552 # define DATASTART ((ptr_t)(&etext))
555 # define OS_TYPE "LINUX"
556 # define STACKBOTTOM ((ptr_t)0xf0000000)
557 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
559 # define DYNAMIC_LOADING
560 # include <features.h>
561 # if defined(__GLIBC__)&& __GLIBC__>=2
562 # define LINUX_DATA_START
564 extern char **__environ;
565 # define DATASTART ((ptr_t)(&__environ))
566 /* hideous kludge: __environ is the first */
567 /* word in crt0.o, and delimits the start */
568 /* of the data segment, no matter which */
569 /* ld options were passed through. */
570 /* We could use _etext instead, but that */
571 /* would include .rodata, which may */
572 /* contain large read-only data tables */
573 /* that we'd rather not scan. */
574 # endif /* !GLIBC2 */
576 # define DATAEND (&_end)
579 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
583 # define OS_TYPE "SUNOS4"
585 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
586 # define HEURISTIC1 /* differs */
587 # define DYNAMIC_LOADING
590 # define OS_TYPE "HP"
592 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
593 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
594 /* empirically determined. seems to work. */
596 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
599 # define OS_TYPE "SYSV"
601 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
603 +((word)&etext & 0x1fff))
604 /* This only works for shared-text binaries with magic number 0413.
605 The other sorts of SysV binaries put the data at the end of the text,
606 in which case the default of &etext would work. Unfortunately,
607 handling both would require having the magic-number available.
610 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
611 /* The stack starts at the top of memory, but */
612 /* 0x0 cannot be used as setjump_test complains */
613 /* that the stack direction is incorrect. Two */
614 /* bytes down from 0x0 should be safe enough. */
616 # include <sys/mmu.h>
617 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
620 # define OS_TYPE "AMIGA"
621 /* STACKBOTTOM and DATASTART handled specially */
623 # define DATAEND /* not needed */
624 # define GETPAGESIZE() 4096
630 # define OS_TYPE "MACOS"
631 /* see os_dep.c for details of global data segments. */
632 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
633 # define DATAEND /* not needed */
634 # define GETPAGESIZE() 4096
637 # define OS_TYPE "NEXT"
638 # define DATASTART ((ptr_t) get_etext())
639 # define STACKBOTTOM ((ptr_t) 0x4000000)
640 # define DATAEND /* not needed */
645 # define MACH_TYPE "POWERPC"
647 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
651 # define OS_TYPE "MACOS"
652 /* see os_dep.c for details of global data segments. */
653 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
654 # define DATAEND /* not needed */
657 # define ALIGNMENT 4 /* Guess. Can someone verify? */
658 /* This was 2, but that didn't sound right. */
659 # define OS_TYPE "LINUX"
661 # define DYNAMIC_LOADING
663 # define STACK_GRAN 0x10000000
664 /* Stack usually starts at 0x80000000 */
665 # define LINUX_DATA_START
667 # define DATAEND (&_end)
670 /* There are reasons to suspect this may not be reliable. */
672 # define OS_TYPE "MACOSX"
673 # define DATASTART ((ptr_t) get_etext())
674 # define STACKBOTTOM ((ptr_t) 0xc0000000)
675 # define DATAEND /* not needed */
676 # define MPROTECT_VDB
678 # define GETPAGESIZE() getpagesize()
682 # define OS_TYPE "NETBSD"
685 # define DATASTART GC_data_start
686 # define DYNAMIC_LOADING
690 # define OS_TYPE "NOSYS"
691 extern void __end, __dso_handle;
692 # define DATASTART (&__dso_handle) /* OK, that's ugly. */
693 # define DATAEND (&__end)
694 /* Stack starts at 0xE0000000 for the simulator. */
696 # define STACK_GRAN 0x10000000
702 # define MACH_TYPE "VAX"
703 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
705 # define DATASTART ((ptr_t)(&etext))
707 # define OS_TYPE "BSD"
709 /* HEURISTIC2 may be OK, but it's hard to test. */
712 # define OS_TYPE "ULTRIX"
713 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
718 # define MACH_TYPE "RT"
720 # define DATASTART ((ptr_t) 0x10000000)
721 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
725 # define MACH_TYPE "SPARC"
726 # if defined(__arch64__) || defined(__sparcv9)
728 # define CPP_WORDSZ 64
729 # define ELF_CLASS ELFCLASS64
731 # define ALIGNMENT 4 /* Required by hardware */
732 # define CPP_WORDSZ 32
734 # define ALIGN_DOUBLE
736 # define OS_TYPE "SUNOS5"
739 extern char * GC_SysVGetDataStart();
740 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
741 # define DATAEND (&_end)
742 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
744 /* Otherwise we now use calloc. Mmap may result in the */
745 /* heap interleaved with thread stacks, which can result in */
746 /* excessive blacklisting. Sbrk is unusable since it */
747 /* doesn't interact correctly with the system malloc. */
750 # define HEAP_START (ptr_t)0x40000000
752 # define HEAP_START DATAEND
755 /* HEURISTIC1 reportedly no longer works under 2.7. */
756 /* HEURISTIC2 probably works, but this appears to be preferable. */
757 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
758 /* installations that's undefined. We work around this with a */
760 # include <sys/vmparam.h>
762 /* This should work everywhere, but doesn't. */
763 # define STACKBOTTOM USRSTACK
768 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
769 /* getpagesize() appeared to be missing from at least one */
770 /* Solaris 5.4 installation. Weird. */
771 # if CPP_WORDSZ == 32
772 # define DYNAMIC_LOADING
776 # define OS_TYPE "SUNOS4"
777 /* [If you have a weak stomach, don't read this.] */
778 /* We would like to use: */
779 /* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
780 /* This fails occasionally, due to an ancient, but very */
781 /* persistent ld bug. &etext is set 32 bytes too high. */
782 /* We instead read the text segment size from the a.out */
783 /* header, which happens to be mapped into our address space */
784 /* at the start of the text segment. The detective work here */
785 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
786 /* Serpette of INRIA. */
787 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
788 # define TEXTSTART 0x2000
789 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
790 # define MPROTECT_VDB
792 # define DYNAMIC_LOADING
795 # define OS_TYPE "DRSNX"
796 extern char * GC_SysVGetDataStart();
798 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
799 # define MPROTECT_VDB
800 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
801 # define DYNAMIC_LOADING
804 # define OS_TYPE "LINUX"
806 # define DYNAMIC_LOADING
808 Linux Sparc/a.out not supported
812 # define DATAEND (&_end)
815 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
816 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, &_etext)
818 # define STACKBOTTOM ((ptr_t) 0xf0000000)
819 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
823 # define OS_TYPE "OPENBSD"
824 # define STACKBOTTOM ((ptr_t) 0xf8000000)
826 # define DATASTART ((ptr_t)(&etext))
829 # define OS_TYPE "NETBSD"
832 # define DATASTART GC_data_start
833 # define DYNAMIC_LOADING
836 # define DATASTART ((ptr_t)(&etext))
842 # define MACH_TYPE "I386"
843 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
844 /* except Borland. The -a4 option fixes */
846 /* Ivan Demakov: For Watcom the option is -zp4. */
847 # ifndef SMALL_CONFIG
848 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
849 /* improvement on Pentiums. */
851 # ifdef HAVE_BUILTIN_UNWIND_INIT
852 # define USE_GENERIC_PUSH_REGS
855 # define OS_TYPE "SEQUENT"
857 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
858 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
861 # define OS_TYPE "BEOS"
863 # define GETPAGESIZE() B_PAGE_SIZE
865 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
868 # define OS_TYPE "SUNOS5"
869 extern int _etext, _end;
870 extern char * GC_SysVGetDataStart();
871 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
872 # define DATAEND (&_end)
873 /* # define STACKBOTTOM ((ptr_t)(&_start)) worked through 2.7, */
874 /* but reportedly breaks under 2.8. It appears that the stack */
875 /* base is a property of the executable, so this should not break */
876 /* old executables. */
877 /* HEURISTIC2 probably works, but this appears to be preferable. */
879 # define STACKBOTTOM USRSTACK
880 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
881 /* It appears to be fixed in 2.8 and 2.9. */
882 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
885 # define DYNAMIC_LOADING
886 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
888 /* Otherwise we now use calloc. Mmap may result in the */
889 /* heap interleaved with thread stacks, which can result in */
890 /* excessive blacklisting. Sbrk is unusable since it */
891 /* doesn't interact correctly with the system malloc. */
894 # define HEAP_START (ptr_t)0x40000000
896 # define HEAP_START DATAEND
900 # define OS_TYPE "SCO"
902 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
904 +((word)&etext & 0xfff))
905 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
908 # define OS_TYPE "SCO_ELF"
910 # define DATASTART ((ptr_t)(&etext))
911 # define STACKBOTTOM ((ptr_t) 0x08048000)
912 # define DYNAMIC_LOADING
913 # define ELF_CLASS ELFCLASS32
917 /* The Intel compiler doesn't like inline assembly */
918 # define USE_GENERIC_PUSH_REGS
920 # define OS_TYPE "LINUX"
921 # define LINUX_STACKBOTTOM
925 # define STACK_GRAN 0x10000000
926 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
927 /* different kernel configurations. In particular, systems */
928 /* with 2GB physical memory will usually move the user */
929 /* address space limit, and hence initial SP to 0x80000000. */
931 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
932 # define MPROTECT_VDB
934 /* We seem to get random errors in incremental mode, */
935 /* possibly because Linux threads is itself a malloc client */
936 /* and can't deal with the signals. */
939 # define DYNAMIC_LOADING
940 # ifdef UNDEFINED /* includes ro data */
942 # define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
944 # include <features.h>
945 # if defined(__GLIBC__) && __GLIBC__ >= 2
946 # define LINUX_DATA_START
948 extern char **__environ;
949 # define DATASTART ((ptr_t)(&__environ))
950 /* hideous kludge: __environ is the first */
951 /* word in crt0.o, and delimits the start */
952 /* of the data segment, no matter which */
953 /* ld options were passed through. */
954 /* We could use _etext instead, but that */
955 /* would include .rodata, which may */
956 /* contain large read-only data tables */
957 /* that we'd rather not scan. */
960 # define DATAEND (&_end)
963 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
965 # ifdef USE_I686_PREFETCH
966 # define PREFETCH(x) \
967 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
968 /* Empirically prefetcht0 is much more effective at reducing */
969 /* cache miss stalls for the targetted load instructions. But it */
970 /* seems to interfere enough with other cache traffic that the net */
971 /* result is worse than prefetchnta. */
973 /* Using prefetches for write seems to have a slight negative */
974 /* impact on performance, at least for a PIII/500. */
975 # define PREFETCH_FOR_WRITE(x) \
976 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
979 # ifdef USE_3DNOW_PREFETCH
980 # define PREFETCH(x) \
981 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
982 # define PREFETCH_FOR_WRITE(x) \
983 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
987 # define OS_TYPE "CYGWIN32"
988 extern int _data_start__;
989 extern int _data_end__;
990 extern int _bss_start__;
991 extern int _bss_end__;
992 /* For binutils 2.9.1, we have */
993 /* DATASTART = _data_start__ */
994 /* DATAEND = _bss_end__ */
995 /* whereas for some earlier versions it was */
996 /* DATASTART = _bss_start__ */
997 /* DATAEND = _data_end__ */
998 /* To get it right for both, we take the */
999 /* minumum/maximum of the two. */
1000 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1001 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1002 # define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
1003 # define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__))
1005 # define STACK_GRAN 0x10000
1009 # define OS_TYPE "OS2"
1010 /* STACKBOTTOM and DATASTART are handled specially in */
1011 /* os_dep.c. OS2 actually has the right */
1013 # define DATAEND /* not needed */
1014 # define USE_GENERIC_PUSH_REGS
1017 # define OS_TYPE "MSWIN32"
1018 /* STACKBOTTOM and DATASTART are handled specially in */
1020 # ifndef __WATCOMC__
1021 # define MPROTECT_VDB
1023 # define DATAEND /* not needed */
1026 # define OS_TYPE "MSWINCE"
1027 # define DATAEND /* not needed */
1030 # define OS_TYPE "DJGPP"
1031 # include "stubinfo.h"
1034 extern int __djgpp_stack_limit;
1035 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
1036 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1038 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1039 /* This may not be right. */
1042 # define OS_TYPE "OPENBSD"
1045 # define OS_TYPE "FREEBSD"
1046 # ifndef GC_FREEBSD_THREADS
1047 # define MPROTECT_VDB
1049 # define SIG_SUSPEND SIGUSR1
1050 # define SIG_THR_RESTART SIGUSR2
1051 # define FREEBSD_STACKBOTTOM
1053 # define DYNAMIC_LOADING
1056 # define DATASTART ((ptr_t)(&etext))
1059 # define OS_TYPE "NETBSD"
1062 # define OS_TYPE "THREE86BSD"
1065 # define OS_TYPE "BSDI"
1067 # if defined(OPENBSD) || defined(NETBSD) \
1068 || defined(THREE86BSD) || defined(BSDI)
1071 # define DATASTART ((ptr_t)(&etext))
1074 # define OS_TYPE "NEXT"
1075 # define DATASTART ((ptr_t) get_etext())
1076 # define STACKBOTTOM ((ptr_t)0xc0000000)
1077 # define DATAEND /* not needed */
1080 # define OS_TYPE "DOS4GW"
1081 extern long __nullarea;
1083 extern char *_STACKTOP;
1084 /* Depending on calling conventions Watcom C either precedes
1085 or does not precedes with undescore names of C-variables.
1086 Make sure startup code variables always have the same names. */
1087 #pragma aux __nullarea "*";
1088 #pragma aux _end "*";
1089 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1090 /* confused? me too. */
1091 # define DATASTART ((ptr_t) &__nullarea)
1092 # define DATAEND ((ptr_t) &_end)
1095 # define OS_TYPE "HURD"
1096 # define STACK_GROWS_DOWN
1098 extern int __data_start;
1099 # define DATASTART ( (ptr_t) (&__data_start))
1101 # define DATAEND ( (ptr_t) (&_end))
1102 /* # define MPROTECT_VDB Not quite working yet? */
1103 # define DYNAMIC_LOADING
1108 # define MACH_TYPE "NS32K"
1109 # define ALIGNMENT 4
1110 extern char **environ;
1111 # define DATASTART ((ptr_t)(&environ))
1112 /* hideous kludge: environ is the first */
1113 /* word in crt0.o, and delimits the start */
1114 /* of the data segment, no matter which */
1115 /* ld options were passed through. */
1116 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1120 # define MACH_TYPE "MIPS"
1122 /* This was developed for a linuxce style platform. Probably */
1123 /* needs to be tweaked for workstation class machines. */
1124 # define OS_TYPE "LINUX"
1125 extern int __data_start;
1126 # define DATASTART ((ptr_t)(&__data_start))
1127 # define ALIGNMENT 4
1128 # define USE_GENERIC_PUSH_REGS
1129 # define STACKBOTTOM ((ptr_t)0x7fff8000)
1130 /* Older toolchains may need 0x80000000. */
1131 /* In many cases, this should probably use LINUX_STACKBOTTOM */
1132 /* instead. But some kernel versions seem to give the wrong */
1133 /* value from /proc. */
1137 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1138 extern int _fdata[], _end[];
1139 # define DATASTART ((ptr_t)_fdata)
1140 # define DATAEND ((ptr_t)_end)
1141 # define CPP_WORDSZ _MIPS_SZPTR
1142 # define ALIGNMENT (_MIPS_SZPTR/8)
1144 extern int etext, edata, end;
1145 extern int _DYNAMIC_LINKING, _gp;
1146 # define DATASTART ((ptr_t)((((word)&etext + 0x3ffff) & ~0x3ffff) \
1147 + ((word)&etext & 0xffff)))
1148 # define DATAEND (&edata)
1149 # define DATASTART2 (&_DYNAMIC_LINKING \
1150 ? (ptr_t)(((word)&_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1152 # define DATAEND2 (&end)
1153 # define ALIGNMENT 4
1155 # define OS_TYPE "EWS4800"
1156 # define USE_GENERIC_PUSH_REGS 1
1160 # define DATASTART (ptr_t)0x10000000
1161 /* Could probably be slightly higher since */
1162 /* startup code allocates lots of stuff. */
1163 # define OS_TYPE "ULTRIX"
1164 # define ALIGNMENT 4
1168 # define DATASTART (ptr_t)0x10000000
1169 # define OS_TYPE "RISCOS"
1170 # define ALIGNMENT 4 /* Required by hardware */
1175 # define DATASTART ((ptr_t)(&_fdata))
1177 # define HEAP_START (ptr_t)0x30000000
1179 # define HEAP_START DATASTART
1181 /* Lowest plausible heap address. */
1182 /* In the MMAP case, we map there. */
1183 /* In either case it is used to identify */
1184 /* heap sections so they're not */
1185 /* considered as roots. */
1186 # define OS_TYPE "IRIX5"
1187 # define MPROTECT_VDB
1189 # define CPP_WORDSZ _MIPS_SZPTR
1190 # define ALIGNMENT (_MIPS_SZPTR/8)
1191 # if CPP_WORDSZ != 64
1192 # define ALIGN_DOUBLE
1195 # define ALIGNMENT 4
1196 # define ALIGN_DOUBLE
1198 # define DYNAMIC_LOADING
1201 # define OS_TYPE "MSWINCE"
1202 # define ALIGNMENT 4
1203 # define DATAEND /* not needed */
1205 # if defined(NETBSD)
1206 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1207 /* should be handled at the top of the file. */
1208 # define ALIGNMENT 4
1209 # define OS_TYPE "NETBSD"
1211 # define USE_GENERIC_PUSH_REGS
1214 # define DATASTART GC_data_start
1215 # define NEED_FIND_LIMIT
1216 # define DYNAMIC_LOADING
1218 # define DATASTART ((ptr_t) 0x10000000)
1219 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1225 # define MACH_TYPE "RS6000"
1227 # define ALIGNMENT 8
1228 # define CPP_WORDSZ 64
1230 # define ALIGNMENT 4
1231 # define CPP_WORDSZ 32
1233 extern int _data, _end;
1234 # define DATASTART ((ptr_t)((ulong)&_data))
1235 # define DATAEND ((ptr_t)((ulong)&_end))
1237 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1238 # define USE_GENERIC_PUSH_REGS
1239 # define DYNAMIC_LOADING
1240 /* For really old versions of AIX, this may have to be removed. */
1244 # define MACH_TYPE "HP_PA"
1246 # define CPP_WORDSZ 64
1247 # define ALIGNMENT 8
1249 # define CPP_WORDSZ 32
1250 # define ALIGNMENT 4
1251 # define ALIGN_DOUBLE
1253 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1254 # ifndef LINUX /* For now. */
1255 # define MPROTECT_VDB
1258 # define GENERIC_COMPARE_AND_SWAP
1259 /* No compare-and-swap instruction. Use pthread mutexes */
1260 /* when we absolutely have to. */
1261 # ifdef PARALLEL_MARK
1262 # define USE_MARK_BYTES
1263 /* Minimize compare-and-swap usage. */
1266 # define STACK_GROWS_UP
1268 # define OS_TYPE "HPUX"
1269 extern int __data_start;
1270 # define DATASTART ((ptr_t)(&__data_start))
1272 /* The following appears to work for 7xx systems running HP/UX */
1273 /* 9.xx Furthermore, it might result in much faster */
1274 /* collections than HEURISTIC2, which may involve scanning */
1275 /* segments that directly precede the stack. It is not the */
1276 /* default, since it may not work on older machine/OS */
1277 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1279 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1281 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1282 /* to this. Note that the GC must be initialized before the */
1283 /* first putenv call. */
1284 extern char ** environ;
1285 # define STACKBOTTOM ((ptr_t)environ)
1287 # define DYNAMIC_LOADING
1288 # include <unistd.h>
1289 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1291 # define PREFETCH(x) { \
1292 register long addr = (long)(x); \
1293 (void) _asm ("LDW", 0, 0, addr, 0); \
1298 # define OS_TYPE "LINUX"
1299 # define LINUX_STACKBOTTOM
1300 # define DYNAMIC_LOADING
1301 # define LINUX_DATA_START
1303 # define DATAEND (&_end)
1308 # define MACH_TYPE "ALPHA"
1309 # define ALIGNMENT 8
1311 # define OS_TYPE "NETBSD"
1313 # define DATASTART GC_data_start
1314 # define ELFCLASS32 32
1315 # define ELFCLASS64 64
1316 # define ELF_CLASS ELFCLASS64
1317 # define CPP_WORDSZ 64
1318 # define DYNAMIC_LOADING
1321 # define OS_TYPE "OPENBSD"
1323 # define CPP_WORDSZ 64
1324 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1325 # define DATASTART GC_data_start
1326 # define ELFCLASS32 32
1327 # define ELFCLASS64 64
1328 # define ELF_CLASS ELFCLASS64
1329 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1330 # define DATASTART ((ptr_t) 0x140000000)
1334 # define OS_TYPE "OSF1"
1335 # define DATASTART ((ptr_t) 0x140000000)
1337 # define DATAEND ((ptr_t) &_end)
1338 extern char ** environ;
1339 /* round up from the value of environ to the nearest page boundary */
1340 /* Probably breaks if putenv is called before collector */
1341 /* initialization. */
1342 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1343 /* # define HEURISTIC2 */
1344 /* Normally HEURISTIC2 is too conervative, since */
1345 /* the text segment immediately follows the stack. */
1346 /* Hence we give an upper pound. */
1347 /* This is currently unused, since we disabled HEURISTIC2 */
1349 # define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
1350 # define CPP_WORDSZ 64
1351 # define MPROTECT_VDB
1352 # define DYNAMIC_LOADING
1355 # define OS_TYPE "LINUX"
1356 # define CPP_WORDSZ 64
1357 # define STACKBOTTOM ((ptr_t) 0x120000000)
1359 # define SEARCH_FOR_DATA_START
1360 # define DATASTART GC_data_start
1361 # define DYNAMIC_LOADING
1363 # define DATASTART ((ptr_t) 0x140000000)
1366 # define DATAEND (&_end)
1367 # define MPROTECT_VDB
1368 /* Has only been superficially tested. May not */
1369 /* work on all versions. */
1374 # define MACH_TYPE "IA64"
1375 # define USE_GENERIC_PUSH_REGS
1376 /* We need to get preserved registers in addition to register */
1377 /* windows. That's easiest to do with setjmp. */
1378 # ifdef PARALLEL_MARK
1379 # define USE_MARK_BYTES
1380 /* Compare-and-exchange is too expensive to use for */
1381 /* setting mark bits. */
1385 # define CPP_WORDSZ 32
1386 # define ALIGN_DOUBLE
1387 /* Requires 8 byte alignment for malloc */
1388 # define ALIGNMENT 4
1393 # define CPP_WORDSZ 64
1394 # define ALIGN_DOUBLE
1395 /* Requires 16 byte alignment for malloc */
1396 # define ALIGNMENT 8
1398 # define OS_TYPE "HPUX"
1399 extern int __data_start;
1400 # define DATASTART ((ptr_t)(&__data_start))
1401 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1402 /* to this. Note that the GC must be initialized before the */
1403 /* first putenv call. */
1404 extern char ** environ;
1405 # define STACKBOTTOM ((ptr_t)environ)
1406 # define DYNAMIC_LOADING
1407 # include <unistd.h>
1408 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1409 /* The following was empirically determined, and is probably */
1410 /* not very robust. */
1411 /* Note that the backing store base seems to be at a nice */
1412 /* address minus one page. */
1413 # define BACKING_STORE_DISPLACEMENT 0x1000000
1414 # define BACKING_STORE_ALIGNMENT 0x1000
1415 # define BACKING_STORE_BASE \
1416 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1417 & ~(BACKING_STORE_ALIGNMENT - 1))
1420 # define CPP_WORDSZ 64
1421 # define ALIGN_DOUBLE
1422 /* Requires 16 byte alignment for malloc */
1423 # define ALIGNMENT 8
1424 # define OS_TYPE "LINUX"
1425 /* The following works on NUE and older kernels: */
1426 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1427 /* This does not work on NUE: */
1428 # define LINUX_STACKBOTTOM
1429 /* We also need the base address of the register stack */
1430 /* backing store. This is computed in */
1431 /* GC_linux_register_stack_base based on the following */
1433 # define BACKING_STORE_ALIGNMENT 0x100000
1434 # define BACKING_STORE_DISPLACEMENT 0x80000000
1435 extern char * GC_register_stackbottom;
1436 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1437 # define SEARCH_FOR_DATA_START
1438 # define DATASTART GC_data_start
1440 # define DYNAMIC_LOADING
1442 /* In the Intel compiler environment, we seem to end up with */
1443 /* statically linked executables and an undefined reference */
1446 # define MPROTECT_VDB
1447 /* Requires Linux 2.3.47 or later. */
1449 # define DATAEND (&_end)
1451 # define PREFETCH(x) \
1452 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1453 # define PREFETCH_FOR_WRITE(x) \
1454 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1455 # define CLEAR_DOUBLE(x) \
1456 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1462 # define MACH_TYPE "M88K"
1463 # define ALIGNMENT 4
1464 # define ALIGN_DOUBLE
1467 # define OS_TYPE "CX_UX"
1468 # define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1471 # define OS_TYPE "DGUX"
1472 extern char * GC_SysVGetDataStart();
1473 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
1475 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1479 # define MACH_TYPE "S370"
1480 # define ALIGNMENT 4 /* Required by hardware */
1481 # define USE_GENERIC_PUSH_REGS
1483 # define OS_TYPE "UTS4"
1487 extern char * GC_SysVGetDataStart();
1488 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
1489 # define DATAEND (&_end)
1493 # define OS_TYPE "LINUX"
1495 # define DYNAMIC_LOADING
1496 extern int __data_start;
1497 # define DATASTART ((ptr_t)(&__data_start))
1502 # define ALIGNMENT 4
1504 # define DATASTART ((ptr_t)(&_etext))
1509 # define CPP_WORDSZ 32
1510 # define MACH_TYPE "ARM32"
1511 # define ALIGNMENT 4
1513 # define OS_TYPE "NETBSD"
1516 # define DATASTART ((ptr_t)(&etext))
1517 # define USE_GENERIC_PUSH_REGS
1520 # define OS_TYPE "LINUX"
1523 # define STACK_GRAN 0x10000000
1524 # define USE_GENERIC_PUSH_REGS
1526 # define DYNAMIC_LOADING
1527 # include <features.h>
1528 # if defined(__GLIBC__) && __GLIBC__ >= 2
1529 # define LINUX_DATA_START
1531 extern char **__environ;
1532 # define DATASTART ((ptr_t)(&__environ))
1533 /* hideous kludge: __environ is the first */
1534 /* word in crt0.o, and delimits the start */
1535 /* of the data segment, no matter which */
1536 /* ld options were passed through. */
1537 /* We could use _etext instead, but that */
1538 /* would include .rodata, which may */
1539 /* contain large read-only data tables */
1540 /* that we'd rather not scan. */
1543 # define DATAEND (&_end)
1546 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
1550 # define OS_TYPE "MSWINCE"
1551 # define DATAEND /* not needed */
1554 /* __data_start is usually defined in the target linker script. */
1555 extern int __data_start;
1556 # define DATASTART (ptr_t)(&__data_start)
1557 # define USE_GENERIC_PUSH_REGS
1558 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1559 extern void *__stack_base__;
1560 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1565 # define MACH_TYPE "SH"
1566 # define ALIGNMENT 4
1568 # define OS_TYPE "MSWINCE"
1569 # define DATAEND /* not needed */
1572 # define OS_TYPE "LINUX"
1573 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1574 # define USE_GENERIC_PUSH_REGS
1575 # define DYNAMIC_LOADING
1576 # define LINUX_DATA_START
1578 # define DATAEND (&_end)
1583 # define MACH_TYPE "SH4"
1584 # define OS_TYPE "MSWINCE"
1585 # define ALIGNMENT 4
1586 # define DATAEND /* not needed */
1589 #ifdef LINUX_DATA_START
1590 /* Some Linux distributions arrange to define __data_start. Some */
1591 /* define data_start as a weak symbol. The latter is technically */
1592 /* broken, since the user program may define data_start, in which */
1593 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1594 /* We assume gcc. */
1595 # pragma weak __data_start
1596 extern int __data_start;
1597 # pragma weak data_start
1598 extern int data_start;
1599 # define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
1602 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1603 /* Rld appears to allocate some memory with its own allocator, and */
1604 /* some through malloc, which might be redirected. To make this */
1605 /* work with collectable memory, we have to scan memory allocated */
1606 /* by rld's internal malloc. */
1607 # define USE_PROC_FOR_LIBRARIES
1610 # ifndef STACK_GROWS_UP
1611 # define STACK_GROWS_DOWN
1615 # define CPP_WORDSZ 32
1624 # define DATAEND (&end)
1627 # if defined(SVR4) && !defined(GETPAGESIZE)
1628 # include <unistd.h>
1629 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1632 # ifndef GETPAGESIZE
1633 # if defined(SUNOS5) || defined(IRIX5)
1634 # include <unistd.h>
1636 # define GETPAGESIZE() getpagesize()
1639 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1640 /* OS has SVR4 generic features. Probably others also qualify. */
1644 # if defined(SUNOS5) || defined(DRSNX)
1645 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1648 /* OS has SUNOS5 style signal handlers. */
1656 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1657 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1658 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1659 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1662 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1667 # undef DYNAMIC_LOADING
1672 # undef MPROTECT_VDB
1677 /* Postponed for now. */
1679 # undef MPROTECT_VDB
1682 # ifdef SMALL_CONFIG
1683 /* Presumably not worth the space it takes. */
1685 # undef MPROTECT_VDB
1689 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1692 # ifdef PARALLEL_MARK
1693 # undef MPROTECT_VDB /* For now. */
1696 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1697 # define DEFAULT_VDB
1701 # define PREFETCH(x)
1702 # define NO_PREFETCH
1705 # ifndef PREFETCH_FOR_WRITE
1706 # define PREFETCH_FOR_WRITE(x)
1707 # define NO_PREFETCH_FOR_WRITE
1710 # ifndef CACHE_LINE_SIZE
1711 # define CACHE_LINE_SIZE 32 /* Wild guess */
1714 # ifndef CLEAR_DOUBLE
1715 # define CLEAR_DOUBLE(x) \
1716 ((word*)x)[0] = 0; \
1718 # endif /* CLEAR_DOUBLE */
1720 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1721 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1722 # define GC_SOLARIS_THREADS
1725 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1726 --> inconsistent configuration
1728 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1729 --> inconsistent configuration
1731 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1732 --> inconsistent configuration
1734 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1735 --> inconsistent configuration
1737 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1738 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1739 /* the necessary code is mostly there, but nobody has actually made */
1740 /* sure the right combination of pieces is compiled in, etc. */
1741 --> inconsistent configuration
1744 # if defined(PCR) || defined(SRC_M3) || \
1745 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1746 defined(GC_PTHREADS)
1750 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1751 || defined(LINT) || defined(MSWINCE) \
1752 || (defined(I386) && defined(__LCC__))
1753 /* Use setjmp based hack to mark from callee-save registers. */
1754 /* The define should move to the individual platform */
1756 # define USE_GENERIC_PUSH_REGS
1760 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1761 /* include assembly code to do it well. */
1764 /* Can we save call chain in objects for debugging? */
1765 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1766 /* to reasonable values for the platform. */
1767 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1768 /* build time, though we feel free to adjust it slightly. */
1769 /* Define NEED_CALLINFO if we either save the call stack or */
1770 /* GC_ADD_CALLER is defined. */
1772 # include <features.h>
1773 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1774 # define HAVE_BUILTIN_BACKTRACE
1779 # define CAN_SAVE_CALL_STACKS
1780 # define CAN_SAVE_CALL_ARGS
1782 #if defined(I386) && defined(LINUX)
1783 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1784 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1785 # define CAN_SAVE_CALL_STACKS
1786 # define CAN_SAVE_CALL_ARGS
1788 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1789 # define CAN_SAVE_CALL_STACKS
1792 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1793 && defined(CAN_SAVE_CALL_STACKS)
1794 # define SAVE_CALL_CHAIN
1796 # ifdef SAVE_CALL_CHAIN
1797 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1798 # define NARGS SAVE_CALL_NARGS
1800 # define NARGS 0 /* Number of arguments to save for each call. */
1803 # ifdef SAVE_CALL_CHAIN
1804 # ifndef SAVE_CALL_COUNT
1805 # define NFRAMES 6 /* Number of frames to save. Even for */
1806 /* alignment reasons. */
1808 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1810 # define NEED_CALLINFO
1811 # endif /* SAVE_CALL_CHAIN */
1812 # ifdef GC_ADD_CALLER
1815 # define NEED_CALLINFO
1818 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1819 # define DBG_HDRS_ALL
1822 # endif /* GCCONFIG_H */