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;'' .
456 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
457 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
458 * without any special options.
460 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
463 * STACKBOTTOM is the cool end of the stack, which is usually the
464 * highest address in the stack.
465 * Under PCR or OS/2, we have other ways of finding thread stacks.
466 * For each machine, the following should:
467 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
468 * 2) define exactly one of
469 * STACKBOTTOM (should be defined to be an expression)
472 * If either of the last two macros are defined, then STACKBOTTOM is computed
473 * during collector startup using one of the following two heuristics:
474 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
475 * the next multiple of STACK_GRAN.
476 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
477 * in small steps (decrement if STACK_GROWS_UP), and read the value
478 * at each location. Remember the value when the first
479 * Segmentation violation or Bus error is signalled. Round that
480 * to the nearest plausible page boundary, and use that instead
483 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
484 * the value of environ is a pointer that can serve as STACKBOTTOM.
485 * I expect that HEURISTIC2 can be replaced by this approach, which
486 * interferes far less with debugging. However it has the disadvantage
487 * that it's confused by a putenv call before the collector is initialized.
488 * This could be dealt with by intercepting putenv ...
490 * If no expression for STACKBOTTOM can be found, and neither of the above
491 * heuristics are usable, the collector can still be used with all of the above
492 * undefined, provided one of the following is done:
493 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
494 * without reference to STACKBOTTOM. This is appropriate for use in
495 * conjunction with thread packages, since there will be multiple stacks.
496 * (Allocating thread stacks in the heap, and treating them as ordinary
497 * heap data objects is also possible as a last resort. However, this is
498 * likely to introduce significant amounts of excess storage retention
499 * unless the dead parts of the thread stacks are periodically cleared.)
500 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
501 * If the author of the client code controls the main program, this is
502 * easily accomplished by introducing a new main program, setting
503 * GC_stackbottom to the address of a local variable, and then calling
504 * the original main program. The new main program would read something
507 * # include "gc_private.h"
509 * main(argc, argv, envp)
511 * char **argv, **envp;
515 * GC_stackbottom = (ptr_t)(&dummy);
516 * return(real_main(argc, argv, envp));
520 * Each architecture may also define the style of virtual dirty bit
521 * implementation to be used:
522 * MPROTECT_VDB: Write protect the heap and catch faults.
523 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
525 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
526 * defined GC_register_dynamic_libraries() for the architecture.
528 * An architecture may define PREFETCH(x) to preload the cache with *x.
529 * This defaults to a no-op.
531 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
533 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
534 * clear the two words at GC_malloc-aligned address x. By default,
535 * word stores of 0 are used instead.
538 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
539 * to push the relevant registers onto the stack. This generally makes
540 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
542 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
543 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
544 # define HAVE_BUILTIN_UNWIND_INIT
547 # define STACK_GRAN 0x1000000
549 # define MACH_TYPE "M68K"
552 # define OS_TYPE "OPENBSD"
555 # define DATASTART ((ptr_t)(etext))
558 # define OS_TYPE "NETBSD"
561 # define DATASTART ((ptr_t)(etext))
564 # define OS_TYPE "LINUX"
565 # define STACKBOTTOM ((ptr_t)0xf0000000)
566 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
568 # define DYNAMIC_LOADING
569 # include <features.h>
570 # if defined(__GLIBC__)&& __GLIBC__>=2
571 # define LINUX_DATA_START
573 extern char **__environ;
574 # define DATASTART ((ptr_t)(&__environ))
575 /* hideous kludge: __environ is the first */
576 /* word in crt0.o, and delimits the start */
577 /* of the data segment, no matter which */
578 /* ld options were passed through. */
579 /* We could use _etext instead, but that */
580 /* would include .rodata, which may */
581 /* contain large read-only data tables */
582 /* that we'd rather not scan. */
583 # endif /* !GLIBC2 */
585 # define DATAEND (_end)
588 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
592 # define OS_TYPE "SUNOS4"
594 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
595 # define HEURISTIC1 /* differs */
596 # define DYNAMIC_LOADING
599 # define OS_TYPE "HP"
601 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
602 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
603 /* empirically determined. seems to work. */
605 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
608 # define OS_TYPE "SYSV"
610 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
612 +((word)etext & 0x1fff))
613 /* This only works for shared-text binaries with magic number 0413.
614 The other sorts of SysV binaries put the data at the end of the text,
615 in which case the default of etext would work. Unfortunately,
616 handling both would require having the magic-number available.
619 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
620 /* The stack starts at the top of memory, but */
621 /* 0x0 cannot be used as setjump_test complains */
622 /* that the stack direction is incorrect. Two */
623 /* bytes down from 0x0 should be safe enough. */
625 # include <sys/mmu.h>
626 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
629 # define OS_TYPE "AMIGA"
630 /* STACKBOTTOM and DATASTART handled specially */
632 # define DATAEND /* not needed */
633 # define GETPAGESIZE() 4096
639 # define OS_TYPE "MACOS"
640 /* see os_dep.c for details of global data segments. */
641 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
642 # define DATAEND /* not needed */
643 # define GETPAGESIZE() 4096
646 # define OS_TYPE "NEXT"
647 # define DATASTART ((ptr_t) get_etext())
648 # define STACKBOTTOM ((ptr_t) 0x4000000)
649 # define DATAEND /* not needed */
654 # define MACH_TYPE "POWERPC"
656 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
660 # define OS_TYPE "MACOS"
661 /* see os_dep.c for details of global data segments. */
662 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
663 # define DATAEND /* not needed */
666 # define ALIGNMENT 4 /* Guess. Can someone verify? */
667 /* This was 2, but that didn't sound right. */
668 # define OS_TYPE "LINUX"
670 # define DYNAMIC_LOADING
672 # define STACK_GRAN 0x10000000
673 /* Stack usually starts at 0x80000000 */
674 # define LINUX_DATA_START
676 # define DATAEND (_end)
679 /* There are reasons to suspect this may not be reliable. */
681 # define OS_TYPE "MACOSX"
682 # define DATASTART ((ptr_t) get_etext())
683 # define STACKBOTTOM ((ptr_t) 0xc0000000)
684 # define DATAEND /* not needed */
685 # define MPROTECT_VDB
687 # define GETPAGESIZE() getpagesize()
691 # define OS_TYPE "NETBSD"
694 # define DATASTART GC_data_start
695 # define DYNAMIC_LOADING
699 # define OS_TYPE "NOSYS"
700 extern void __end[], __dso_handle[];
701 # define DATASTART (__dso_handle) /* OK, that's ugly. */
702 # define DATAEND (__end)
703 /* Stack starts at 0xE0000000 for the simulator. */
705 # define STACK_GRAN 0x10000000
711 # define MACH_TYPE "VAX"
712 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
714 # define DATASTART ((ptr_t)(etext))
716 # define OS_TYPE "BSD"
718 /* HEURISTIC2 may be OK, but it's hard to test. */
721 # define OS_TYPE "ULTRIX"
722 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
727 # define MACH_TYPE "RT"
729 # define DATASTART ((ptr_t) 0x10000000)
730 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
734 # define MACH_TYPE "SPARC"
735 # if defined(__arch64__) || defined(__sparcv9)
737 # define CPP_WORDSZ 64
738 # define ELF_CLASS ELFCLASS64
740 # define ALIGNMENT 4 /* Required by hardware */
741 # define CPP_WORDSZ 32
743 # define ALIGN_DOUBLE
745 # define OS_TYPE "SUNOS5"
748 extern char * GC_SysVGetDataStart();
749 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
750 # define DATAEND (_end)
751 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
753 /* Otherwise we now use calloc. Mmap may result in the */
754 /* heap interleaved with thread stacks, which can result in */
755 /* excessive blacklisting. Sbrk is unusable since it */
756 /* doesn't interact correctly with the system malloc. */
759 # define HEAP_START (ptr_t)0x40000000
761 # define HEAP_START DATAEND
764 /* HEURISTIC1 reportedly no longer works under 2.7. */
765 /* HEURISTIC2 probably works, but this appears to be preferable. */
766 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
767 /* installations that's undefined. We work around this with a */
769 # include <sys/vmparam.h>
771 /* This should work everywhere, but doesn't. */
772 # define STACKBOTTOM USRSTACK
777 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
778 /* getpagesize() appeared to be missing from at least one */
779 /* Solaris 5.4 installation. Weird. */
780 # if CPP_WORDSZ == 32
781 # define DYNAMIC_LOADING
785 # define OS_TYPE "SUNOS4"
786 /* [If you have a weak stomach, don't read this.] */
787 /* We would like to use: */
788 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
789 /* This fails occasionally, due to an ancient, but very */
790 /* persistent ld bug. etext is set 32 bytes too high. */
791 /* We instead read the text segment size from the a.out */
792 /* header, which happens to be mapped into our address space */
793 /* at the start of the text segment. The detective work here */
794 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
795 /* Serpette of INRIA. */
796 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
797 # define TEXTSTART 0x2000
798 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
799 # define MPROTECT_VDB
801 # define DYNAMIC_LOADING
804 # define OS_TYPE "DRSNX"
805 extern char * GC_SysVGetDataStart();
807 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
808 # define MPROTECT_VDB
809 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
810 # define DYNAMIC_LOADING
813 # define OS_TYPE "LINUX"
815 # define DYNAMIC_LOADING
817 Linux Sparc/a.out not supported
821 # define DATAEND (_end)
823 # define LINUX_STACKBOTTOM
825 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
827 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
831 # define OS_TYPE "OPENBSD"
832 # define STACKBOTTOM ((ptr_t) 0xf8000000)
834 # define DATASTART ((ptr_t)(etext))
837 # define OS_TYPE "NETBSD"
840 # define DATASTART GC_data_start
841 # define DYNAMIC_LOADING
844 # define DATASTART ((ptr_t)(etext))
850 # define MACH_TYPE "I386"
851 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
852 /* except Borland. The -a4 option fixes */
854 /* Ivan Demakov: For Watcom the option is -zp4. */
855 # ifndef SMALL_CONFIG
856 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
857 /* improvement on Pentiums. */
859 # ifdef HAVE_BUILTIN_UNWIND_INIT
860 # define USE_GENERIC_PUSH_REGS
863 # define OS_TYPE "SEQUENT"
865 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
866 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
869 # define OS_TYPE "BEOS"
871 # define GETPAGESIZE() B_PAGE_SIZE
873 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
876 # define OS_TYPE "SUNOS5"
877 extern int _etext[], _end[];
878 extern char * GC_SysVGetDataStart();
879 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
880 # define DATAEND (_end)
881 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
882 /* but reportedly breaks under 2.8. It appears that the stack */
883 /* base is a property of the executable, so this should not break */
884 /* old executables. */
885 /* HEURISTIC2 probably works, but this appears to be preferable. */
887 # define STACKBOTTOM USRSTACK
888 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
889 /* It appears to be fixed in 2.8 and 2.9. */
890 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
893 # define DYNAMIC_LOADING
894 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
896 /* Otherwise we now use calloc. Mmap may result in the */
897 /* heap interleaved with thread stacks, which can result in */
898 /* excessive blacklisting. Sbrk is unusable since it */
899 /* doesn't interact correctly with the system malloc. */
902 # define HEAP_START (ptr_t)0x40000000
904 # define HEAP_START DATAEND
908 # define OS_TYPE "SCO"
910 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
912 +((word)etext & 0xfff))
913 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
916 # define OS_TYPE "SCO_ELF"
918 # define DATASTART ((ptr_t)(etext))
919 # define STACKBOTTOM ((ptr_t) 0x08048000)
920 # define DYNAMIC_LOADING
921 # define ELF_CLASS ELFCLASS32
925 /* The Intel compiler doesn't like inline assembly */
926 # define USE_GENERIC_PUSH_REGS
928 # define OS_TYPE "LINUX"
929 # define LINUX_STACKBOTTOM
933 # define STACK_GRAN 0x10000000
934 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
935 /* different kernel configurations. In particular, systems */
936 /* with 2GB physical memory will usually move the user */
937 /* address space limit, and hence initial SP to 0x80000000. */
939 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
940 # define MPROTECT_VDB
942 /* We seem to get random errors in incremental mode, */
943 /* possibly because Linux threads is itself a malloc client */
944 /* and can't deal with the signals. */
947 # define DYNAMIC_LOADING
948 # ifdef UNDEFINED /* includes ro data */
950 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
952 # include <features.h>
953 # if defined(__GLIBC__) && __GLIBC__ >= 2
954 # define LINUX_DATA_START
956 extern char **__environ;
957 # define DATASTART ((ptr_t)(&__environ))
958 /* hideous kludge: __environ is the first */
959 /* word in crt0.o, and delimits the start */
960 /* of the data segment, no matter which */
961 /* ld options were passed through. */
962 /* We could use _etext instead, but that */
963 /* would include .rodata, which may */
964 /* contain large read-only data tables */
965 /* that we'd rather not scan. */
968 # define DATAEND (_end)
971 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
973 # ifdef USE_I686_PREFETCH
974 # define PREFETCH(x) \
975 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
976 /* Empirically prefetcht0 is much more effective at reducing */
977 /* cache miss stalls for the targetted load instructions. But it */
978 /* seems to interfere enough with other cache traffic that the net */
979 /* result is worse than prefetchnta. */
981 /* Using prefetches for write seems to have a slight negative */
982 /* impact on performance, at least for a PIII/500. */
983 # define PREFETCH_FOR_WRITE(x) \
984 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
987 # ifdef USE_3DNOW_PREFETCH
988 # define PREFETCH(x) \
989 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
990 # define PREFETCH_FOR_WRITE(x) \
991 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
995 # define OS_TYPE "CYGWIN32"
996 extern int _data_start__[];
997 extern int _data_end__[];
998 extern int _bss_start__[];
999 extern int _bss_end__[];
1000 /* For binutils 2.9.1, we have */
1001 /* DATASTART = _data_start__ */
1002 /* DATAEND = _bss_end__ */
1003 /* whereas for some earlier versions it was */
1004 /* DATASTART = _bss_start__ */
1005 /* DATAEND = _data_end__ */
1006 /* To get it right for both, we take the */
1007 /* minumum/maximum of the two. */
1008 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1009 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1010 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1011 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1013 # define STACK_GRAN 0x10000
1017 # define OS_TYPE "OS2"
1018 /* STACKBOTTOM and DATASTART are handled specially in */
1019 /* os_dep.c. OS2 actually has the right */
1021 # define DATAEND /* not needed */
1022 # define USE_GENERIC_PUSH_REGS
1025 # define OS_TYPE "MSWIN32"
1026 /* STACKBOTTOM and DATASTART are handled specially in */
1028 # ifndef __WATCOMC__
1029 # define MPROTECT_VDB
1031 # define DATAEND /* not needed */
1034 # define OS_TYPE "MSWINCE"
1035 # define DATAEND /* not needed */
1038 # define OS_TYPE "DJGPP"
1039 # include "stubinfo.h"
1042 extern int __djgpp_stack_limit;
1043 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1044 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1046 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1047 /* This may not be right. */
1050 # define OS_TYPE "OPENBSD"
1053 # define OS_TYPE "FREEBSD"
1054 # ifndef GC_FREEBSD_THREADS
1055 # define MPROTECT_VDB
1057 # define SIG_SUSPEND SIGUSR1
1058 # define SIG_THR_RESTART SIGUSR2
1059 # define FREEBSD_STACKBOTTOM
1061 # define DYNAMIC_LOADING
1063 /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */
1064 extern char etext[];
1065 extern char edata[];
1067 # define NEED_FIND_LIMIT
1068 # define DATASTART ((ptr_t)(etext))
1069 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1070 # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2))
1071 # define DATASTART2 ((ptr_t)(edata))
1072 # define DATAEND2 ((ptr_t)(end))
1075 # define OS_TYPE "NETBSD"
1077 # define DYNAMIC_LOADING
1081 # define OS_TYPE "THREE86BSD"
1084 # define OS_TYPE "BSDI"
1086 # if defined(OPENBSD) || defined(NETBSD) \
1087 || defined(THREE86BSD) || defined(BSDI)
1089 extern char etext[];
1090 # define DATASTART ((ptr_t)(etext))
1093 # define OS_TYPE "NEXT"
1094 # define DATASTART ((ptr_t) get_etext())
1095 # define STACKBOTTOM ((ptr_t)0xc0000000)
1096 # define DATAEND /* not needed */
1099 # define OS_TYPE "DOS4GW"
1100 extern long __nullarea;
1102 extern char *_STACKTOP;
1103 /* Depending on calling conventions Watcom C either precedes
1104 or does not precedes with undescore names of C-variables.
1105 Make sure startup code variables always have the same names. */
1106 #pragma aux __nullarea "*";
1107 #pragma aux _end "*";
1108 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1109 /* confused? me too. */
1110 # define DATASTART ((ptr_t) &__nullarea)
1111 # define DATAEND ((ptr_t) &_end)
1114 # define OS_TYPE "HURD"
1115 # define STACK_GROWS_DOWN
1117 extern int __data_start[];
1118 # define DATASTART ( (ptr_t) (__data_start))
1120 # define DATAEND ( (ptr_t) (_end))
1121 /* # define MPROTECT_VDB Not quite working yet? */
1122 # define DYNAMIC_LOADING
1127 # define MACH_TYPE "NS32K"
1128 # define ALIGNMENT 4
1129 extern char **environ;
1130 # define DATASTART ((ptr_t)(&environ))
1131 /* hideous kludge: environ is the first */
1132 /* word in crt0.o, and delimits the start */
1133 /* of the data segment, no matter which */
1134 /* ld options were passed through. */
1135 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1139 # define MACH_TYPE "MIPS"
1141 /* This was developed for a linuxce style platform. Probably */
1142 /* needs to be tweaked for workstation class machines. */
1143 # define OS_TYPE "LINUX"
1144 extern int __data_start[];
1145 # define DATASTART ((ptr_t)(__data_start))
1146 # define ALIGNMENT 4
1147 # define USE_GENERIC_PUSH_REGS
1148 # define STACKBOTTOM ((ptr_t)0x7fff8000)
1149 /* Older toolchains may need 0x80000000. */
1150 /* In many cases, this should probably use LINUX_STACKBOTTOM */
1151 /* instead. But some kernel versions seem to give the wrong */
1152 /* value from /proc. */
1156 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1157 extern int _fdata[], _end[];
1158 # define DATASTART ((ptr_t)_fdata)
1159 # define DATAEND ((ptr_t)_end)
1160 # define CPP_WORDSZ _MIPS_SZPTR
1161 # define ALIGNMENT (_MIPS_SZPTR/8)
1163 extern int etext[], edata[], end[];
1164 extern int _DYNAMIC_LINKING[], _gp[];
1165 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1166 + ((word)etext & 0xffff)))
1167 # define DATAEND (edata)
1168 # define DATASTART2 (_DYNAMIC_LINKING \
1169 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1171 # define DATAEND2 (end)
1172 # define ALIGNMENT 4
1174 # define OS_TYPE "EWS4800"
1175 # define USE_GENERIC_PUSH_REGS 1
1179 # define DATASTART (ptr_t)0x10000000
1180 /* Could probably be slightly higher since */
1181 /* startup code allocates lots of stuff. */
1182 # define OS_TYPE "ULTRIX"
1183 # define ALIGNMENT 4
1187 # define DATASTART (ptr_t)0x10000000
1188 # define OS_TYPE "RISCOS"
1189 # define ALIGNMENT 4 /* Required by hardware */
1193 extern int _fdata[];
1194 # define DATASTART ((ptr_t)(_fdata))
1196 # define HEAP_START (ptr_t)0x30000000
1198 # define HEAP_START DATASTART
1200 /* Lowest plausible heap address. */
1201 /* In the MMAP case, we map there. */
1202 /* In either case it is used to identify */
1203 /* heap sections so they're not */
1204 /* considered as roots. */
1205 # define OS_TYPE "IRIX5"
1206 # define MPROTECT_VDB
1208 # define CPP_WORDSZ _MIPS_SZPTR
1209 # define ALIGNMENT (_MIPS_SZPTR/8)
1210 # if CPP_WORDSZ != 64
1211 # define ALIGN_DOUBLE
1214 # define ALIGNMENT 4
1215 # define ALIGN_DOUBLE
1217 # define DYNAMIC_LOADING
1220 # define OS_TYPE "MSWINCE"
1221 # define ALIGNMENT 4
1222 # define DATAEND /* not needed */
1224 # if defined(NETBSD)
1225 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1226 /* should be handled at the top of the file. */
1227 # define ALIGNMENT 4
1228 # define OS_TYPE "NETBSD"
1230 # define USE_GENERIC_PUSH_REGS
1233 # define DATASTART GC_data_start
1234 # define NEED_FIND_LIMIT
1235 # define DYNAMIC_LOADING
1237 # define DATASTART ((ptr_t) 0x10000000)
1238 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1244 # define MACH_TYPE "RS6000"
1246 # define ALIGNMENT 8
1247 # define CPP_WORDSZ 64
1249 # define ALIGNMENT 4
1250 # define CPP_WORDSZ 32
1252 extern int _data[], _end[];
1253 # define DATASTART ((ptr_t)((ulong)_data))
1254 # define DATAEND ((ptr_t)((ulong)_end))
1256 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1257 # define USE_GENERIC_PUSH_REGS
1258 # define DYNAMIC_LOADING
1259 /* For really old versions of AIX, this may have to be removed. */
1263 # define MACH_TYPE "HP_PA"
1265 # define CPP_WORDSZ 64
1266 # define ALIGNMENT 8
1268 # define CPP_WORDSZ 32
1269 # define ALIGNMENT 4
1270 # define ALIGN_DOUBLE
1272 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1273 # ifndef LINUX /* For now. */
1274 # define MPROTECT_VDB
1277 # define GENERIC_COMPARE_AND_SWAP
1278 /* No compare-and-swap instruction. Use pthread mutexes */
1279 /* when we absolutely have to. */
1280 # ifdef PARALLEL_MARK
1281 # define USE_MARK_BYTES
1282 /* Minimize compare-and-swap usage. */
1285 # define STACK_GROWS_UP
1287 # define OS_TYPE "HPUX"
1288 extern int __data_start[];
1289 # define DATASTART ((ptr_t)(__data_start))
1291 /* The following appears to work for 7xx systems running HP/UX */
1292 /* 9.xx Furthermore, it might result in much faster */
1293 /* collections than HEURISTIC2, which may involve scanning */
1294 /* segments that directly precede the stack. It is not the */
1295 /* default, since it may not work on older machine/OS */
1296 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1298 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1300 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1301 /* to this. Note that the GC must be initialized before the */
1302 /* first putenv call. */
1303 extern char ** environ;
1304 # define STACKBOTTOM ((ptr_t)environ)
1306 # define DYNAMIC_LOADING
1307 # include <unistd.h>
1308 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1310 # define PREFETCH(x) { \
1311 register long addr = (long)(x); \
1312 (void) _asm ("LDW", 0, 0, addr, 0); \
1317 # define OS_TYPE "LINUX"
1318 # define LINUX_STACKBOTTOM
1319 # define DYNAMIC_LOADING
1320 # define LINUX_DATA_START
1322 # define DATAEND (_end)
1327 # define MACH_TYPE "ALPHA"
1328 # define ALIGNMENT 8
1330 # define OS_TYPE "NETBSD"
1332 # define DATASTART GC_data_start
1333 # define ELFCLASS32 32
1334 # define ELFCLASS64 64
1335 # define ELF_CLASS ELFCLASS64
1336 # define CPP_WORDSZ 64
1337 # define DYNAMIC_LOADING
1340 # define OS_TYPE "OPENBSD"
1342 # define CPP_WORDSZ 64
1343 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1344 # define DATASTART GC_data_start
1345 # define ELFCLASS32 32
1346 # define ELFCLASS64 64
1347 # define ELF_CLASS ELFCLASS64
1348 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1349 # define DATASTART ((ptr_t) 0x140000000)
1353 # define OS_TYPE "FREEBSD"
1354 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1355 # define SIG_SUSPEND SIGUSR1
1356 # define SIG_THR_RESTART SIGUSR2
1357 # define FREEBSD_STACKBOTTOM
1359 # define DYNAMIC_LOADING
1361 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1362 extern char etext[];
1363 extern char edata[];
1365 # define NEED_FIND_LIMIT
1366 # define DATASTART ((ptr_t)(etext))
1367 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1368 # define DATASTART2 ((ptr_t)(edata))
1369 # define DATAEND2 ((ptr_t)(end))
1370 # define CPP_WORDSZ 64
1373 # define OS_TYPE "OSF1"
1374 # define DATASTART ((ptr_t) 0x140000000)
1376 # define DATAEND ((ptr_t) _end)
1377 extern char ** environ;
1378 /* round up from the value of environ to the nearest page boundary */
1379 /* Probably breaks if putenv is called before collector */
1380 /* initialization. */
1381 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1382 /* # define HEURISTIC2 */
1383 /* Normally HEURISTIC2 is too conervative, since */
1384 /* the text segment immediately follows the stack. */
1385 /* Hence we give an upper pound. */
1386 /* This is currently unused, since we disabled HEURISTIC2 */
1387 extern int __start[];
1388 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1389 # define CPP_WORDSZ 64
1390 # define MPROTECT_VDB
1391 # define DYNAMIC_LOADING
1394 # define OS_TYPE "LINUX"
1395 # define CPP_WORDSZ 64
1396 # define STACKBOTTOM ((ptr_t) 0x120000000)
1398 # define SEARCH_FOR_DATA_START
1399 # define DATASTART GC_data_start
1400 # define DYNAMIC_LOADING
1402 # define DATASTART ((ptr_t) 0x140000000)
1405 # define DATAEND (_end)
1406 # define MPROTECT_VDB
1407 /* Has only been superficially tested. May not */
1408 /* work on all versions. */
1413 # define MACH_TYPE "IA64"
1414 # define USE_GENERIC_PUSH_REGS
1415 /* We need to get preserved registers in addition to register */
1416 /* windows. That's easiest to do with setjmp. */
1417 # ifdef PARALLEL_MARK
1418 # define USE_MARK_BYTES
1419 /* Compare-and-exchange is too expensive to use for */
1420 /* setting mark bits. */
1424 # define CPP_WORDSZ 32
1425 # define ALIGN_DOUBLE
1426 /* Requires 8 byte alignment for malloc */
1427 # define ALIGNMENT 4
1432 # define CPP_WORDSZ 64
1433 # define ALIGN_DOUBLE
1434 /* Requires 16 byte alignment for malloc */
1435 # define ALIGNMENT 8
1437 # define OS_TYPE "HPUX"
1438 extern int __data_start[];
1439 # define DATASTART ((ptr_t)(__data_start))
1440 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1441 /* to this. Note that the GC must be initialized before the */
1442 /* first putenv call. */
1443 extern char ** environ;
1444 # define STACKBOTTOM ((ptr_t)environ)
1445 # define DYNAMIC_LOADING
1446 # include <unistd.h>
1447 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1448 /* The following was empirically determined, and is probably */
1449 /* not very robust. */
1450 /* Note that the backing store base seems to be at a nice */
1451 /* address minus one page. */
1452 # define BACKING_STORE_DISPLACEMENT 0x1000000
1453 # define BACKING_STORE_ALIGNMENT 0x1000
1454 # define BACKING_STORE_BASE \
1455 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1456 & ~(BACKING_STORE_ALIGNMENT - 1))
1459 # define CPP_WORDSZ 64
1460 # define ALIGN_DOUBLE
1461 /* Requires 16 byte alignment for malloc */
1462 # define ALIGNMENT 8
1463 # define OS_TYPE "LINUX"
1464 /* The following works on NUE and older kernels: */
1465 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1466 /* This does not work on NUE: */
1467 # define LINUX_STACKBOTTOM
1468 /* We also need the base address of the register stack */
1469 /* backing store. This is computed in */
1470 /* GC_linux_register_stack_base based on the following */
1472 # define BACKING_STORE_ALIGNMENT 0x100000
1473 # define BACKING_STORE_DISPLACEMENT 0x80000000
1474 extern char * GC_register_stackbottom;
1475 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1476 # define SEARCH_FOR_DATA_START
1477 # define DATASTART GC_data_start
1479 # define DYNAMIC_LOADING
1481 /* In the Intel compiler environment, we seem to end up with */
1482 /* statically linked executables and an undefined reference */
1485 # define MPROTECT_VDB
1486 /* Requires Linux 2.3.47 or later. */
1488 # define DATAEND (_end)
1490 # define PREFETCH(x) \
1491 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1492 # define PREFETCH_FOR_WRITE(x) \
1493 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1494 # define CLEAR_DOUBLE(x) \
1495 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1501 # define MACH_TYPE "M88K"
1502 # define ALIGNMENT 4
1503 # define ALIGN_DOUBLE
1506 # define OS_TYPE "CX_UX"
1507 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1510 # define OS_TYPE "DGUX"
1511 extern char * GC_SysVGetDataStart();
1512 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1514 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1518 # define MACH_TYPE "S370"
1519 # define ALIGNMENT 4 /* Required by hardware */
1520 # define USE_GENERIC_PUSH_REGS
1522 # define OS_TYPE "UTS4"
1524 extern int _etext[];
1526 extern char * GC_SysVGetDataStart();
1527 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1528 # define DATAEND (_end)
1532 # define OS_TYPE "LINUX"
1534 # define DYNAMIC_LOADING
1535 extern int __data_start[];
1536 # define DATASTART ((ptr_t)(__data_start))
1541 # define ALIGNMENT 4
1542 extern int _etext[];
1543 # define DATASTART ((ptr_t)(_etext))
1548 # define CPP_WORDSZ 32
1549 # define MACH_TYPE "ARM32"
1550 # define ALIGNMENT 4
1552 # define OS_TYPE "NETBSD"
1554 extern char etext[];
1555 # define DATASTART ((ptr_t)(etext))
1556 # define USE_GENERIC_PUSH_REGS
1559 # define OS_TYPE "LINUX"
1562 # define STACK_GRAN 0x10000000
1563 # define USE_GENERIC_PUSH_REGS
1565 # define DYNAMIC_LOADING
1566 # include <features.h>
1567 # if defined(__GLIBC__) && __GLIBC__ >= 2
1568 # define LINUX_DATA_START
1570 extern char **__environ;
1571 # define DATASTART ((ptr_t)(&__environ))
1572 /* hideous kludge: __environ is the first */
1573 /* word in crt0.o, and delimits the start */
1574 /* of the data segment, no matter which */
1575 /* ld options were passed through. */
1576 /* We could use _etext instead, but that */
1577 /* would include .rodata, which may */
1578 /* contain large read-only data tables */
1579 /* that we'd rather not scan. */
1582 # define DATAEND (_end)
1585 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1589 # define OS_TYPE "MSWINCE"
1590 # define DATAEND /* not needed */
1593 /* __data_start is usually defined in the target linker script. */
1594 extern int __data_start[];
1595 # define DATASTART (ptr_t)(__data_start)
1596 # define USE_GENERIC_PUSH_REGS
1597 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1598 extern void *__stack_base__;
1599 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1604 # define MACH_TYPE "SH"
1605 # define ALIGNMENT 4
1607 # define OS_TYPE "MSWINCE"
1608 # define DATAEND /* not needed */
1611 # define OS_TYPE "LINUX"
1612 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1613 # define USE_GENERIC_PUSH_REGS
1614 # define DYNAMIC_LOADING
1615 # define LINUX_DATA_START
1617 # define DATAEND (_end)
1622 # define MACH_TYPE "SH4"
1623 # define OS_TYPE "MSWINCE"
1624 # define ALIGNMENT 4
1625 # define DATAEND /* not needed */
1628 #ifdef LINUX_DATA_START
1629 /* Some Linux distributions arrange to define __data_start. Some */
1630 /* define data_start as a weak symbol. The latter is technically */
1631 /* broken, since the user program may define data_start, in which */
1632 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1633 /* We assume gcc. */
1634 # pragma weak __data_start
1635 extern int __data_start[];
1636 # pragma weak data_start
1637 extern int data_start[];
1638 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1641 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1642 /* Rld appears to allocate some memory with its own allocator, and */
1643 /* some through malloc, which might be redirected. To make this */
1644 /* work with collectable memory, we have to scan memory allocated */
1645 /* by rld's internal malloc. */
1646 # define USE_PROC_FOR_LIBRARIES
1649 # ifndef STACK_GROWS_UP
1650 # define STACK_GROWS_DOWN
1654 # define CPP_WORDSZ 32
1663 # define DATAEND (end)
1666 # if defined(SVR4) && !defined(GETPAGESIZE)
1667 # include <unistd.h>
1668 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1671 # ifndef GETPAGESIZE
1672 # if defined(SUNOS5) || defined(IRIX5)
1673 # include <unistd.h>
1675 # define GETPAGESIZE() getpagesize()
1678 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1679 /* OS has SVR4 generic features. Probably others also qualify. */
1683 # if defined(SUNOS5) || defined(DRSNX)
1684 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1687 /* OS has SUNOS5 style signal handlers. */
1695 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1696 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1697 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1698 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1701 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1706 # undef DYNAMIC_LOADING
1711 # undef MPROTECT_VDB
1716 /* Postponed for now. */
1718 # undef MPROTECT_VDB
1721 # ifdef SMALL_CONFIG
1722 /* Presumably not worth the space it takes. */
1724 # undef MPROTECT_VDB
1728 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1731 # ifdef PARALLEL_MARK
1732 # undef MPROTECT_VDB /* For now. */
1735 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1736 # define DEFAULT_VDB
1740 # define PREFETCH(x)
1741 # define NO_PREFETCH
1744 # ifndef PREFETCH_FOR_WRITE
1745 # define PREFETCH_FOR_WRITE(x)
1746 # define NO_PREFETCH_FOR_WRITE
1749 # ifndef CACHE_LINE_SIZE
1750 # define CACHE_LINE_SIZE 32 /* Wild guess */
1753 # ifndef CLEAR_DOUBLE
1754 # define CLEAR_DOUBLE(x) \
1755 ((word*)x)[0] = 0; \
1757 # endif /* CLEAR_DOUBLE */
1759 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1760 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1761 # define GC_SOLARIS_THREADS
1764 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1765 --> inconsistent configuration
1767 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1768 --> inconsistent configuration
1770 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1771 --> inconsistent configuration
1773 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1774 --> inconsistent configuration
1776 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1777 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1778 /* the necessary code is mostly there, but nobody has actually made */
1779 /* sure the right combination of pieces is compiled in, etc. */
1780 --> inconsistent configuration
1783 # if defined(PCR) || defined(SRC_M3) || \
1784 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1785 defined(GC_PTHREADS)
1789 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1790 || defined(LINT) || defined(MSWINCE) \
1791 || (defined(I386) && defined(__LCC__))
1792 /* Use setjmp based hack to mark from callee-save registers. */
1793 /* The define should move to the individual platform */
1795 # define USE_GENERIC_PUSH_REGS
1799 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1800 /* include assembly code to do it well. */
1803 /* Can we save call chain in objects for debugging? */
1804 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1805 /* to reasonable values for the platform. */
1806 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1807 /* build time, though we feel free to adjust it slightly. */
1808 /* Define NEED_CALLINFO if we either save the call stack or */
1809 /* GC_ADD_CALLER is defined. */
1811 # include <features.h>
1812 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1813 # define HAVE_BUILTIN_BACKTRACE
1818 # define CAN_SAVE_CALL_STACKS
1819 # define CAN_SAVE_CALL_ARGS
1821 #if defined(I386) && defined(LINUX)
1822 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1823 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1824 # define CAN_SAVE_CALL_STACKS
1825 # define CAN_SAVE_CALL_ARGS
1827 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1828 # define CAN_SAVE_CALL_STACKS
1831 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1832 && defined(CAN_SAVE_CALL_STACKS)
1833 # define SAVE_CALL_CHAIN
1835 # ifdef SAVE_CALL_CHAIN
1836 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1837 # define NARGS SAVE_CALL_NARGS
1839 # define NARGS 0 /* Number of arguments to save for each call. */
1842 # ifdef SAVE_CALL_CHAIN
1843 # ifndef SAVE_CALL_COUNT
1844 # define NFRAMES 6 /* Number of frames to save. Even for */
1845 /* alignment reasons. */
1847 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1849 # define NEED_CALLINFO
1850 # endif /* SAVE_CALL_CHAIN */
1851 # ifdef GC_ADD_CALLER
1854 # define NEED_CALLINFO
1857 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1858 # define DBG_HDRS_ALL
1861 # endif /* GCCONFIG_H */