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)
824 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
825 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
827 # define STACKBOTTOM ((ptr_t) 0xf0000000)
828 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
832 # define OS_TYPE "OPENBSD"
833 # define STACKBOTTOM ((ptr_t) 0xf8000000)
835 # define DATASTART ((ptr_t)(etext))
838 # define OS_TYPE "NETBSD"
841 # define DATASTART GC_data_start
842 # define DYNAMIC_LOADING
845 # define DATASTART ((ptr_t)(etext))
851 # define MACH_TYPE "I386"
852 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
853 /* except Borland. The -a4 option fixes */
855 /* Ivan Demakov: For Watcom the option is -zp4. */
856 # ifndef SMALL_CONFIG
857 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
858 /* improvement on Pentiums. */
860 # ifdef HAVE_BUILTIN_UNWIND_INIT
861 # define USE_GENERIC_PUSH_REGS
864 # define OS_TYPE "SEQUENT"
866 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
867 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
870 # define OS_TYPE "BEOS"
872 # define GETPAGESIZE() B_PAGE_SIZE
874 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
877 # define OS_TYPE "SUNOS5"
878 extern int _etext[], _end[];
879 extern char * GC_SysVGetDataStart();
880 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
881 # define DATAEND (_end)
882 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
883 /* but reportedly breaks under 2.8. It appears that the stack */
884 /* base is a property of the executable, so this should not break */
885 /* old executables. */
886 /* HEURISTIC2 probably works, but this appears to be preferable. */
888 # define STACKBOTTOM USRSTACK
889 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
890 /* It appears to be fixed in 2.8 and 2.9. */
891 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
894 # define DYNAMIC_LOADING
895 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
897 /* Otherwise we now use calloc. Mmap may result in the */
898 /* heap interleaved with thread stacks, which can result in */
899 /* excessive blacklisting. Sbrk is unusable since it */
900 /* doesn't interact correctly with the system malloc. */
903 # define HEAP_START (ptr_t)0x40000000
905 # define HEAP_START DATAEND
909 # define OS_TYPE "SCO"
911 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
913 +((word)etext & 0xfff))
914 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
917 # define OS_TYPE "SCO_ELF"
919 # define DATASTART ((ptr_t)(etext))
920 # define STACKBOTTOM ((ptr_t) 0x08048000)
921 # define DYNAMIC_LOADING
922 # define ELF_CLASS ELFCLASS32
926 /* The Intel compiler doesn't like inline assembly */
927 # define USE_GENERIC_PUSH_REGS
929 # define OS_TYPE "LINUX"
930 # define LINUX_STACKBOTTOM
934 # define STACK_GRAN 0x10000000
935 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
936 /* different kernel configurations. In particular, systems */
937 /* with 2GB physical memory will usually move the user */
938 /* address space limit, and hence initial SP to 0x80000000. */
940 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
941 # define MPROTECT_VDB
943 /* We seem to get random errors in incremental mode, */
944 /* possibly because Linux threads is itself a malloc client */
945 /* and can't deal with the signals. */
948 # define DYNAMIC_LOADING
949 # ifdef UNDEFINED /* includes ro data */
951 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
953 # include <features.h>
954 # if defined(__GLIBC__) && __GLIBC__ >= 2
955 # define LINUX_DATA_START
957 extern char **__environ;
958 # define DATASTART ((ptr_t)(&__environ))
959 /* hideous kludge: __environ is the first */
960 /* word in crt0.o, and delimits the start */
961 /* of the data segment, no matter which */
962 /* ld options were passed through. */
963 /* We could use _etext instead, but that */
964 /* would include .rodata, which may */
965 /* contain large read-only data tables */
966 /* that we'd rather not scan. */
969 # define DATAEND (_end)
972 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
974 # ifdef USE_I686_PREFETCH
975 # define PREFETCH(x) \
976 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
977 /* Empirically prefetcht0 is much more effective at reducing */
978 /* cache miss stalls for the targetted load instructions. But it */
979 /* seems to interfere enough with other cache traffic that the net */
980 /* result is worse than prefetchnta. */
982 /* Using prefetches for write seems to have a slight negative */
983 /* impact on performance, at least for a PIII/500. */
984 # define PREFETCH_FOR_WRITE(x) \
985 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
988 # ifdef USE_3DNOW_PREFETCH
989 # define PREFETCH(x) \
990 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
991 # define PREFETCH_FOR_WRITE(x) \
992 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
996 # define OS_TYPE "CYGWIN32"
997 extern int _data_start__[];
998 extern int _data_end__[];
999 extern int _bss_start__[];
1000 extern int _bss_end__[];
1001 /* For binutils 2.9.1, we have */
1002 /* DATASTART = _data_start__ */
1003 /* DATAEND = _bss_end__ */
1004 /* whereas for some earlier versions it was */
1005 /* DATASTART = _bss_start__ */
1006 /* DATAEND = _data_end__ */
1007 /* To get it right for both, we take the */
1008 /* minumum/maximum of the two. */
1009 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1010 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1011 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1012 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1014 # define STACK_GRAN 0x10000
1018 # define OS_TYPE "OS2"
1019 /* STACKBOTTOM and DATASTART are handled specially in */
1020 /* os_dep.c. OS2 actually has the right */
1022 # define DATAEND /* not needed */
1023 # define USE_GENERIC_PUSH_REGS
1026 # define OS_TYPE "MSWIN32"
1027 /* STACKBOTTOM and DATASTART are handled specially in */
1029 # ifndef __WATCOMC__
1030 # define MPROTECT_VDB
1032 # define DATAEND /* not needed */
1035 # define OS_TYPE "MSWINCE"
1036 # define DATAEND /* not needed */
1039 # define OS_TYPE "DJGPP"
1040 # include "stubinfo.h"
1043 extern int __djgpp_stack_limit;
1044 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1045 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1047 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1048 /* This may not be right. */
1051 # define OS_TYPE "OPENBSD"
1054 # define OS_TYPE "FREEBSD"
1055 # ifndef GC_FREEBSD_THREADS
1056 # define MPROTECT_VDB
1058 # define SIG_SUSPEND SIGUSR1
1059 # define SIG_THR_RESTART SIGUSR2
1060 # define FREEBSD_STACKBOTTOM
1062 # define DYNAMIC_LOADING
1064 /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */
1065 extern char etext[];
1066 extern char edata[];
1068 # define NEED_FIND_LIMIT
1069 # define DATASTART ((ptr_t)(etext))
1070 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1071 # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2))
1072 # define DATASTART2 ((ptr_t)(edata))
1073 # define DATAEND2 ((ptr_t)(end))
1076 # define OS_TYPE "NETBSD"
1078 # define DYNAMIC_LOADING
1082 # define OS_TYPE "THREE86BSD"
1085 # define OS_TYPE "BSDI"
1087 # if defined(OPENBSD) || defined(NETBSD) \
1088 || defined(THREE86BSD) || defined(BSDI)
1090 extern char etext[];
1091 # define DATASTART ((ptr_t)(etext))
1094 # define OS_TYPE "NEXT"
1095 # define DATASTART ((ptr_t) get_etext())
1096 # define STACKBOTTOM ((ptr_t)0xc0000000)
1097 # define DATAEND /* not needed */
1100 # define OS_TYPE "DOS4GW"
1101 extern long __nullarea;
1103 extern char *_STACKTOP;
1104 /* Depending on calling conventions Watcom C either precedes
1105 or does not precedes with undescore names of C-variables.
1106 Make sure startup code variables always have the same names. */
1107 #pragma aux __nullarea "*";
1108 #pragma aux _end "*";
1109 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1110 /* confused? me too. */
1111 # define DATASTART ((ptr_t) &__nullarea)
1112 # define DATAEND ((ptr_t) &_end)
1115 # define OS_TYPE "HURD"
1116 # define STACK_GROWS_DOWN
1118 extern int __data_start[];
1119 # define DATASTART ( (ptr_t) (__data_start))
1121 # define DATAEND ( (ptr_t) (_end))
1122 /* # define MPROTECT_VDB Not quite working yet? */
1123 # define DYNAMIC_LOADING
1128 # define MACH_TYPE "NS32K"
1129 # define ALIGNMENT 4
1130 extern char **environ;
1131 # define DATASTART ((ptr_t)(&environ))
1132 /* hideous kludge: environ is the first */
1133 /* word in crt0.o, and delimits the start */
1134 /* of the data segment, no matter which */
1135 /* ld options were passed through. */
1136 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1140 # define MACH_TYPE "MIPS"
1142 /* This was developed for a linuxce style platform. Probably */
1143 /* needs to be tweaked for workstation class machines. */
1144 # define OS_TYPE "LINUX"
1145 extern int __data_start[];
1146 # define DATASTART ((ptr_t)(__data_start))
1147 # define ALIGNMENT 4
1148 # define USE_GENERIC_PUSH_REGS
1149 # define STACKBOTTOM ((ptr_t)0x7fff8000)
1150 /* Older toolchains may need 0x80000000. */
1151 /* In many cases, this should probably use LINUX_STACKBOTTOM */
1152 /* instead. But some kernel versions seem to give the wrong */
1153 /* value from /proc. */
1157 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1158 extern int _fdata[], _end[];
1159 # define DATASTART ((ptr_t)_fdata)
1160 # define DATAEND ((ptr_t)_end)
1161 # define CPP_WORDSZ _MIPS_SZPTR
1162 # define ALIGNMENT (_MIPS_SZPTR/8)
1164 extern int etext[], edata[], end[];
1165 extern int _DYNAMIC_LINKING[], _gp[];
1166 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1167 + ((word)etext & 0xffff)))
1168 # define DATAEND (edata)
1169 # define DATASTART2 (_DYNAMIC_LINKING \
1170 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1172 # define DATAEND2 (end)
1173 # define ALIGNMENT 4
1175 # define OS_TYPE "EWS4800"
1176 # define USE_GENERIC_PUSH_REGS 1
1180 # define DATASTART (ptr_t)0x10000000
1181 /* Could probably be slightly higher since */
1182 /* startup code allocates lots of stuff. */
1183 # define OS_TYPE "ULTRIX"
1184 # define ALIGNMENT 4
1188 # define DATASTART (ptr_t)0x10000000
1189 # define OS_TYPE "RISCOS"
1190 # define ALIGNMENT 4 /* Required by hardware */
1194 extern int _fdata[];
1195 # define DATASTART ((ptr_t)(_fdata))
1197 # define HEAP_START (ptr_t)0x30000000
1199 # define HEAP_START DATASTART
1201 /* Lowest plausible heap address. */
1202 /* In the MMAP case, we map there. */
1203 /* In either case it is used to identify */
1204 /* heap sections so they're not */
1205 /* considered as roots. */
1206 # define OS_TYPE "IRIX5"
1207 # define MPROTECT_VDB
1209 # define CPP_WORDSZ _MIPS_SZPTR
1210 # define ALIGNMENT (_MIPS_SZPTR/8)
1211 # if CPP_WORDSZ != 64
1212 # define ALIGN_DOUBLE
1215 # define ALIGNMENT 4
1216 # define ALIGN_DOUBLE
1218 # define DYNAMIC_LOADING
1221 # define OS_TYPE "MSWINCE"
1222 # define ALIGNMENT 4
1223 # define DATAEND /* not needed */
1225 # if defined(NETBSD)
1226 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1227 /* should be handled at the top of the file. */
1228 # define ALIGNMENT 4
1229 # define OS_TYPE "NETBSD"
1231 # define USE_GENERIC_PUSH_REGS
1234 # define DATASTART GC_data_start
1235 # define NEED_FIND_LIMIT
1236 # define DYNAMIC_LOADING
1238 # define DATASTART ((ptr_t) 0x10000000)
1239 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1245 # define MACH_TYPE "RS6000"
1247 # define ALIGNMENT 8
1248 # define CPP_WORDSZ 64
1250 # define ALIGNMENT 4
1251 # define CPP_WORDSZ 32
1253 extern int _data[], _end[];
1254 # define DATASTART ((ptr_t)((ulong)_data))
1255 # define DATAEND ((ptr_t)((ulong)_end))
1257 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1258 # define USE_GENERIC_PUSH_REGS
1259 # define DYNAMIC_LOADING
1260 /* For really old versions of AIX, this may have to be removed. */
1264 # define MACH_TYPE "HP_PA"
1266 # define CPP_WORDSZ 64
1267 # define ALIGNMENT 8
1269 # define CPP_WORDSZ 32
1270 # define ALIGNMENT 4
1271 # define ALIGN_DOUBLE
1273 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1274 # ifndef LINUX /* For now. */
1275 # define MPROTECT_VDB
1278 # define GENERIC_COMPARE_AND_SWAP
1279 /* No compare-and-swap instruction. Use pthread mutexes */
1280 /* when we absolutely have to. */
1281 # ifdef PARALLEL_MARK
1282 # define USE_MARK_BYTES
1283 /* Minimize compare-and-swap usage. */
1286 # define STACK_GROWS_UP
1288 # define OS_TYPE "HPUX"
1289 extern int __data_start[];
1290 # define DATASTART ((ptr_t)(__data_start))
1292 /* The following appears to work for 7xx systems running HP/UX */
1293 /* 9.xx Furthermore, it might result in much faster */
1294 /* collections than HEURISTIC2, which may involve scanning */
1295 /* segments that directly precede the stack. It is not the */
1296 /* default, since it may not work on older machine/OS */
1297 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1299 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1301 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1302 /* to this. Note that the GC must be initialized before the */
1303 /* first putenv call. */
1304 extern char ** environ;
1305 # define STACKBOTTOM ((ptr_t)environ)
1307 # define DYNAMIC_LOADING
1308 # include <unistd.h>
1309 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1311 # define PREFETCH(x) { \
1312 register long addr = (long)(x); \
1313 (void) _asm ("LDW", 0, 0, addr, 0); \
1318 # define OS_TYPE "LINUX"
1319 # define LINUX_STACKBOTTOM
1320 # define DYNAMIC_LOADING
1321 # define LINUX_DATA_START
1323 # define DATAEND (_end)
1328 # define MACH_TYPE "ALPHA"
1329 # define ALIGNMENT 8
1331 # define OS_TYPE "NETBSD"
1333 # define DATASTART GC_data_start
1334 # define ELFCLASS32 32
1335 # define ELFCLASS64 64
1336 # define ELF_CLASS ELFCLASS64
1337 # define CPP_WORDSZ 64
1338 # define DYNAMIC_LOADING
1341 # define OS_TYPE "OPENBSD"
1343 # define CPP_WORDSZ 64
1344 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1345 # define DATASTART GC_data_start
1346 # define ELFCLASS32 32
1347 # define ELFCLASS64 64
1348 # define ELF_CLASS ELFCLASS64
1349 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1350 # define DATASTART ((ptr_t) 0x140000000)
1354 # define OS_TYPE "FREEBSD"
1355 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1356 # define SIG_SUSPEND SIGUSR1
1357 # define SIG_THR_RESTART SIGUSR2
1358 # define FREEBSD_STACKBOTTOM
1360 # define DYNAMIC_LOADING
1362 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1363 extern char etext[];
1364 extern char edata[];
1366 # define NEED_FIND_LIMIT
1367 # define DATASTART ((ptr_t)(etext))
1368 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1369 # define DATASTART2 ((ptr_t)(edata))
1370 # define DATAEND2 ((ptr_t)(end))
1371 # define CPP_WORDSZ 64
1374 # define OS_TYPE "OSF1"
1375 # define DATASTART ((ptr_t) 0x140000000)
1377 # define DATAEND ((ptr_t) _end)
1378 extern char ** environ;
1379 /* round up from the value of environ to the nearest page boundary */
1380 /* Probably breaks if putenv is called before collector */
1381 /* initialization. */
1382 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1383 /* # define HEURISTIC2 */
1384 /* Normally HEURISTIC2 is too conervative, since */
1385 /* the text segment immediately follows the stack. */
1386 /* Hence we give an upper pound. */
1387 /* This is currently unused, since we disabled HEURISTIC2 */
1388 extern int __start[];
1389 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1390 # define CPP_WORDSZ 64
1391 # define MPROTECT_VDB
1392 # define DYNAMIC_LOADING
1395 # define OS_TYPE "LINUX"
1396 # define CPP_WORDSZ 64
1397 # define STACKBOTTOM ((ptr_t) 0x120000000)
1399 # define SEARCH_FOR_DATA_START
1400 # define DATASTART GC_data_start
1401 # define DYNAMIC_LOADING
1403 # define DATASTART ((ptr_t) 0x140000000)
1406 # define DATAEND (_end)
1407 # define MPROTECT_VDB
1408 /* Has only been superficially tested. May not */
1409 /* work on all versions. */
1414 # define MACH_TYPE "IA64"
1415 # define USE_GENERIC_PUSH_REGS
1416 /* We need to get preserved registers in addition to register */
1417 /* windows. That's easiest to do with setjmp. */
1418 # ifdef PARALLEL_MARK
1419 # define USE_MARK_BYTES
1420 /* Compare-and-exchange is too expensive to use for */
1421 /* setting mark bits. */
1425 # define CPP_WORDSZ 32
1426 # define ALIGN_DOUBLE
1427 /* Requires 8 byte alignment for malloc */
1428 # define ALIGNMENT 4
1433 # define CPP_WORDSZ 64
1434 # define ALIGN_DOUBLE
1435 /* Requires 16 byte alignment for malloc */
1436 # define ALIGNMENT 8
1438 # define OS_TYPE "HPUX"
1439 extern int __data_start[];
1440 # define DATASTART ((ptr_t)(__data_start))
1441 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1442 /* to this. Note that the GC must be initialized before the */
1443 /* first putenv call. */
1444 extern char ** environ;
1445 # define STACKBOTTOM ((ptr_t)environ)
1446 # define DYNAMIC_LOADING
1447 # include <unistd.h>
1448 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1449 /* The following was empirically determined, and is probably */
1450 /* not very robust. */
1451 /* Note that the backing store base seems to be at a nice */
1452 /* address minus one page. */
1453 # define BACKING_STORE_DISPLACEMENT 0x1000000
1454 # define BACKING_STORE_ALIGNMENT 0x1000
1455 # define BACKING_STORE_BASE \
1456 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1457 & ~(BACKING_STORE_ALIGNMENT - 1))
1460 # define CPP_WORDSZ 64
1461 # define ALIGN_DOUBLE
1462 /* Requires 16 byte alignment for malloc */
1463 # define ALIGNMENT 8
1464 # define OS_TYPE "LINUX"
1465 /* The following works on NUE and older kernels: */
1466 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1467 /* This does not work on NUE: */
1468 # define LINUX_STACKBOTTOM
1469 /* We also need the base address of the register stack */
1470 /* backing store. This is computed in */
1471 /* GC_linux_register_stack_base based on the following */
1473 # define BACKING_STORE_ALIGNMENT 0x100000
1474 # define BACKING_STORE_DISPLACEMENT 0x80000000
1475 extern char * GC_register_stackbottom;
1476 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1477 # define SEARCH_FOR_DATA_START
1478 # define DATASTART GC_data_start
1480 # define DYNAMIC_LOADING
1482 /* In the Intel compiler environment, we seem to end up with */
1483 /* statically linked executables and an undefined reference */
1486 # define MPROTECT_VDB
1487 /* Requires Linux 2.3.47 or later. */
1489 # define DATAEND (_end)
1491 # define PREFETCH(x) \
1492 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1493 # define PREFETCH_FOR_WRITE(x) \
1494 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1495 # define CLEAR_DOUBLE(x) \
1496 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1502 # define MACH_TYPE "M88K"
1503 # define ALIGNMENT 4
1504 # define ALIGN_DOUBLE
1507 # define OS_TYPE "CX_UX"
1508 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1511 # define OS_TYPE "DGUX"
1512 extern char * GC_SysVGetDataStart();
1513 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1515 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1519 # define MACH_TYPE "S370"
1520 # define ALIGNMENT 4 /* Required by hardware */
1521 # define USE_GENERIC_PUSH_REGS
1523 # define OS_TYPE "UTS4"
1525 extern int _etext[];
1527 extern char * GC_SysVGetDataStart();
1528 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1529 # define DATAEND (_end)
1533 # define OS_TYPE "LINUX"
1535 # define DYNAMIC_LOADING
1536 extern int __data_start[];
1537 # define DATASTART ((ptr_t)(__data_start))
1542 # define ALIGNMENT 4
1543 extern int _etext[];
1544 # define DATASTART ((ptr_t)(_etext))
1549 # define CPP_WORDSZ 32
1550 # define MACH_TYPE "ARM32"
1551 # define ALIGNMENT 4
1553 # define OS_TYPE "NETBSD"
1555 extern char etext[];
1556 # define DATASTART ((ptr_t)(etext))
1557 # define USE_GENERIC_PUSH_REGS
1560 # define OS_TYPE "LINUX"
1563 # define STACK_GRAN 0x10000000
1564 # define USE_GENERIC_PUSH_REGS
1566 # define DYNAMIC_LOADING
1567 # include <features.h>
1568 # if defined(__GLIBC__) && __GLIBC__ >= 2
1569 # define LINUX_DATA_START
1571 extern char **__environ;
1572 # define DATASTART ((ptr_t)(&__environ))
1573 /* hideous kludge: __environ is the first */
1574 /* word in crt0.o, and delimits the start */
1575 /* of the data segment, no matter which */
1576 /* ld options were passed through. */
1577 /* We could use _etext instead, but that */
1578 /* would include .rodata, which may */
1579 /* contain large read-only data tables */
1580 /* that we'd rather not scan. */
1583 # define DATAEND (_end)
1586 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1590 # define OS_TYPE "MSWINCE"
1591 # define DATAEND /* not needed */
1594 /* __data_start is usually defined in the target linker script. */
1595 extern int __data_start[];
1596 # define DATASTART (ptr_t)(__data_start)
1597 # define USE_GENERIC_PUSH_REGS
1598 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1599 extern void *__stack_base__;
1600 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1605 # define MACH_TYPE "SH"
1606 # define ALIGNMENT 4
1608 # define OS_TYPE "MSWINCE"
1609 # define DATAEND /* not needed */
1612 # define OS_TYPE "LINUX"
1613 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1614 # define USE_GENERIC_PUSH_REGS
1615 # define DYNAMIC_LOADING
1616 # define LINUX_DATA_START
1618 # define DATAEND (_end)
1623 # define MACH_TYPE "SH4"
1624 # define OS_TYPE "MSWINCE"
1625 # define ALIGNMENT 4
1626 # define DATAEND /* not needed */
1629 #ifdef LINUX_DATA_START
1630 /* Some Linux distributions arrange to define __data_start. Some */
1631 /* define data_start as a weak symbol. The latter is technically */
1632 /* broken, since the user program may define data_start, in which */
1633 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1634 /* We assume gcc. */
1635 # pragma weak __data_start
1636 extern int __data_start[];
1637 # pragma weak data_start
1638 extern int data_start[];
1639 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1642 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1643 /* Rld appears to allocate some memory with its own allocator, and */
1644 /* some through malloc, which might be redirected. To make this */
1645 /* work with collectable memory, we have to scan memory allocated */
1646 /* by rld's internal malloc. */
1647 # define USE_PROC_FOR_LIBRARIES
1650 # ifndef STACK_GROWS_UP
1651 # define STACK_GROWS_DOWN
1655 # define CPP_WORDSZ 32
1664 # define DATAEND (end)
1667 # if defined(SVR4) && !defined(GETPAGESIZE)
1668 # include <unistd.h>
1669 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1672 # ifndef GETPAGESIZE
1673 # if defined(SUNOS5) || defined(IRIX5)
1674 # include <unistd.h>
1676 # define GETPAGESIZE() getpagesize()
1679 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1680 /* OS has SVR4 generic features. Probably others also qualify. */
1684 # if defined(SUNOS5) || defined(DRSNX)
1685 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1688 /* OS has SUNOS5 style signal handlers. */
1696 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1697 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1698 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1699 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1702 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1707 # undef DYNAMIC_LOADING
1712 # undef MPROTECT_VDB
1717 /* Postponed for now. */
1719 # undef MPROTECT_VDB
1722 # ifdef SMALL_CONFIG
1723 /* Presumably not worth the space it takes. */
1725 # undef MPROTECT_VDB
1729 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1732 # ifdef PARALLEL_MARK
1733 # undef MPROTECT_VDB /* For now. */
1736 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1737 # define DEFAULT_VDB
1741 # define PREFETCH(x)
1742 # define NO_PREFETCH
1745 # ifndef PREFETCH_FOR_WRITE
1746 # define PREFETCH_FOR_WRITE(x)
1747 # define NO_PREFETCH_FOR_WRITE
1750 # ifndef CACHE_LINE_SIZE
1751 # define CACHE_LINE_SIZE 32 /* Wild guess */
1754 # ifndef CLEAR_DOUBLE
1755 # define CLEAR_DOUBLE(x) \
1756 ((word*)x)[0] = 0; \
1758 # endif /* CLEAR_DOUBLE */
1760 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1761 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1762 # define GC_SOLARIS_THREADS
1765 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1766 --> inconsistent configuration
1768 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1769 --> inconsistent configuration
1771 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1772 --> inconsistent configuration
1774 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1775 --> inconsistent configuration
1777 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1778 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1779 /* the necessary code is mostly there, but nobody has actually made */
1780 /* sure the right combination of pieces is compiled in, etc. */
1781 --> inconsistent configuration
1784 # if defined(PCR) || defined(SRC_M3) || \
1785 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1786 defined(GC_PTHREADS)
1790 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1791 || defined(LINT) || defined(MSWINCE) \
1792 || (defined(I386) && defined(__LCC__))
1793 /* Use setjmp based hack to mark from callee-save registers. */
1794 /* The define should move to the individual platform */
1796 # define USE_GENERIC_PUSH_REGS
1800 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1801 /* include assembly code to do it well. */
1804 /* Can we save call chain in objects for debugging? */
1805 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1806 /* to reasonable values for the platform. */
1807 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1808 /* build time, though we feel free to adjust it slightly. */
1809 /* Define NEED_CALLINFO if we either save the call stack or */
1810 /* GC_ADD_CALLER is defined. */
1812 # include <features.h>
1813 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1814 # define HAVE_BUILTIN_BACKTRACE
1819 # define CAN_SAVE_CALL_STACKS
1820 # define CAN_SAVE_CALL_ARGS
1822 #if defined(I386) && defined(LINUX)
1823 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1824 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1825 # define CAN_SAVE_CALL_STACKS
1826 # define CAN_SAVE_CALL_ARGS
1828 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1829 # define CAN_SAVE_CALL_STACKS
1832 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1833 && defined(CAN_SAVE_CALL_STACKS)
1834 # define SAVE_CALL_CHAIN
1836 # ifdef SAVE_CALL_CHAIN
1837 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1838 # define NARGS SAVE_CALL_NARGS
1840 # define NARGS 0 /* Number of arguments to save for each call. */
1843 # ifdef SAVE_CALL_CHAIN
1844 # ifndef SAVE_CALL_COUNT
1845 # define NFRAMES 6 /* Number of frames to save. Even for */
1846 /* alignment reasons. */
1848 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1850 # define NEED_CALLINFO
1851 # endif /* SAVE_CALL_CHAIN */
1852 # ifdef GC_ADD_CALLER
1855 # define NEED_CALLINFO
1858 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1859 # define DBG_HDRS_ALL
1862 # endif /* GCCONFIG_H */