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(__x86_64__)
198 # define mach_type_known
200 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
202 # define mach_type_known
204 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
206 # define mach_type_known
208 # if defined(LINUX) && defined(__mc68000__)
210 # define mach_type_known
212 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
214 # define mach_type_known
216 # if defined(LINUX) && defined(__arm__)
218 # define mach_type_known
220 # if defined(LINUX) && defined(__sh__)
222 # define mach_type_known
224 # if defined(__alpha) || defined(__alpha__)
226 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
227 # define OSF1 /* a.k.a Digital Unix */
229 # define mach_type_known
231 # if defined(_AMIGA) && !defined(AMIGA)
236 # define mach_type_known
238 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
241 # define mach_type_known
243 # if defined(__MWERKS__) && defined(__powerc)
246 # define mach_type_known
248 # if defined(macosx) || \
249 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
252 # define mach_type_known
254 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
257 --> Not really supported, but at least we recognize it.
259 # if defined(NeXT) && defined(mc68000)
262 # define mach_type_known
264 # if defined(NeXT) && (defined(i386) || defined(__i386__))
267 # define mach_type_known
269 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
272 # define mach_type_known
274 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
276 # define mach_type_known
278 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
280 # define mach_type_known
282 # if defined(bsdi) && (defined(i386) || defined(__i386__))
285 # define mach_type_known
287 # if !defined(mach_type_known) && defined(__386BSD__)
290 # define mach_type_known
292 # if defined(_CX_UX) && defined(_M88K)
295 # define mach_type_known
300 # define mach_type_known
302 # if defined(_WIN32_WCE)
303 /* SH3, SH4, MIPS already defined for corresponding architectures */
304 # if defined(SH3) || defined(SH4)
314 # define mach_type_known
316 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
317 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
319 # define MSWIN32 /* or Win32s */
320 # define mach_type_known
323 # if defined(__DJGPP__)
326 # define DJGPP /* MSDOS running the DJGPP port of GCC */
328 # define mach_type_known
330 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
333 # define mach_type_known
335 # if defined(__MINGW32__)
338 # define mach_type_known
340 # if defined(__BORLANDC__)
343 # define mach_type_known
345 # if defined(_UTS) && !defined(mach_type_known)
348 # define mach_type_known
352 # define mach_type_known
354 # if defined(__embedded__) && defined(PPC)
357 # define mach_type_known
360 # if defined(__WATCOMC__) && defined(__386__)
362 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
363 # if defined(__OS2__)
366 # if defined(__WINDOWS_386__) || defined(__NT__)
373 # define mach_type_known
375 # if defined(__s390__) && defined(LINUX)
377 # define mach_type_known
379 # if defined(__GNU__)
380 # if defined(__i386__)
381 /* The Debian Hurd running on generic PC */
384 # define mach_type_known
388 /* Feel free to add more clauses here */
390 /* Or manually define the machine type here. A machine type is */
391 /* characterized by the architecture. Some */
392 /* machine types are further subdivided by OS. */
393 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
394 /* Note that SGI IRIX is treated identically to RISCOS. */
395 /* SYSV on an M68K actually means A/UX. */
396 /* The distinction in these cases is usually the stack starting address */
397 # ifndef mach_type_known
398 --> unknown machine type
400 /* Mapping is: M68K ==> Motorola 680X0 */
401 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
402 /* MACOS and AMIGA variants) */
403 /* I386 ==> Intel 386 */
404 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
405 /* FREEBSD, THREE86BSD, MSWIN32, */
406 /* BSDI,SUNOS5, NEXT, other variants) */
407 /* NS32K ==> Encore Multimax */
408 /* MIPS ==> R2000 or R3000 */
409 /* (RISCOS, ULTRIX variants) */
410 /* VAX ==> DEC VAX */
411 /* (BSD, ULTRIX variants) */
412 /* RS6000 ==> IBM RS/6000 AIX3.X */
413 /* RT ==> IBM PC/RT */
414 /* HP_PA ==> HP9000/700 & /800 */
416 /* SPARC ==> SPARC v7/v8/v9 */
417 /* (SUNOS4, SUNOS5, LINUX, */
418 /* DRSNX variants) */
419 /* ALPHA ==> DEC Alpha */
420 /* (OSF1 and LINUX variants) */
421 /* M88K ==> Motorola 88XX0 */
422 /* (CX_UX and DGUX) */
423 /* S370 ==> 370-like machine */
424 /* running Amdahl UTS4 */
425 /* or a 390 running LINUX */
426 /* ARM32 ==> Intel StrongARM */
427 /* IA64 ==> Intel IPF */
429 /* (LINUX and HPUX) */
430 /* IA64_32 ==> IA64 w/32 bit ABI */
432 /* SH ==> Hitachi SuperH */
433 /* (LINUX & MSWINCE) */
434 /* X86_64 ==> AMD x86-64 */
438 * For each architecture and OS, the following need to be defined:
440 * CPP_WORD_SZ is a simple integer constant representing the word size.
441 * in bits. We assume byte addressibility, where a byte has 8 bits.
442 * We also assume CPP_WORD_SZ is either 32 or 64.
443 * (We care about the length of pointers, not hardware
444 * bus widths. Thus a 64 bit processor with a C compiler that uses
445 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
447 * MACH_TYPE is a string representation of the machine type.
448 * OS_TYPE is analogous for the OS.
450 * ALIGNMENT is the largest N, such that
451 * all pointer are guaranteed to be aligned on N byte boundaries.
452 * defining it to be 1 will always work, but perform poorly.
454 * DATASTART is the beginning of the data segment.
455 * On UNIX systems, the collector will scan the area between DATASTART
456 * and DATAEND for root pointers.
458 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
459 * RTH suggests gaining access to linker script synth'd values with
460 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
461 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
462 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
463 * without any special options.
465 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
468 * STACKBOTTOM is the cool end of the stack, which is usually the
469 * highest address in the stack.
470 * Under PCR or OS/2, we have other ways of finding thread stacks.
471 * For each machine, the following should:
472 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
473 * 2) define exactly one of
474 * STACKBOTTOM (should be defined to be an expression)
477 * If either of the last two macros are defined, then STACKBOTTOM is computed
478 * during collector startup using one of the following two heuristics:
479 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
480 * the next multiple of STACK_GRAN.
481 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
482 * in small steps (decrement if STACK_GROWS_UP), and read the value
483 * at each location. Remember the value when the first
484 * Segmentation violation or Bus error is signalled. Round that
485 * to the nearest plausible page boundary, and use that instead
488 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
489 * the value of environ is a pointer that can serve as STACKBOTTOM.
490 * I expect that HEURISTIC2 can be replaced by this approach, which
491 * interferes far less with debugging. However it has the disadvantage
492 * that it's confused by a putenv call before the collector is initialized.
493 * This could be dealt with by intercepting putenv ...
495 * If no expression for STACKBOTTOM can be found, and neither of the above
496 * heuristics are usable, the collector can still be used with all of the above
497 * undefined, provided one of the following is done:
498 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
499 * without reference to STACKBOTTOM. This is appropriate for use in
500 * conjunction with thread packages, since there will be multiple stacks.
501 * (Allocating thread stacks in the heap, and treating them as ordinary
502 * heap data objects is also possible as a last resort. However, this is
503 * likely to introduce significant amounts of excess storage retention
504 * unless the dead parts of the thread stacks are periodically cleared.)
505 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
506 * If the author of the client code controls the main program, this is
507 * easily accomplished by introducing a new main program, setting
508 * GC_stackbottom to the address of a local variable, and then calling
509 * the original main program. The new main program would read something
512 * # include "gc_private.h"
514 * main(argc, argv, envp)
516 * char **argv, **envp;
520 * GC_stackbottom = (ptr_t)(&dummy);
521 * return(real_main(argc, argv, envp));
525 * Each architecture may also define the style of virtual dirty bit
526 * implementation to be used:
527 * MPROTECT_VDB: Write protect the heap and catch faults.
528 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
530 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
531 * defined GC_register_dynamic_libraries() for the architecture.
533 * An architecture may define PREFETCH(x) to preload the cache with *x.
534 * This defaults to a no-op.
536 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
538 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
539 * clear the two words at GC_malloc-aligned address x. By default,
540 * word stores of 0 are used instead.
543 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
544 * to push the relevant registers onto the stack. This generally makes
545 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
547 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
548 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
549 # define HAVE_BUILTIN_UNWIND_INIT
552 # define STACK_GRAN 0x1000000
554 # define MACH_TYPE "M68K"
557 # define OS_TYPE "OPENBSD"
560 # define DATASTART ((ptr_t)(etext))
563 # define OS_TYPE "NETBSD"
566 # define DATASTART ((ptr_t)(etext))
569 # define OS_TYPE "LINUX"
570 # define STACKBOTTOM ((ptr_t)0xf0000000)
571 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
573 # define DYNAMIC_LOADING
574 # include <features.h>
575 # if defined(__GLIBC__)&& __GLIBC__>=2
576 # define LINUX_DATA_START
578 extern char **__environ;
579 # define DATASTART ((ptr_t)(&__environ))
580 /* hideous kludge: __environ is the first */
581 /* word in crt0.o, and delimits the start */
582 /* of the data segment, no matter which */
583 /* ld options were passed through. */
584 /* We could use _etext instead, but that */
585 /* would include .rodata, which may */
586 /* contain large read-only data tables */
587 /* that we'd rather not scan. */
588 # endif /* !GLIBC2 */
590 # define DATAEND (_end)
593 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
597 # define OS_TYPE "SUNOS4"
599 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
600 # define HEURISTIC1 /* differs */
601 # define DYNAMIC_LOADING
604 # define OS_TYPE "HP"
606 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
607 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
608 /* empirically determined. seems to work. */
610 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
613 # define OS_TYPE "SYSV"
615 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
617 +((word)etext & 0x1fff))
618 /* This only works for shared-text binaries with magic number 0413.
619 The other sorts of SysV binaries put the data at the end of the text,
620 in which case the default of etext would work. Unfortunately,
621 handling both would require having the magic-number available.
624 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
625 /* The stack starts at the top of memory, but */
626 /* 0x0 cannot be used as setjump_test complains */
627 /* that the stack direction is incorrect. Two */
628 /* bytes down from 0x0 should be safe enough. */
630 # include <sys/mmu.h>
631 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
634 # define OS_TYPE "AMIGA"
635 /* STACKBOTTOM and DATASTART handled specially */
637 # define DATAEND /* not needed */
638 # define GETPAGESIZE() 4096
644 # define OS_TYPE "MACOS"
645 /* see os_dep.c for details of global data segments. */
646 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
647 # define DATAEND /* not needed */
648 # define GETPAGESIZE() 4096
651 # define OS_TYPE "NEXT"
652 # define DATASTART ((ptr_t) get_etext())
653 # define STACKBOTTOM ((ptr_t) 0x4000000)
654 # define DATAEND /* not needed */
659 # define MACH_TYPE "POWERPC"
661 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
665 # define OS_TYPE "MACOS"
666 /* see os_dep.c for details of global data segments. */
667 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
668 # define DATAEND /* not needed */
671 # define ALIGNMENT 4 /* Guess. Can someone verify? */
672 /* This was 2, but that didn't sound right. */
673 # define OS_TYPE "LINUX"
675 # define DYNAMIC_LOADING
677 # define STACK_GRAN 0x10000000
678 /* Stack usually starts at 0x80000000 */
679 # define LINUX_DATA_START
681 # define DATAEND (_end)
684 /* There are reasons to suspect this may not be reliable. */
686 # define OS_TYPE "MACOSX"
687 # define DATASTART ((ptr_t) get_etext())
688 # define STACKBOTTOM ((ptr_t) 0xc0000000)
689 # define DATAEND /* not needed */
690 # define MPROTECT_VDB
692 # define GETPAGESIZE() getpagesize()
696 # define OS_TYPE "NETBSD"
699 # define DATASTART GC_data_start
700 # define DYNAMIC_LOADING
704 # define OS_TYPE "NOSYS"
705 extern void __end[], __dso_handle[];
706 # define DATASTART (__dso_handle) /* OK, that's ugly. */
707 # define DATAEND (__end)
708 /* Stack starts at 0xE0000000 for the simulator. */
710 # define STACK_GRAN 0x10000000
716 # define MACH_TYPE "VAX"
717 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
719 # define DATASTART ((ptr_t)(etext))
721 # define OS_TYPE "BSD"
723 /* HEURISTIC2 may be OK, but it's hard to test. */
726 # define OS_TYPE "ULTRIX"
727 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
732 # define MACH_TYPE "RT"
734 # define DATASTART ((ptr_t) 0x10000000)
735 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
739 # define MACH_TYPE "SPARC"
740 # if defined(__arch64__) || defined(__sparcv9)
742 # define CPP_WORDSZ 64
743 # define ELF_CLASS ELFCLASS64
745 # define ALIGNMENT 4 /* Required by hardware */
746 # define CPP_WORDSZ 32
748 # define ALIGN_DOUBLE
750 # define OS_TYPE "SUNOS5"
753 extern char * GC_SysVGetDataStart();
754 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
755 # define DATAEND (_end)
756 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
758 /* Otherwise we now use calloc. Mmap may result in the */
759 /* heap interleaved with thread stacks, which can result in */
760 /* excessive blacklisting. Sbrk is unusable since it */
761 /* doesn't interact correctly with the system malloc. */
764 # define HEAP_START (ptr_t)0x40000000
766 # define HEAP_START DATAEND
769 /* HEURISTIC1 reportedly no longer works under 2.7. */
770 /* HEURISTIC2 probably works, but this appears to be preferable. */
771 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
772 /* installations that's undefined. We work around this with a */
774 # include <sys/vmparam.h>
776 /* This should work everywhere, but doesn't. */
777 # define STACKBOTTOM USRSTACK
782 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
783 /* getpagesize() appeared to be missing from at least one */
784 /* Solaris 5.4 installation. Weird. */
785 # define DYNAMIC_LOADING
788 # define OS_TYPE "SUNOS4"
789 /* [If you have a weak stomach, don't read this.] */
790 /* We would like to use: */
791 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
792 /* This fails occasionally, due to an ancient, but very */
793 /* persistent ld bug. etext is set 32 bytes too high. */
794 /* We instead read the text segment size from the a.out */
795 /* header, which happens to be mapped into our address space */
796 /* at the start of the text segment. The detective work here */
797 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
798 /* Serpette of INRIA. */
799 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
800 # define TEXTSTART 0x2000
801 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
802 # define MPROTECT_VDB
804 # define DYNAMIC_LOADING
807 # define OS_TYPE "DRSNX"
808 extern char * GC_SysVGetDataStart();
810 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
811 # define MPROTECT_VDB
812 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
813 # define DYNAMIC_LOADING
816 # define OS_TYPE "LINUX"
818 # define DYNAMIC_LOADING
820 Linux Sparc/a.out not supported
824 # define DATAEND (_end)
827 /* libc_stack_end is not set reliably for sparc64 */
828 # define STACKBOTTOM ((ptr_t) 0x80000000000)
829 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
831 # define LINUX_STACKBOTTOM
832 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
836 # define OS_TYPE "OPENBSD"
837 # define STACKBOTTOM ((ptr_t) 0xf8000000)
839 # define DATASTART ((ptr_t)(etext))
842 # define OS_TYPE "NETBSD"
845 # define DATASTART GC_data_start
846 # define DYNAMIC_LOADING
849 # define DATASTART ((ptr_t)(etext))
855 # define MACH_TYPE "I386"
856 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
857 /* except Borland. The -a4 option fixes */
859 /* Ivan Demakov: For Watcom the option is -zp4. */
860 # ifndef SMALL_CONFIG
861 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
862 /* improvement on Pentiums. */
864 # ifdef HAVE_BUILTIN_UNWIND_INIT
865 # define USE_GENERIC_PUSH_REGS
868 # define OS_TYPE "SEQUENT"
870 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
871 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
874 # define OS_TYPE "BEOS"
876 # define GETPAGESIZE() B_PAGE_SIZE
878 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
881 # define OS_TYPE "SUNOS5"
882 extern int _etext[], _end[];
883 extern char * GC_SysVGetDataStart();
884 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
885 # define DATAEND (_end)
886 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
887 /* but reportedly breaks under 2.8. It appears that the stack */
888 /* base is a property of the executable, so this should not break */
889 /* old executables. */
890 /* HEURISTIC2 probably works, but this appears to be preferable. */
892 # define STACKBOTTOM USRSTACK
893 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
894 /* It appears to be fixed in 2.8 and 2.9. */
895 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
898 # define DYNAMIC_LOADING
899 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
901 /* Otherwise we now use calloc. Mmap may result in the */
902 /* heap interleaved with thread stacks, which can result in */
903 /* excessive blacklisting. Sbrk is unusable since it */
904 /* doesn't interact correctly with the system malloc. */
907 # define HEAP_START (ptr_t)0x40000000
909 # define HEAP_START DATAEND
913 # define OS_TYPE "SCO"
915 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
917 +((word)etext & 0xfff))
918 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
921 # define OS_TYPE "SCO_ELF"
923 # define DATASTART ((ptr_t)(etext))
924 # define STACKBOTTOM ((ptr_t) 0x08048000)
925 # define DYNAMIC_LOADING
926 # define ELF_CLASS ELFCLASS32
930 /* The Intel compiler doesn't like inline assembly */
931 # define USE_GENERIC_PUSH_REGS
933 # define OS_TYPE "LINUX"
934 # define LINUX_STACKBOTTOM
938 # define STACK_GRAN 0x10000000
939 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
940 /* different kernel configurations. In particular, systems */
941 /* with 2GB physical memory will usually move the user */
942 /* address space limit, and hence initial SP to 0x80000000. */
944 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
945 # define MPROTECT_VDB
947 /* We seem to get random errors in incremental mode, */
948 /* possibly because Linux threads is itself a malloc client */
949 /* and can't deal with the signals. */
952 # define DYNAMIC_LOADING
953 # ifdef UNDEFINED /* includes ro data */
955 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
957 # include <features.h>
958 # if defined(__GLIBC__) && __GLIBC__ >= 2
959 # define LINUX_DATA_START
961 extern char **__environ;
962 # define DATASTART ((ptr_t)(&__environ))
963 /* hideous kludge: __environ is the first */
964 /* word in crt0.o, and delimits the start */
965 /* of the data segment, no matter which */
966 /* ld options were passed through. */
967 /* We could use _etext instead, but that */
968 /* would include .rodata, which may */
969 /* contain large read-only data tables */
970 /* that we'd rather not scan. */
973 # define DATAEND (_end)
976 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
978 # ifdef USE_I686_PREFETCH
979 # define PREFETCH(x) \
980 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
981 /* Empirically prefetcht0 is much more effective at reducing */
982 /* cache miss stalls for the targetted load instructions. But it */
983 /* seems to interfere enough with other cache traffic that the net */
984 /* result is worse than prefetchnta. */
986 /* Using prefetches for write seems to have a slight negative */
987 /* impact on performance, at least for a PIII/500. */
988 # define PREFETCH_FOR_WRITE(x) \
989 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
992 # ifdef USE_3DNOW_PREFETCH
993 # define PREFETCH(x) \
994 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
995 # define PREFETCH_FOR_WRITE(x) \
996 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1000 # define OS_TYPE "CYGWIN32"
1001 extern int _data_start__[];
1002 extern int _data_end__[];
1003 extern int _bss_start__[];
1004 extern int _bss_end__[];
1005 /* For binutils 2.9.1, we have */
1006 /* DATASTART = _data_start__ */
1007 /* DATAEND = _bss_end__ */
1008 /* whereas for some earlier versions it was */
1009 /* DATASTART = _bss_start__ */
1010 /* DATAEND = _data_end__ */
1011 /* To get it right for both, we take the */
1012 /* minumum/maximum of the two. */
1013 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1014 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1015 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1016 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1018 # define STACK_GRAN 0x10000
1022 # define OS_TYPE "OS2"
1023 /* STACKBOTTOM and DATASTART are handled specially in */
1024 /* os_dep.c. OS2 actually has the right */
1026 # define DATAEND /* not needed */
1027 # define USE_GENERIC_PUSH_REGS
1030 # define OS_TYPE "MSWIN32"
1031 /* STACKBOTTOM and DATASTART are handled specially in */
1033 # ifndef __WATCOMC__
1034 # define MPROTECT_VDB
1036 # define DATAEND /* not needed */
1039 # define OS_TYPE "MSWINCE"
1040 # define DATAEND /* not needed */
1043 # define OS_TYPE "DJGPP"
1044 # include "stubinfo.h"
1047 extern int __djgpp_stack_limit;
1048 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1049 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1051 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1052 /* This may not be right. */
1055 # define OS_TYPE "OPENBSD"
1058 # define OS_TYPE "FREEBSD"
1059 # ifndef GC_FREEBSD_THREADS
1060 # define MPROTECT_VDB
1062 # define SIG_SUSPEND SIGUSR1
1063 # define SIG_THR_RESTART SIGUSR2
1064 # define FREEBSD_STACKBOTTOM
1066 # define DYNAMIC_LOADING
1068 /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */
1069 extern char etext[];
1070 extern char edata[];
1072 # define NEED_FIND_LIMIT
1073 # define DATASTART ((ptr_t)(etext))
1074 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1075 # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2))
1076 # define DATASTART2 ((ptr_t)(edata))
1077 # define DATAEND2 ((ptr_t)(end))
1080 # define OS_TYPE "NETBSD"
1082 # define DYNAMIC_LOADING
1086 # define OS_TYPE "THREE86BSD"
1089 # define OS_TYPE "BSDI"
1091 # if defined(OPENBSD) || defined(NETBSD) \
1092 || defined(THREE86BSD) || defined(BSDI)
1094 extern char etext[];
1095 # define DATASTART ((ptr_t)(etext))
1098 # define OS_TYPE "NEXT"
1099 # define DATASTART ((ptr_t) get_etext())
1100 # define STACKBOTTOM ((ptr_t)0xc0000000)
1101 # define DATAEND /* not needed */
1104 # define OS_TYPE "DOS4GW"
1105 extern long __nullarea;
1107 extern char *_STACKTOP;
1108 /* Depending on calling conventions Watcom C either precedes
1109 or does not precedes with undescore names of C-variables.
1110 Make sure startup code variables always have the same names. */
1111 #pragma aux __nullarea "*";
1112 #pragma aux _end "*";
1113 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1114 /* confused? me too. */
1115 # define DATASTART ((ptr_t) &__nullarea)
1116 # define DATAEND ((ptr_t) &_end)
1119 # define OS_TYPE "HURD"
1120 # define STACK_GROWS_DOWN
1122 extern int __data_start[];
1123 # define DATASTART ( (ptr_t) (__data_start))
1125 # define DATAEND ( (ptr_t) (_end))
1126 /* # define MPROTECT_VDB Not quite working yet? */
1127 # define DYNAMIC_LOADING
1132 # define MACH_TYPE "NS32K"
1133 # define ALIGNMENT 4
1134 extern char **environ;
1135 # define DATASTART ((ptr_t)(&environ))
1136 /* hideous kludge: environ is the first */
1137 /* word in crt0.o, and delimits the start */
1138 /* of the data segment, no matter which */
1139 /* ld options were passed through. */
1140 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1144 # define MACH_TYPE "MIPS"
1146 /* This was developed for a linuxce style platform. Probably */
1147 /* needs to be tweaked for workstation class machines. */
1148 # define OS_TYPE "LINUX"
1149 # define DYNAMIC_LOADING
1151 # define DATAEND (_end)
1152 extern int __data_start[];
1153 # define DATASTART ((ptr_t)(__data_start))
1154 # define ALIGNMENT 4
1155 # define USE_GENERIC_PUSH_REGS
1156 # define LINUX_STACKBOTTOM
1160 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1161 extern int _fdata[], _end[];
1162 # define DATASTART ((ptr_t)_fdata)
1163 # define DATAEND ((ptr_t)_end)
1164 # define CPP_WORDSZ _MIPS_SZPTR
1165 # define ALIGNMENT (_MIPS_SZPTR/8)
1167 extern int etext[], edata[], end[];
1168 extern int _DYNAMIC_LINKING[], _gp[];
1169 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1170 + ((word)etext & 0xffff)))
1171 # define DATAEND (edata)
1172 # define DATASTART2 (_DYNAMIC_LINKING \
1173 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1175 # define DATAEND2 (end)
1176 # define ALIGNMENT 4
1178 # define OS_TYPE "EWS4800"
1179 # define USE_GENERIC_PUSH_REGS 1
1183 # define DATASTART (ptr_t)0x10000000
1184 /* Could probably be slightly higher since */
1185 /* startup code allocates lots of stuff. */
1186 # define OS_TYPE "ULTRIX"
1187 # define ALIGNMENT 4
1191 # define DATASTART (ptr_t)0x10000000
1192 # define OS_TYPE "RISCOS"
1193 # define ALIGNMENT 4 /* Required by hardware */
1197 extern int _fdata[];
1198 # define DATASTART ((ptr_t)(_fdata))
1200 # define HEAP_START (ptr_t)0x30000000
1202 # define HEAP_START DATASTART
1204 /* Lowest plausible heap address. */
1205 /* In the MMAP case, we map there. */
1206 /* In either case it is used to identify */
1207 /* heap sections so they're not */
1208 /* considered as roots. */
1209 # define OS_TYPE "IRIX5"
1210 # define MPROTECT_VDB
1212 # define CPP_WORDSZ _MIPS_SZPTR
1213 # define ALIGNMENT (_MIPS_SZPTR/8)
1214 # if CPP_WORDSZ != 64
1215 # define ALIGN_DOUBLE
1218 # define ALIGNMENT 4
1219 # define ALIGN_DOUBLE
1221 # define DYNAMIC_LOADING
1224 # define OS_TYPE "MSWINCE"
1225 # define ALIGNMENT 4
1226 # define DATAEND /* not needed */
1228 # if defined(NETBSD)
1229 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1230 /* should be handled at the top of the file. */
1231 # define ALIGNMENT 4
1232 # define OS_TYPE "NETBSD"
1234 # define USE_GENERIC_PUSH_REGS
1237 # define DATASTART GC_data_start
1238 # define NEED_FIND_LIMIT
1239 # define DYNAMIC_LOADING
1241 # define DATASTART ((ptr_t) 0x10000000)
1242 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1248 # define MACH_TYPE "RS6000"
1250 # define ALIGNMENT 8
1251 # define CPP_WORDSZ 64
1253 # define ALIGNMENT 4
1254 # define CPP_WORDSZ 32
1256 extern int _data[], _end[];
1257 # define DATASTART ((ptr_t)((ulong)_data))
1258 # define DATAEND ((ptr_t)((ulong)_end))
1260 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1261 # define USE_GENERIC_PUSH_REGS
1262 # define DYNAMIC_LOADING
1263 /* For really old versions of AIX, this may have to be removed. */
1267 # define MACH_TYPE "HP_PA"
1269 # define CPP_WORDSZ 64
1270 # define ALIGNMENT 8
1272 # define CPP_WORDSZ 32
1273 # define ALIGNMENT 4
1274 # define ALIGN_DOUBLE
1276 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1277 # ifndef LINUX /* For now. */
1278 # define MPROTECT_VDB
1281 # define GENERIC_COMPARE_AND_SWAP
1282 /* No compare-and-swap instruction. Use pthread mutexes */
1283 /* when we absolutely have to. */
1284 # ifdef PARALLEL_MARK
1285 # define USE_MARK_BYTES
1286 /* Minimize compare-and-swap usage. */
1289 # define STACK_GROWS_UP
1291 # define OS_TYPE "HPUX"
1292 extern int __data_start[];
1293 # define DATASTART ((ptr_t)(__data_start))
1295 /* The following appears to work for 7xx systems running HP/UX */
1296 /* 9.xx Furthermore, it might result in much faster */
1297 /* collections than HEURISTIC2, which may involve scanning */
1298 /* segments that directly precede the stack. It is not the */
1299 /* default, since it may not work on older machine/OS */
1300 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1302 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1304 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1305 /* to this. Note that the GC must be initialized before the */
1306 /* first putenv call. */
1307 extern char ** environ;
1308 # define STACKBOTTOM ((ptr_t)environ)
1310 # define DYNAMIC_LOADING
1311 # include <unistd.h>
1312 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1314 # define PREFETCH(x) { \
1315 register long addr = (long)(x); \
1316 (void) _asm ("LDW", 0, 0, addr, 0); \
1321 # define OS_TYPE "LINUX"
1322 # define LINUX_STACKBOTTOM
1323 # define DYNAMIC_LOADING
1324 # define LINUX_DATA_START
1326 # define DATAEND (_end)
1331 # define MACH_TYPE "ALPHA"
1332 # define ALIGNMENT 8
1334 # define OS_TYPE "NETBSD"
1336 # define DATASTART GC_data_start
1337 # define ELFCLASS32 32
1338 # define ELFCLASS64 64
1339 # define ELF_CLASS ELFCLASS64
1340 # define CPP_WORDSZ 64
1341 # define DYNAMIC_LOADING
1344 # define OS_TYPE "OPENBSD"
1346 # define CPP_WORDSZ 64
1347 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1348 # define DATASTART GC_data_start
1349 # define ELFCLASS32 32
1350 # define ELFCLASS64 64
1351 # define ELF_CLASS ELFCLASS64
1352 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1353 # define DATASTART ((ptr_t) 0x140000000)
1357 # define OS_TYPE "FREEBSD"
1358 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1359 # define SIG_SUSPEND SIGUSR1
1360 # define SIG_THR_RESTART SIGUSR2
1361 # define FREEBSD_STACKBOTTOM
1363 # define DYNAMIC_LOADING
1365 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1366 extern char etext[];
1367 extern char edata[];
1369 # define NEED_FIND_LIMIT
1370 # define DATASTART ((ptr_t)(etext))
1371 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1372 # define DATASTART2 ((ptr_t)(edata))
1373 # define DATAEND2 ((ptr_t)(end))
1374 # define CPP_WORDSZ 64
1377 # define OS_TYPE "OSF1"
1378 # define DATASTART ((ptr_t) 0x140000000)
1380 # define DATAEND ((ptr_t) _end)
1381 extern char ** environ;
1382 /* round up from the value of environ to the nearest page boundary */
1383 /* Probably breaks if putenv is called before collector */
1384 /* initialization. */
1385 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1386 /* # define HEURISTIC2 */
1387 /* Normally HEURISTIC2 is too conervative, since */
1388 /* the text segment immediately follows the stack. */
1389 /* Hence we give an upper pound. */
1390 /* This is currently unused, since we disabled HEURISTIC2 */
1391 extern int __start[];
1392 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1393 # define CPP_WORDSZ 64
1394 # define MPROTECT_VDB
1395 # define DYNAMIC_LOADING
1398 # define OS_TYPE "LINUX"
1399 # define CPP_WORDSZ 64
1400 # define STACKBOTTOM ((ptr_t) 0x120000000)
1402 # define SEARCH_FOR_DATA_START
1403 # define DATASTART GC_data_start
1404 # define DYNAMIC_LOADING
1406 # define DATASTART ((ptr_t) 0x140000000)
1409 # define DATAEND (_end)
1410 # define MPROTECT_VDB
1411 /* Has only been superficially tested. May not */
1412 /* work on all versions. */
1417 # define MACH_TYPE "IA64"
1418 # define USE_GENERIC_PUSH_REGS
1419 /* We need to get preserved registers in addition to register */
1420 /* windows. That's easiest to do with setjmp. */
1421 # ifdef PARALLEL_MARK
1422 # define USE_MARK_BYTES
1423 /* Compare-and-exchange is too expensive to use for */
1424 /* setting mark bits. */
1428 # define CPP_WORDSZ 32
1429 # define ALIGN_DOUBLE
1430 /* Requires 8 byte alignment for malloc */
1431 # define ALIGNMENT 4
1436 # define CPP_WORDSZ 64
1437 # define ALIGN_DOUBLE
1438 /* Requires 16 byte alignment for malloc */
1439 # define ALIGNMENT 8
1441 # define OS_TYPE "HPUX"
1442 extern int __data_start[];
1443 # define DATASTART ((ptr_t)(__data_start))
1444 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1445 /* to this. Note that the GC must be initialized before the */
1446 /* first putenv call. */
1447 extern char ** environ;
1448 # define STACKBOTTOM ((ptr_t)environ)
1449 # define DYNAMIC_LOADING
1450 # include <unistd.h>
1451 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1452 /* The following was empirically determined, and is probably */
1453 /* not very robust. */
1454 /* Note that the backing store base seems to be at a nice */
1455 /* address minus one page. */
1456 # define BACKING_STORE_DISPLACEMENT 0x1000000
1457 # define BACKING_STORE_ALIGNMENT 0x1000
1458 # define BACKING_STORE_BASE \
1459 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1460 & ~(BACKING_STORE_ALIGNMENT - 1))
1463 # define CPP_WORDSZ 64
1464 # define ALIGN_DOUBLE
1465 /* Requires 16 byte alignment for malloc */
1466 # define ALIGNMENT 8
1467 # define OS_TYPE "LINUX"
1468 /* The following works on NUE and older kernels: */
1469 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1470 /* This does not work on NUE: */
1471 # define LINUX_STACKBOTTOM
1472 /* We also need the base address of the register stack */
1473 /* backing store. This is computed in */
1474 /* GC_linux_register_stack_base based on the following */
1476 # define BACKING_STORE_ALIGNMENT 0x100000
1477 # define BACKING_STORE_DISPLACEMENT 0x80000000
1478 extern char * GC_register_stackbottom;
1479 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1480 # define SEARCH_FOR_DATA_START
1481 # define DATASTART GC_data_start
1483 # define DYNAMIC_LOADING
1485 /* In the Intel compiler environment, we seem to end up with */
1486 /* statically linked executables and an undefined reference */
1489 # define MPROTECT_VDB
1490 /* Requires Linux 2.3.47 or later. */
1492 # define DATAEND (_end)
1494 # define PREFETCH(x) \
1495 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1496 # define PREFETCH_FOR_WRITE(x) \
1497 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1498 # define CLEAR_DOUBLE(x) \
1499 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1505 # define MACH_TYPE "M88K"
1506 # define ALIGNMENT 4
1507 # define ALIGN_DOUBLE
1510 # define OS_TYPE "CX_UX"
1511 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1514 # define OS_TYPE "DGUX"
1515 extern char * GC_SysVGetDataStart();
1516 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1518 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1522 # define MACH_TYPE "S370"
1523 # define ALIGNMENT 4 /* Required by hardware */
1524 # define USE_GENERIC_PUSH_REGS
1526 # define OS_TYPE "UTS4"
1528 extern int _etext[];
1530 extern char * GC_SysVGetDataStart();
1531 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1532 # define DATAEND (_end)
1536 # define OS_TYPE "LINUX"
1538 # define DYNAMIC_LOADING
1539 extern int __data_start[];
1540 # define DATASTART ((ptr_t)(__data_start))
1545 # define ALIGNMENT 4
1546 extern int _etext[];
1547 # define DATASTART ((ptr_t)(_etext))
1552 # define CPP_WORDSZ 32
1553 # define MACH_TYPE "ARM32"
1554 # define ALIGNMENT 4
1556 # define OS_TYPE "NETBSD"
1558 extern char etext[];
1559 # define DATASTART ((ptr_t)(etext))
1560 # define USE_GENERIC_PUSH_REGS
1563 # define OS_TYPE "LINUX"
1566 # define STACK_GRAN 0x10000000
1567 # define USE_GENERIC_PUSH_REGS
1569 # define DYNAMIC_LOADING
1570 # include <features.h>
1571 # if defined(__GLIBC__) && __GLIBC__ >= 2
1572 # define LINUX_DATA_START
1574 extern char **__environ;
1575 # define DATASTART ((ptr_t)(&__environ))
1576 /* hideous kludge: __environ is the first */
1577 /* word in crt0.o, and delimits the start */
1578 /* of the data segment, no matter which */
1579 /* ld options were passed through. */
1580 /* We could use _etext instead, but that */
1581 /* would include .rodata, which may */
1582 /* contain large read-only data tables */
1583 /* that we'd rather not scan. */
1586 # define DATAEND (_end)
1589 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1593 # define OS_TYPE "MSWINCE"
1594 # define DATAEND /* not needed */
1597 /* __data_start is usually defined in the target linker script. */
1598 extern int __data_start[];
1599 # define DATASTART (ptr_t)(__data_start)
1600 # define USE_GENERIC_PUSH_REGS
1601 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1602 extern void *__stack_base__;
1603 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1608 # define MACH_TYPE "SH"
1609 # define ALIGNMENT 4
1611 # define OS_TYPE "MSWINCE"
1612 # define DATAEND /* not needed */
1615 # define OS_TYPE "LINUX"
1616 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1617 # define USE_GENERIC_PUSH_REGS
1618 # define DYNAMIC_LOADING
1619 # define LINUX_DATA_START
1621 # define DATAEND (_end)
1626 # define MACH_TYPE "SH4"
1627 # define OS_TYPE "MSWINCE"
1628 # define ALIGNMENT 4
1629 # define DATAEND /* not needed */
1633 # define MACH_TYPE "X86_64"
1634 # define ALIGNMENT 8
1635 # define CPP_WORDSZ 64
1636 # define CACHE_LINE_SIZE 64
1637 # define USE_GENERIC_PUSH_REGS
1639 # define OS_TYPE "LINUX"
1640 # define LINUX_STACKBOTTOM
1641 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1642 # define MPROTECT_VDB
1644 /* We seem to get random errors in incremental mode, */
1645 /* possibly because Linux threads is itself a malloc client */
1646 /* and can't deal with the signals. */
1649 # define DYNAMIC_LOADING
1650 # ifdef UNDEFINED /* includes ro data */
1651 extern int _etext[];
1652 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1654 # include <features.h>
1655 # define LINUX_DATA_START
1657 # define DATAEND (_end)
1660 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1662 # define PREFETCH(x) \
1663 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1664 # define PREFETCH_FOR_WRITE(x) \
1665 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1669 #ifdef LINUX_DATA_START
1670 /* Some Linux distributions arrange to define __data_start. Some */
1671 /* define data_start as a weak symbol. The latter is technically */
1672 /* broken, since the user program may define data_start, in which */
1673 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1674 /* We assume gcc. */
1675 # pragma weak __data_start
1676 extern int __data_start[];
1677 # pragma weak data_start
1678 extern int data_start[];
1679 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1682 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1683 /* Rld appears to allocate some memory with its own allocator, and */
1684 /* some through malloc, which might be redirected. To make this */
1685 /* work with collectable memory, we have to scan memory allocated */
1686 /* by rld's internal malloc. */
1687 # define USE_PROC_FOR_LIBRARIES
1690 # ifndef STACK_GROWS_UP
1691 # define STACK_GROWS_DOWN
1695 # define CPP_WORDSZ 32
1704 # define DATAEND (end)
1707 # if defined(SVR4) && !defined(GETPAGESIZE)
1708 # include <unistd.h>
1709 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1712 # ifndef GETPAGESIZE
1713 # if defined(SUNOS5) || defined(IRIX5)
1714 # include <unistd.h>
1716 # define GETPAGESIZE() getpagesize()
1719 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1720 /* OS has SVR4 generic features. Probably others also qualify. */
1724 # if defined(SUNOS5) || defined(DRSNX)
1725 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1728 /* OS has SUNOS5 style signal handlers. */
1736 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1737 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1738 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1739 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1742 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1747 # undef DYNAMIC_LOADING
1752 # undef MPROTECT_VDB
1757 /* Postponed for now. */
1759 # undef MPROTECT_VDB
1762 # ifdef SMALL_CONFIG
1763 /* Presumably not worth the space it takes. */
1765 # undef MPROTECT_VDB
1769 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1772 # ifdef PARALLEL_MARK
1773 # undef MPROTECT_VDB /* For now. */
1776 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1777 # define DEFAULT_VDB
1781 # define PREFETCH(x)
1782 # define NO_PREFETCH
1785 # ifndef PREFETCH_FOR_WRITE
1786 # define PREFETCH_FOR_WRITE(x)
1787 # define NO_PREFETCH_FOR_WRITE
1790 # ifndef CACHE_LINE_SIZE
1791 # define CACHE_LINE_SIZE 32 /* Wild guess */
1794 # ifndef CLEAR_DOUBLE
1795 # define CLEAR_DOUBLE(x) \
1796 ((word*)x)[0] = 0; \
1798 # endif /* CLEAR_DOUBLE */
1800 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1801 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1802 # define GC_SOLARIS_THREADS
1805 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1806 --> inconsistent configuration
1808 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1809 --> inconsistent configuration
1811 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1812 --> inconsistent configuration
1814 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1815 --> inconsistent configuration
1817 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1818 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1819 /* the necessary code is mostly there, but nobody has actually made */
1820 /* sure the right combination of pieces is compiled in, etc. */
1821 --> inconsistent configuration
1824 # if defined(PCR) || defined(SRC_M3) || \
1825 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1826 defined(GC_PTHREADS)
1830 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1831 || defined(LINT) || defined(MSWINCE) \
1832 || (defined(I386) && defined(__LCC__))
1833 /* Use setjmp based hack to mark from callee-save registers. */
1834 /* The define should move to the individual platform */
1836 # define USE_GENERIC_PUSH_REGS
1840 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1841 /* include assembly code to do it well. */
1844 /* Can we save call chain in objects for debugging? */
1845 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1846 /* to reasonable values for the platform. */
1847 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1848 /* build time, though we feel free to adjust it slightly. */
1849 /* Define NEED_CALLINFO if we either save the call stack or */
1850 /* GC_ADD_CALLER is defined. */
1852 # include <features.h>
1853 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1854 # define HAVE_BUILTIN_BACKTRACE
1859 # define CAN_SAVE_CALL_STACKS
1860 # define CAN_SAVE_CALL_ARGS
1862 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1863 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1864 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1865 # define CAN_SAVE_CALL_STACKS
1866 # define CAN_SAVE_CALL_ARGS
1868 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1869 # define CAN_SAVE_CALL_STACKS
1872 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1873 && defined(CAN_SAVE_CALL_STACKS)
1874 # define SAVE_CALL_CHAIN
1876 # ifdef SAVE_CALL_CHAIN
1877 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1878 # define NARGS SAVE_CALL_NARGS
1880 # define NARGS 0 /* Number of arguments to save for each call. */
1883 # ifdef SAVE_CALL_CHAIN
1884 # ifndef SAVE_CALL_COUNT
1885 # define NFRAMES 6 /* Number of frames to save. Even for */
1886 /* alignment reasons. */
1888 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1890 # define NEED_CALLINFO
1891 # endif /* SAVE_CALL_CHAIN */
1892 # ifdef GC_ADD_CALLER
1895 # define NEED_CALLINFO
1898 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1899 # define DBG_HDRS_ALL
1902 # endif /* GCCONFIG_H */