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(__XSCALE__)
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(__arm32__)
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)
99 # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
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 # if defined(__NetBSD__) && defined(__MIPSEL__)
113 # define mach_type_known
115 # if defined(sequent) && (defined(i386) || defined(__i386__))
118 # define mach_type_known
120 # if defined(sun) && (defined(i386) || defined(__i386__))
123 # define mach_type_known
125 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
128 # define mach_type_known
132 # define mach_type_known
134 # if defined(sun) && (defined(sparc) || defined(__sparc))
136 /* Test for SunOS 5.x */
143 # define mach_type_known
145 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
146 && !defined(__OpenBSD__) && !(__NetBSD__)
149 # define mach_type_known
153 # define mach_type_known
155 # if defined(__NetBSD__) && defined(__sparc__)
157 # define mach_type_known
159 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
160 /* The above test may need refinement */
162 # if defined(_SCO_ELF)
167 # define mach_type_known
169 # if defined(_AUX_SOURCE)
172 # define mach_type_known
174 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
175 || defined(hppa) || defined(__hppa__)
180 # define mach_type_known
182 # if defined(__ia64) && defined(_HPUX_SOURCE)
185 # define mach_type_known
187 # if defined(__BEOS__) && defined(_X86_)
190 # define mach_type_known
192 # if defined(LINUX) && (defined(i386) || defined(__i386__))
194 # define mach_type_known
196 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
198 # define mach_type_known
200 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
202 # define mach_type_known
204 # if defined(LINUX) && defined(__mc68000__)
206 # define mach_type_known
208 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
210 # define mach_type_known
212 # if defined(LINUX) && defined(__arm__)
214 # define mach_type_known
216 # if defined(LINUX) && defined(__sh__)
218 # define mach_type_known
220 # if defined(__alpha) || defined(__alpha__)
222 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
223 # define OSF1 /* a.k.a Digital Unix */
225 # define mach_type_known
227 # if defined(_AMIGA) && !defined(AMIGA)
232 # define mach_type_known
234 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
237 # define mach_type_known
239 # if defined(__MWERKS__) && defined(__powerc)
242 # define mach_type_known
244 # if defined(macosx) || \
245 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
248 # define mach_type_known
250 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
253 --> Not really supported, but at least we recognize it.
255 # if defined(NeXT) && defined(mc68000)
258 # define mach_type_known
260 # if defined(NeXT) && (defined(i386) || defined(__i386__))
263 # define mach_type_known
265 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
268 # define mach_type_known
270 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
272 # define mach_type_known
274 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
276 # define mach_type_known
278 # if defined(bsdi) && (defined(i386) || defined(__i386__))
281 # define mach_type_known
283 # if !defined(mach_type_known) && defined(__386BSD__)
286 # define mach_type_known
288 # if defined(_CX_UX) && defined(_M88K)
291 # define mach_type_known
296 # define mach_type_known
298 # if defined(_WIN32_WCE)
299 /* SH3, SH4, MIPS already defined for corresponding architectures */
300 # if defined(SH3) || defined(SH4)
310 # define mach_type_known
312 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
313 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
315 # define MSWIN32 /* or Win32s */
316 # define mach_type_known
319 # if defined(__DJGPP__)
322 # define DJGPP /* MSDOS running the DJGPP port of GCC */
324 # define mach_type_known
326 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
329 # define mach_type_known
331 # if defined(__MINGW32__)
334 # define mach_type_known
336 # if defined(__BORLANDC__)
339 # define mach_type_known
341 # if defined(_UTS) && !defined(mach_type_known)
344 # define mach_type_known
348 # define mach_type_known
350 # if defined(__embedded__) && defined(PPC)
353 # define mach_type_known
356 # if defined(__WATCOMC__) && defined(__386__)
358 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
359 # if defined(__OS2__)
362 # if defined(__WINDOWS_386__) || defined(__NT__)
369 # define mach_type_known
371 # if defined(__s390__) && defined(LINUX)
373 # define mach_type_known
375 # if defined(__GNU__)
376 # if defined(__i386__)
377 /* The Debian Hurd running on generic PC */
380 # define mach_type_known
384 /* Feel free to add more clauses here */
386 /* Or manually define the machine type here. A machine type is */
387 /* characterized by the architecture. Some */
388 /* machine types are further subdivided by OS. */
389 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
390 /* Note that SGI IRIX is treated identically to RISCOS. */
391 /* SYSV on an M68K actually means A/UX. */
392 /* The distinction in these cases is usually the stack starting address */
393 # ifndef mach_type_known
394 --> unknown machine type
396 /* Mapping is: M68K ==> Motorola 680X0 */
397 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
398 /* MACOS and AMIGA variants) */
399 /* I386 ==> Intel 386 */
400 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
401 /* FREEBSD, THREE86BSD, MSWIN32, */
402 /* BSDI,SUNOS5, NEXT, other variants) */
403 /* NS32K ==> Encore Multimax */
404 /* MIPS ==> R2000 or R3000 */
405 /* (RISCOS, ULTRIX variants) */
406 /* VAX ==> DEC VAX */
407 /* (BSD, ULTRIX variants) */
408 /* RS6000 ==> IBM RS/6000 AIX3.X */
409 /* RT ==> IBM PC/RT */
410 /* HP_PA ==> HP9000/700 & /800 */
412 /* SPARC ==> SPARC v7/v8/v9 */
413 /* (SUNOS4, SUNOS5, LINUX, */
414 /* DRSNX variants) */
415 /* ALPHA ==> DEC Alpha */
416 /* (OSF1 and LINUX variants) */
417 /* M88K ==> Motorola 88XX0 */
418 /* (CX_UX and DGUX) */
419 /* S370 ==> 370-like machine */
420 /* running Amdahl UTS4 */
421 /* or a 390 running LINUX */
422 /* ARM32 ==> Intel StrongARM */
423 /* IA64 ==> Intel IPF */
425 /* (LINUX and HPUX) */
426 /* IA64_32 ==> IA64 w/32 bit ABI */
428 /* SH ==> Hitachi SuperH */
429 /* (LINUX & MSWINCE) */
433 * For each architecture and OS, the following need to be defined:
435 * CPP_WORD_SZ is a simple integer constant representing the word size.
436 * in bits. We assume byte addressibility, where a byte has 8 bits.
437 * We also assume CPP_WORD_SZ is either 32 or 64.
438 * (We care about the length of pointers, not hardware
439 * bus widths. Thus a 64 bit processor with a C compiler that uses
440 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
442 * MACH_TYPE is a string representation of the machine type.
443 * OS_TYPE is analogous for the OS.
445 * ALIGNMENT is the largest N, such that
446 * all pointer are guaranteed to be aligned on N byte boundaries.
447 * defining it to be 1 will always work, but perform poorly.
449 * DATASTART is the beginning of the data segment.
450 * On UNIX systems, the collector will scan the area between DATASTART
451 * and DATAEND for root pointers.
453 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
454 * RTH suggests gaining access to linker script synth'd values with
455 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
457 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
460 * STACKBOTTOM is the cool end of the stack, which is usually the
461 * highest address in the stack.
462 * Under PCR or OS/2, we have other ways of finding thread stacks.
463 * For each machine, the following should:
464 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
465 * 2) define exactly one of
466 * STACKBOTTOM (should be defined to be an expression)
469 * If either of the last two macros are defined, then STACKBOTTOM is computed
470 * during collector startup using one of the following two heuristics:
471 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
472 * the next multiple of STACK_GRAN.
473 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
474 * in small steps (decrement if STACK_GROWS_UP), and read the value
475 * at each location. Remember the value when the first
476 * Segmentation violation or Bus error is signalled. Round that
477 * to the nearest plausible page boundary, and use that instead
480 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
481 * the value of environ is a pointer that can serve as STACKBOTTOM.
482 * I expect that HEURISTIC2 can be replaced by this approach, which
483 * interferes far less with debugging. However it has the disadvantage
484 * that it's confused by a putenv call before the collector is initialized.
485 * This could be dealt with by intercepting putenv ...
487 * If no expression for STACKBOTTOM can be found, and neither of the above
488 * heuristics are usable, the collector can still be used with all of the above
489 * undefined, provided one of the following is done:
490 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
491 * without reference to STACKBOTTOM. This is appropriate for use in
492 * conjunction with thread packages, since there will be multiple stacks.
493 * (Allocating thread stacks in the heap, and treating them as ordinary
494 * heap data objects is also possible as a last resort. However, this is
495 * likely to introduce significant amounts of excess storage retention
496 * unless the dead parts of the thread stacks are periodically cleared.)
497 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
498 * If the author of the client code controls the main program, this is
499 * easily accomplished by introducing a new main program, setting
500 * GC_stackbottom to the address of a local variable, and then calling
501 * the original main program. The new main program would read something
504 * # include "gc_private.h"
506 * main(argc, argv, envp)
508 * char **argv, **envp;
512 * GC_stackbottom = (ptr_t)(&dummy);
513 * return(real_main(argc, argv, envp));
517 * Each architecture may also define the style of virtual dirty bit
518 * implementation to be used:
519 * MPROTECT_VDB: Write protect the heap and catch faults.
520 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
522 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
523 * defined GC_register_dynamic_libraries() for the architecture.
525 * An architecture may define PREFETCH(x) to preload the cache with *x.
526 * This defaults to a no-op.
528 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
530 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
531 * clear the two words at GC_malloc-aligned address x. By default,
532 * word stores of 0 are used instead.
535 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
536 * to push the relevant registers onto the stack. This generally makes
537 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
539 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
540 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
541 # define HAVE_BUILTIN_UNWIND_INIT
544 # define STACK_GRAN 0x1000000
546 # define MACH_TYPE "M68K"
549 # define OS_TYPE "OPENBSD"
552 # define DATASTART ((ptr_t)(etext))
555 # define OS_TYPE "NETBSD"
558 # define DATASTART ((ptr_t)(etext))
561 # define OS_TYPE "LINUX"
562 # define STACKBOTTOM ((ptr_t)0xf0000000)
563 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
565 # define DYNAMIC_LOADING
566 # include <features.h>
567 # if defined(__GLIBC__)&& __GLIBC__>=2
568 # define LINUX_DATA_START
570 extern char **__environ;
571 # define DATASTART ((ptr_t)(&__environ))
572 /* hideous kludge: __environ is the first */
573 /* word in crt0.o, and delimits the start */
574 /* of the data segment, no matter which */
575 /* ld options were passed through. */
576 /* We could use _etext instead, but that */
577 /* would include .rodata, which may */
578 /* contain large read-only data tables */
579 /* that we'd rather not scan. */
580 # endif /* !GLIBC2 */
582 # define DATAEND (_end)
585 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
589 # define OS_TYPE "SUNOS4"
591 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
592 # define HEURISTIC1 /* differs */
593 # define DYNAMIC_LOADING
596 # define OS_TYPE "HP"
598 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
599 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
600 /* empirically determined. seems to work. */
602 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
605 # define OS_TYPE "SYSV"
607 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
609 +((word)etext & 0x1fff))
610 /* This only works for shared-text binaries with magic number 0413.
611 The other sorts of SysV binaries put the data at the end of the text,
612 in which case the default of etext would work. Unfortunately,
613 handling both would require having the magic-number available.
616 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
617 /* The stack starts at the top of memory, but */
618 /* 0x0 cannot be used as setjump_test complains */
619 /* that the stack direction is incorrect. Two */
620 /* bytes down from 0x0 should be safe enough. */
622 # include <sys/mmu.h>
623 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
626 # define OS_TYPE "AMIGA"
627 /* STACKBOTTOM and DATASTART handled specially */
629 # define DATAEND /* not needed */
630 # define GETPAGESIZE() 4096
636 # define OS_TYPE "MACOS"
637 /* see os_dep.c for details of global data segments. */
638 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
639 # define DATAEND /* not needed */
640 # define GETPAGESIZE() 4096
643 # define OS_TYPE "NEXT"
644 # define DATASTART ((ptr_t) get_etext())
645 # define STACKBOTTOM ((ptr_t) 0x4000000)
646 # define DATAEND /* not needed */
651 # define MACH_TYPE "POWERPC"
653 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
657 # define OS_TYPE "MACOS"
658 /* see os_dep.c for details of global data segments. */
659 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
660 # define DATAEND /* not needed */
663 # define ALIGNMENT 4 /* Guess. Can someone verify? */
664 /* This was 2, but that didn't sound right. */
665 # define OS_TYPE "LINUX"
667 # define DYNAMIC_LOADING
669 # define STACK_GRAN 0x10000000
670 /* Stack usually starts at 0x80000000 */
671 # define LINUX_DATA_START
673 # define DATAEND (_end)
676 /* There are reasons to suspect this may not be reliable. */
678 # define OS_TYPE "MACOSX"
679 # define DATASTART ((ptr_t) get_etext())
680 # define STACKBOTTOM ((ptr_t) 0xc0000000)
681 # define DATAEND /* not needed */
682 # define MPROTECT_VDB
684 # define GETPAGESIZE() getpagesize()
688 # define OS_TYPE "NETBSD"
691 # define DATASTART GC_data_start
692 # define DYNAMIC_LOADING
696 # define OS_TYPE "NOSYS"
697 extern void __end[], __dso_handle[];
698 # define DATASTART (__dso_handle) /* OK, that's ugly. */
699 # define DATAEND (__end)
700 /* Stack starts at 0xE0000000 for the simulator. */
702 # define STACK_GRAN 0x10000000
708 # define MACH_TYPE "VAX"
709 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
711 # define DATASTART ((ptr_t)(etext))
713 # define OS_TYPE "BSD"
715 /* HEURISTIC2 may be OK, but it's hard to test. */
718 # define OS_TYPE "ULTRIX"
719 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
724 # define MACH_TYPE "RT"
726 # define DATASTART ((ptr_t) 0x10000000)
727 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
731 # define MACH_TYPE "SPARC"
732 # if defined(__arch64__) || defined(__sparcv9)
734 # define CPP_WORDSZ 64
735 # define ELF_CLASS ELFCLASS64
737 # define ALIGNMENT 4 /* Required by hardware */
738 # define CPP_WORDSZ 32
740 # define ALIGN_DOUBLE
742 # define OS_TYPE "SUNOS5"
745 extern char * GC_SysVGetDataStart();
746 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
747 # define DATAEND (_end)
748 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
750 /* Otherwise we now use calloc. Mmap may result in the */
751 /* heap interleaved with thread stacks, which can result in */
752 /* excessive blacklisting. Sbrk is unusable since it */
753 /* doesn't interact correctly with the system malloc. */
756 # define HEAP_START (ptr_t)0x40000000
758 # define HEAP_START DATAEND
761 /* HEURISTIC1 reportedly no longer works under 2.7. */
762 /* HEURISTIC2 probably works, but this appears to be preferable. */
763 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
764 /* installations that's undefined. We work around this with a */
766 # include <sys/vmparam.h>
768 /* This should work everywhere, but doesn't. */
769 # define STACKBOTTOM USRSTACK
774 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
775 /* getpagesize() appeared to be missing from at least one */
776 /* Solaris 5.4 installation. Weird. */
777 # if CPP_WORDSZ == 32
778 # define DYNAMIC_LOADING
782 # define OS_TYPE "SUNOS4"
783 /* [If you have a weak stomach, don't read this.] */
784 /* We would like to use: */
785 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
786 /* This fails occasionally, due to an ancient, but very */
787 /* persistent ld bug. etext is set 32 bytes too high. */
788 /* We instead read the text segment size from the a.out */
789 /* header, which happens to be mapped into our address space */
790 /* at the start of the text segment. The detective work here */
791 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
792 /* Serpette of INRIA. */
793 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
794 # define TEXTSTART 0x2000
795 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
796 # define MPROTECT_VDB
798 # define DYNAMIC_LOADING
801 # define OS_TYPE "DRSNX"
802 extern char * GC_SysVGetDataStart();
804 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
805 # define MPROTECT_VDB
806 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
807 # define DYNAMIC_LOADING
810 # define OS_TYPE "LINUX"
812 # define DYNAMIC_LOADING
814 Linux Sparc/a.out not supported
818 # define DATAEND (_end)
821 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
822 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
824 # define STACKBOTTOM ((ptr_t) 0xf0000000)
825 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
829 # define OS_TYPE "OPENBSD"
830 # define STACKBOTTOM ((ptr_t) 0xf8000000)
832 # define DATASTART ((ptr_t)(etext))
835 # define OS_TYPE "NETBSD"
838 # define DATASTART GC_data_start
839 # define DYNAMIC_LOADING
842 # define DATASTART ((ptr_t)(etext))
848 # define MACH_TYPE "I386"
849 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
850 /* except Borland. The -a4 option fixes */
852 /* Ivan Demakov: For Watcom the option is -zp4. */
853 # ifndef SMALL_CONFIG
854 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
855 /* improvement on Pentiums. */
857 # ifdef HAVE_BUILTIN_UNWIND_INIT
858 # define USE_GENERIC_PUSH_REGS
861 # define OS_TYPE "SEQUENT"
863 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
864 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
867 # define OS_TYPE "BEOS"
869 # define GETPAGESIZE() B_PAGE_SIZE
871 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
874 # define OS_TYPE "SUNOS5"
875 extern int _etext[], _end[];
876 extern char * GC_SysVGetDataStart();
877 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
878 # define DATAEND (_end)
879 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
880 /* but reportedly breaks under 2.8. It appears that the stack */
881 /* base is a property of the executable, so this should not break */
882 /* old executables. */
883 /* HEURISTIC2 probably works, but this appears to be preferable. */
885 # define STACKBOTTOM USRSTACK
886 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
887 /* It appears to be fixed in 2.8 and 2.9. */
888 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
891 # define DYNAMIC_LOADING
892 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
894 /* Otherwise we now use calloc. Mmap may result in the */
895 /* heap interleaved with thread stacks, which can result in */
896 /* excessive blacklisting. Sbrk is unusable since it */
897 /* doesn't interact correctly with the system malloc. */
900 # define HEAP_START (ptr_t)0x40000000
902 # define HEAP_START DATAEND
906 # define OS_TYPE "SCO"
908 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
910 +((word)etext & 0xfff))
911 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
914 # define OS_TYPE "SCO_ELF"
916 # define DATASTART ((ptr_t)(etext))
917 # define STACKBOTTOM ((ptr_t) 0x08048000)
918 # define DYNAMIC_LOADING
919 # define ELF_CLASS ELFCLASS32
923 /* The Intel compiler doesn't like inline assembly */
924 # define USE_GENERIC_PUSH_REGS
926 # define OS_TYPE "LINUX"
927 # define LINUX_STACKBOTTOM
931 # define STACK_GRAN 0x10000000
932 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
933 /* different kernel configurations. In particular, systems */
934 /* with 2GB physical memory will usually move the user */
935 /* address space limit, and hence initial SP to 0x80000000. */
937 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
938 # define MPROTECT_VDB
940 /* We seem to get random errors in incremental mode, */
941 /* possibly because Linux threads is itself a malloc client */
942 /* and can't deal with the signals. */
945 # define DYNAMIC_LOADING
946 # ifdef UNDEFINED /* includes ro data */
948 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
950 # include <features.h>
951 # if defined(__GLIBC__) && __GLIBC__ >= 2
952 # define LINUX_DATA_START
954 extern char **__environ;
955 # define DATASTART ((ptr_t)(&__environ))
956 /* hideous kludge: __environ is the first */
957 /* word in crt0.o, and delimits the start */
958 /* of the data segment, no matter which */
959 /* ld options were passed through. */
960 /* We could use _etext instead, but that */
961 /* would include .rodata, which may */
962 /* contain large read-only data tables */
963 /* that we'd rather not scan. */
966 # define DATAEND (_end)
969 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
971 # ifdef USE_I686_PREFETCH
972 # define PREFETCH(x) \
973 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
974 /* Empirically prefetcht0 is much more effective at reducing */
975 /* cache miss stalls for the targetted load instructions. But it */
976 /* seems to interfere enough with other cache traffic that the net */
977 /* result is worse than prefetchnta. */
979 /* Using prefetches for write seems to have a slight negative */
980 /* impact on performance, at least for a PIII/500. */
981 # define PREFETCH_FOR_WRITE(x) \
982 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
985 # ifdef USE_3DNOW_PREFETCH
986 # define PREFETCH(x) \
987 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
988 # define PREFETCH_FOR_WRITE(x) \
989 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
993 # define OS_TYPE "CYGWIN32"
994 extern int _data_start__[];
995 extern int _data_end__[];
996 extern int _bss_start__[];
997 extern int _bss_end__[];
998 /* For binutils 2.9.1, we have */
999 /* DATASTART = _data_start__ */
1000 /* DATAEND = _bss_end__ */
1001 /* whereas for some earlier versions it was */
1002 /* DATASTART = _bss_start__ */
1003 /* DATAEND = _data_end__ */
1004 /* To get it right for both, we take the */
1005 /* minumum/maximum of the two. */
1006 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1007 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1008 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1009 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1011 # define STACK_GRAN 0x10000
1015 # define OS_TYPE "OS2"
1016 /* STACKBOTTOM and DATASTART are handled specially in */
1017 /* os_dep.c. OS2 actually has the right */
1019 # define DATAEND /* not needed */
1020 # define USE_GENERIC_PUSH_REGS
1023 # define OS_TYPE "MSWIN32"
1024 /* STACKBOTTOM and DATASTART are handled specially in */
1026 # ifndef __WATCOMC__
1027 # define MPROTECT_VDB
1029 # define DATAEND /* not needed */
1032 # define OS_TYPE "MSWINCE"
1033 # define DATAEND /* not needed */
1036 # define OS_TYPE "DJGPP"
1037 # include "stubinfo.h"
1040 extern int __djgpp_stack_limit;
1041 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1042 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1044 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1045 /* This may not be right. */
1048 # define OS_TYPE "OPENBSD"
1051 # define OS_TYPE "FREEBSD"
1052 # ifndef GC_FREEBSD_THREADS
1053 # define MPROTECT_VDB
1055 # define SIG_SUSPEND SIGUSR1
1056 # define SIG_THR_RESTART SIGUSR2
1057 # define FREEBSD_STACKBOTTOM
1059 # define DYNAMIC_LOADING
1061 extern char etext[];
1062 # define DATASTART ((ptr_t)(etext))
1065 # define OS_TYPE "NETBSD"
1068 # define OS_TYPE "THREE86BSD"
1071 # define OS_TYPE "BSDI"
1073 # if defined(OPENBSD) || defined(NETBSD) \
1074 || defined(THREE86BSD) || defined(BSDI)
1076 extern char etext[];
1077 # define DATASTART ((ptr_t)(etext))
1080 # define OS_TYPE "NEXT"
1081 # define DATASTART ((ptr_t) get_etext())
1082 # define STACKBOTTOM ((ptr_t)0xc0000000)
1083 # define DATAEND /* not needed */
1086 # define OS_TYPE "DOS4GW"
1087 extern long __nullarea;
1089 extern char *_STACKTOP;
1090 /* Depending on calling conventions Watcom C either precedes
1091 or does not precedes with undescore names of C-variables.
1092 Make sure startup code variables always have the same names. */
1093 #pragma aux __nullarea "*";
1094 #pragma aux _end "*";
1095 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1096 /* confused? me too. */
1097 # define DATASTART ((ptr_t) &__nullarea)
1098 # define DATAEND ((ptr_t) &_end)
1101 # define OS_TYPE "HURD"
1102 # define STACK_GROWS_DOWN
1104 extern int __data_start[];
1105 # define DATASTART ( (ptr_t) (__data_start))
1107 # define DATAEND ( (ptr_t) (_end))
1108 /* # define MPROTECT_VDB Not quite working yet? */
1109 # define DYNAMIC_LOADING
1114 # define MACH_TYPE "NS32K"
1115 # define ALIGNMENT 4
1116 extern char **environ;
1117 # define DATASTART ((ptr_t)(&environ))
1118 /* hideous kludge: environ is the first */
1119 /* word in crt0.o, and delimits the start */
1120 /* of the data segment, no matter which */
1121 /* ld options were passed through. */
1122 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1126 # define MACH_TYPE "MIPS"
1128 /* This was developed for a linuxce style platform. Probably */
1129 /* needs to be tweaked for workstation class machines. */
1130 # define OS_TYPE "LINUX"
1131 extern int __data_start[];
1132 # define DATASTART ((ptr_t)(__data_start))
1133 # define ALIGNMENT 4
1134 # define USE_GENERIC_PUSH_REGS
1135 # define STACKBOTTOM ((ptr_t)0x7fff8000)
1136 /* Older toolchains may need 0x80000000. */
1137 /* In many cases, this should probably use LINUX_STACKBOTTOM */
1138 /* instead. But some kernel versions seem to give the wrong */
1139 /* value from /proc. */
1143 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1144 extern int _fdata[], _end[];
1145 # define DATASTART ((ptr_t)_fdata)
1146 # define DATAEND ((ptr_t)_end)
1147 # define CPP_WORDSZ _MIPS_SZPTR
1148 # define ALIGNMENT (_MIPS_SZPTR/8)
1150 extern int etext[], edata[], end[];
1151 extern int _DYNAMIC_LINKING[], _gp[];
1152 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1153 + ((word)etext & 0xffff)))
1154 # define DATAEND (edata)
1155 # define DATASTART2 (_DYNAMIC_LINKING \
1156 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1158 # define DATAEND2 (end)
1159 # define ALIGNMENT 4
1161 # define OS_TYPE "EWS4800"
1162 # define USE_GENERIC_PUSH_REGS 1
1166 # define DATASTART (ptr_t)0x10000000
1167 /* Could probably be slightly higher since */
1168 /* startup code allocates lots of stuff. */
1169 # define OS_TYPE "ULTRIX"
1170 # define ALIGNMENT 4
1174 # define DATASTART (ptr_t)0x10000000
1175 # define OS_TYPE "RISCOS"
1176 # define ALIGNMENT 4 /* Required by hardware */
1180 extern int _fdata[];
1181 # define DATASTART ((ptr_t)(_fdata))
1183 # define HEAP_START (ptr_t)0x30000000
1185 # define HEAP_START DATASTART
1187 /* Lowest plausible heap address. */
1188 /* In the MMAP case, we map there. */
1189 /* In either case it is used to identify */
1190 /* heap sections so they're not */
1191 /* considered as roots. */
1192 # define OS_TYPE "IRIX5"
1193 # define MPROTECT_VDB
1195 # define CPP_WORDSZ _MIPS_SZPTR
1196 # define ALIGNMENT (_MIPS_SZPTR/8)
1197 # if CPP_WORDSZ != 64
1198 # define ALIGN_DOUBLE
1201 # define ALIGNMENT 4
1202 # define ALIGN_DOUBLE
1204 # define DYNAMIC_LOADING
1207 # define OS_TYPE "MSWINCE"
1208 # define ALIGNMENT 4
1209 # define DATAEND /* not needed */
1211 # if defined(NETBSD)
1212 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1213 /* should be handled at the top of the file. */
1214 # define ALIGNMENT 4
1215 # define OS_TYPE "NETBSD"
1217 # define USE_GENERIC_PUSH_REGS
1220 # define DATASTART GC_data_start
1221 # define NEED_FIND_LIMIT
1222 # define DYNAMIC_LOADING
1224 # define DATASTART ((ptr_t) 0x10000000)
1225 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1231 # define MACH_TYPE "RS6000"
1233 # define ALIGNMENT 8
1234 # define CPP_WORDSZ 64
1236 # define ALIGNMENT 4
1237 # define CPP_WORDSZ 32
1239 extern int _data[], _end[];
1240 # define DATASTART ((ptr_t)((ulong)_data))
1241 # define DATAEND ((ptr_t)((ulong)_end))
1243 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1244 # define USE_GENERIC_PUSH_REGS
1245 # define DYNAMIC_LOADING
1246 /* For really old versions of AIX, this may have to be removed. */
1250 # define MACH_TYPE "HP_PA"
1252 # define CPP_WORDSZ 64
1253 # define ALIGNMENT 8
1255 # define CPP_WORDSZ 32
1256 # define ALIGNMENT 4
1257 # define ALIGN_DOUBLE
1259 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1260 # ifndef LINUX /* For now. */
1261 # define MPROTECT_VDB
1264 # define GENERIC_COMPARE_AND_SWAP
1265 /* No compare-and-swap instruction. Use pthread mutexes */
1266 /* when we absolutely have to. */
1267 # ifdef PARALLEL_MARK
1268 # define USE_MARK_BYTES
1269 /* Minimize compare-and-swap usage. */
1272 # define STACK_GROWS_UP
1274 # define OS_TYPE "HPUX"
1275 extern int __data_start[];
1276 # define DATASTART ((ptr_t)(__data_start))
1278 /* The following appears to work for 7xx systems running HP/UX */
1279 /* 9.xx Furthermore, it might result in much faster */
1280 /* collections than HEURISTIC2, which may involve scanning */
1281 /* segments that directly precede the stack. It is not the */
1282 /* default, since it may not work on older machine/OS */
1283 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1285 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1287 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1288 /* to this. Note that the GC must be initialized before the */
1289 /* first putenv call. */
1290 extern char ** environ;
1291 # define STACKBOTTOM ((ptr_t)environ)
1293 # define DYNAMIC_LOADING
1294 # include <unistd.h>
1295 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1297 # define PREFETCH(x) { \
1298 register long addr = (long)(x); \
1299 (void) _asm ("LDW", 0, 0, addr, 0); \
1304 # define OS_TYPE "LINUX"
1305 # define LINUX_STACKBOTTOM
1306 # define DYNAMIC_LOADING
1307 # define LINUX_DATA_START
1309 # define DATAEND (_end)
1314 # define MACH_TYPE "ALPHA"
1315 # define ALIGNMENT 8
1317 # define OS_TYPE "NETBSD"
1319 # define DATASTART GC_data_start
1320 # define ELFCLASS32 32
1321 # define ELFCLASS64 64
1322 # define ELF_CLASS ELFCLASS64
1323 # define CPP_WORDSZ 64
1324 # define DYNAMIC_LOADING
1327 # define OS_TYPE "OPENBSD"
1329 # define CPP_WORDSZ 64
1330 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1331 # define DATASTART GC_data_start
1332 # define ELFCLASS32 32
1333 # define ELFCLASS64 64
1334 # define ELF_CLASS ELFCLASS64
1335 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1336 # define DATASTART ((ptr_t) 0x140000000)
1340 # define OS_TYPE "FREEBSD"
1341 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1342 # define SIG_SUSPEND SIGUSR1
1343 # define SIG_THR_RESTART SIGUSR2
1344 # define FREEBSD_STACKBOTTOM
1346 # define DYNAMIC_LOADING
1348 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1349 extern char etext[];
1350 extern char edata[];
1352 # define NEED_FIND_LIMIT
1353 # define DATASTART ((ptr_t)(etext))
1354 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1355 # define DATASTART2 ((ptr_t)(edata))
1356 # define DATAEND2 ((ptr_t)(end))
1357 # define CPP_WORDSZ 64
1360 # define OS_TYPE "OSF1"
1361 # define DATASTART ((ptr_t) 0x140000000)
1363 # define DATAEND ((ptr_t) _end)
1364 extern char ** environ;
1365 /* round up from the value of environ to the nearest page boundary */
1366 /* Probably breaks if putenv is called before collector */
1367 /* initialization. */
1368 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1369 /* # define HEURISTIC2 */
1370 /* Normally HEURISTIC2 is too conervative, since */
1371 /* the text segment immediately follows the stack. */
1372 /* Hence we give an upper pound. */
1373 /* This is currently unused, since we disabled HEURISTIC2 */
1374 extern int __start[];
1375 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1376 # define CPP_WORDSZ 64
1377 # define MPROTECT_VDB
1378 # define DYNAMIC_LOADING
1381 # define OS_TYPE "LINUX"
1382 # define CPP_WORDSZ 64
1383 # define STACKBOTTOM ((ptr_t) 0x120000000)
1385 # define SEARCH_FOR_DATA_START
1386 # define DATASTART GC_data_start
1387 # define DYNAMIC_LOADING
1389 # define DATASTART ((ptr_t) 0x140000000)
1392 # define DATAEND (_end)
1393 # define MPROTECT_VDB
1394 /* Has only been superficially tested. May not */
1395 /* work on all versions. */
1400 # define MACH_TYPE "IA64"
1401 # define USE_GENERIC_PUSH_REGS
1402 /* We need to get preserved registers in addition to register */
1403 /* windows. That's easiest to do with setjmp. */
1404 # ifdef PARALLEL_MARK
1405 # define USE_MARK_BYTES
1406 /* Compare-and-exchange is too expensive to use for */
1407 /* setting mark bits. */
1411 # define CPP_WORDSZ 32
1412 # define ALIGN_DOUBLE
1413 /* Requires 8 byte alignment for malloc */
1414 # define ALIGNMENT 4
1419 # define CPP_WORDSZ 64
1420 # define ALIGN_DOUBLE
1421 /* Requires 16 byte alignment for malloc */
1422 # define ALIGNMENT 8
1424 # define OS_TYPE "HPUX"
1425 extern int __data_start[];
1426 # define DATASTART ((ptr_t)(__data_start))
1427 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1428 /* to this. Note that the GC must be initialized before the */
1429 /* first putenv call. */
1430 extern char ** environ;
1431 # define STACKBOTTOM ((ptr_t)environ)
1432 # define DYNAMIC_LOADING
1433 # include <unistd.h>
1434 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1435 /* The following was empirically determined, and is probably */
1436 /* not very robust. */
1437 /* Note that the backing store base seems to be at a nice */
1438 /* address minus one page. */
1439 # define BACKING_STORE_DISPLACEMENT 0x1000000
1440 # define BACKING_STORE_ALIGNMENT 0x1000
1441 # define BACKING_STORE_BASE \
1442 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1443 & ~(BACKING_STORE_ALIGNMENT - 1))
1446 # define CPP_WORDSZ 64
1447 # define ALIGN_DOUBLE
1448 /* Requires 16 byte alignment for malloc */
1449 # define ALIGNMENT 8
1450 # define OS_TYPE "LINUX"
1451 /* The following works on NUE and older kernels: */
1452 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1453 /* This does not work on NUE: */
1454 # define LINUX_STACKBOTTOM
1455 /* We also need the base address of the register stack */
1456 /* backing store. This is computed in */
1457 /* GC_linux_register_stack_base based on the following */
1459 # define BACKING_STORE_ALIGNMENT 0x100000
1460 # define BACKING_STORE_DISPLACEMENT 0x80000000
1461 extern char * GC_register_stackbottom;
1462 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1463 # define SEARCH_FOR_DATA_START
1464 # define DATASTART GC_data_start
1466 # define DYNAMIC_LOADING
1468 /* In the Intel compiler environment, we seem to end up with */
1469 /* statically linked executables and an undefined reference */
1472 # define MPROTECT_VDB
1473 /* Requires Linux 2.3.47 or later. */
1475 # define DATAEND (_end)
1477 # define PREFETCH(x) \
1478 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1479 # define PREFETCH_FOR_WRITE(x) \
1480 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1481 # define CLEAR_DOUBLE(x) \
1482 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1488 # define MACH_TYPE "M88K"
1489 # define ALIGNMENT 4
1490 # define ALIGN_DOUBLE
1493 # define OS_TYPE "CX_UX"
1494 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1497 # define OS_TYPE "DGUX"
1498 extern char * GC_SysVGetDataStart();
1499 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1501 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1505 # define MACH_TYPE "S370"
1506 # define ALIGNMENT 4 /* Required by hardware */
1507 # define USE_GENERIC_PUSH_REGS
1509 # define OS_TYPE "UTS4"
1511 extern int _etext[];
1513 extern char * GC_SysVGetDataStart();
1514 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1515 # define DATAEND (_end)
1519 # define OS_TYPE "LINUX"
1521 # define DYNAMIC_LOADING
1522 extern int __data_start[];
1523 # define DATASTART ((ptr_t)(__data_start))
1528 # define ALIGNMENT 4
1529 extern int _etext[];
1530 # define DATASTART ((ptr_t)(_etext))
1535 # define CPP_WORDSZ 32
1536 # define MACH_TYPE "ARM32"
1537 # define ALIGNMENT 4
1539 # define OS_TYPE "NETBSD"
1541 extern char etext[];
1542 # define DATASTART ((ptr_t)(etext))
1543 # define USE_GENERIC_PUSH_REGS
1546 # define OS_TYPE "LINUX"
1549 # define STACK_GRAN 0x10000000
1550 # define USE_GENERIC_PUSH_REGS
1552 # define DYNAMIC_LOADING
1553 # include <features.h>
1554 # if defined(__GLIBC__) && __GLIBC__ >= 2
1555 # define LINUX_DATA_START
1557 extern char **__environ;
1558 # define DATASTART ((ptr_t)(&__environ))
1559 /* hideous kludge: __environ is the first */
1560 /* word in crt0.o, and delimits the start */
1561 /* of the data segment, no matter which */
1562 /* ld options were passed through. */
1563 /* We could use _etext instead, but that */
1564 /* would include .rodata, which may */
1565 /* contain large read-only data tables */
1566 /* that we'd rather not scan. */
1569 # define DATAEND (_end)
1572 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1576 # define OS_TYPE "MSWINCE"
1577 # define DATAEND /* not needed */
1580 /* __data_start is usually defined in the target linker script. */
1581 extern int __data_start[];
1582 # define DATASTART (ptr_t)(__data_start)
1583 # define USE_GENERIC_PUSH_REGS
1584 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1585 extern void *__stack_base__;
1586 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1591 # define MACH_TYPE "SH"
1592 # define ALIGNMENT 4
1594 # define OS_TYPE "MSWINCE"
1595 # define DATAEND /* not needed */
1598 # define OS_TYPE "LINUX"
1599 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1600 # define USE_GENERIC_PUSH_REGS
1601 # define DYNAMIC_LOADING
1602 # define LINUX_DATA_START
1604 # define DATAEND (_end)
1609 # define MACH_TYPE "SH4"
1610 # define OS_TYPE "MSWINCE"
1611 # define ALIGNMENT 4
1612 # define DATAEND /* not needed */
1615 #ifdef LINUX_DATA_START
1616 /* Some Linux distributions arrange to define __data_start. Some */
1617 /* define data_start as a weak symbol. The latter is technically */
1618 /* broken, since the user program may define data_start, in which */
1619 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1620 /* We assume gcc. */
1621 # pragma weak __data_start
1622 extern int __data_start[];
1623 # pragma weak data_start
1624 extern int data_start[];
1625 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1628 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1629 /* Rld appears to allocate some memory with its own allocator, and */
1630 /* some through malloc, which might be redirected. To make this */
1631 /* work with collectable memory, we have to scan memory allocated */
1632 /* by rld's internal malloc. */
1633 # define USE_PROC_FOR_LIBRARIES
1636 # ifndef STACK_GROWS_UP
1637 # define STACK_GROWS_DOWN
1641 # define CPP_WORDSZ 32
1650 # define DATAEND (end)
1653 # if defined(SVR4) && !defined(GETPAGESIZE)
1654 # include <unistd.h>
1655 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1658 # ifndef GETPAGESIZE
1659 # if defined(SUNOS5) || defined(IRIX5)
1660 # include <unistd.h>
1662 # define GETPAGESIZE() getpagesize()
1665 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1666 /* OS has SVR4 generic features. Probably others also qualify. */
1670 # if defined(SUNOS5) || defined(DRSNX)
1671 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1674 /* OS has SUNOS5 style signal handlers. */
1682 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1683 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1684 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1685 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1688 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1693 # undef DYNAMIC_LOADING
1698 # undef MPROTECT_VDB
1703 /* Postponed for now. */
1705 # undef MPROTECT_VDB
1708 # ifdef SMALL_CONFIG
1709 /* Presumably not worth the space it takes. */
1711 # undef MPROTECT_VDB
1715 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1718 # ifdef PARALLEL_MARK
1719 # undef MPROTECT_VDB /* For now. */
1722 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1723 # define DEFAULT_VDB
1727 # define PREFETCH(x)
1728 # define NO_PREFETCH
1731 # ifndef PREFETCH_FOR_WRITE
1732 # define PREFETCH_FOR_WRITE(x)
1733 # define NO_PREFETCH_FOR_WRITE
1736 # ifndef CACHE_LINE_SIZE
1737 # define CACHE_LINE_SIZE 32 /* Wild guess */
1740 # ifndef CLEAR_DOUBLE
1741 # define CLEAR_DOUBLE(x) \
1742 ((word*)x)[0] = 0; \
1744 # endif /* CLEAR_DOUBLE */
1746 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1747 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1748 # define GC_SOLARIS_THREADS
1751 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1752 --> inconsistent configuration
1754 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1755 --> inconsistent configuration
1757 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1758 --> inconsistent configuration
1760 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1761 --> inconsistent configuration
1763 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1764 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1765 /* the necessary code is mostly there, but nobody has actually made */
1766 /* sure the right combination of pieces is compiled in, etc. */
1767 --> inconsistent configuration
1770 # if defined(PCR) || defined(SRC_M3) || \
1771 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1772 defined(GC_PTHREADS)
1776 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1777 || defined(LINT) || defined(MSWINCE) \
1778 || (defined(I386) && defined(__LCC__))
1779 /* Use setjmp based hack to mark from callee-save registers. */
1780 /* The define should move to the individual platform */
1782 # define USE_GENERIC_PUSH_REGS
1786 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1787 /* include assembly code to do it well. */
1790 /* Can we save call chain in objects for debugging? */
1791 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1792 /* to reasonable values for the platform. */
1793 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1794 /* build time, though we feel free to adjust it slightly. */
1795 /* Define NEED_CALLINFO if we either save the call stack or */
1796 /* GC_ADD_CALLER is defined. */
1798 # include <features.h>
1799 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1800 # define HAVE_BUILTIN_BACKTRACE
1805 # define CAN_SAVE_CALL_STACKS
1806 # define CAN_SAVE_CALL_ARGS
1808 #if defined(I386) && defined(LINUX)
1809 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1810 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1811 # define CAN_SAVE_CALL_STACKS
1812 # define CAN_SAVE_CALL_ARGS
1814 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1815 # define CAN_SAVE_CALL_STACKS
1818 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1819 && defined(CAN_SAVE_CALL_STACKS)
1820 # define SAVE_CALL_CHAIN
1822 # ifdef SAVE_CALL_CHAIN
1823 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1824 # define NARGS SAVE_CALL_NARGS
1826 # define NARGS 0 /* Number of arguments to save for each call. */
1829 # ifdef SAVE_CALL_CHAIN
1830 # ifndef SAVE_CALL_COUNT
1831 # define NFRAMES 6 /* Number of frames to save. Even for */
1832 /* alignment reasons. */
1834 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1836 # define NEED_CALLINFO
1837 # endif /* SAVE_CALL_CHAIN */
1838 # ifdef GC_ADD_CALLER
1841 # define NEED_CALLINFO
1844 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1845 # define DBG_HDRS_ALL
1848 # endif /* GCCONFIG_H */