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(__arm__) || defined(__thumb__)
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) && !defined(NETBSD)
99 # if defined(ultrix) || defined(__ultrix)
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 # define mach_type_known
112 # if defined(sequent) && (defined(i386) || defined(__i386__))
115 # define mach_type_known
117 # if defined(sun) && (defined(i386) || defined(__i386__))
120 # define mach_type_known
122 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
125 # define mach_type_known
129 # define mach_type_known
131 # if defined(sun) && (defined(sparc) || defined(__sparc))
133 /* Test for SunOS 5.x */
140 # define mach_type_known
142 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
143 && !defined(__OpenBSD__) && !(__NetBSD__)
146 # define mach_type_known
150 # define mach_type_known
152 # if defined(__NetBSD__) && defined(__sparc__)
154 # define mach_type_known
156 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
157 /* The above test may need refinement */
159 # if defined(_SCO_ELF)
164 # define mach_type_known
166 # if defined(_AUX_SOURCE)
169 # define mach_type_known
171 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
172 || defined(hppa) || defined(__hppa__)
177 # define mach_type_known
179 # if defined(__ia64) && defined(_HPUX_SOURCE)
182 # define mach_type_known
184 # if defined(__BEOS__) && defined(_X86_)
187 # define mach_type_known
189 # if defined(LINUX) && (defined(i386) || defined(__i386__))
191 # define mach_type_known
193 # if defined(LINUX) && defined(__x86_64__)
195 # define mach_type_known
197 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
199 # define mach_type_known
201 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
203 # define mach_type_known
205 # if defined(LINUX) && defined(__mc68000__)
207 # define mach_type_known
209 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
211 # define mach_type_known
213 # if defined(LINUX) && defined(__arm__)
215 # define mach_type_known
217 # if defined(LINUX) && defined(__sh__)
219 # define mach_type_known
221 # if defined(__alpha) || defined(__alpha__)
223 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
224 # define OSF1 /* a.k.a Digital Unix */
226 # define mach_type_known
228 # if defined(_AMIGA) && !defined(AMIGA)
233 # define mach_type_known
235 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
238 # define mach_type_known
240 # if defined(__MWERKS__) && defined(__powerc)
243 # define mach_type_known
245 # if defined(macosx) || \
246 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
249 # define mach_type_known
251 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
254 --> Not really supported
, but at least we recognize it
.
256 # if defined(NeXT) && defined(mc68000)
259 # define mach_type_known
261 # if defined(NeXT) && (defined(i386) || defined(__i386__))
264 # define mach_type_known
266 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
269 # define mach_type_known
271 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
273 # define mach_type_known
275 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
277 # define mach_type_known
279 # if defined(bsdi) && (defined(i386) || defined(__i386__))
282 # define mach_type_known
284 # if !defined(mach_type_known) && defined(__386BSD__)
287 # define mach_type_known
289 # if defined(_CX_UX) && defined(_M88K)
292 # define mach_type_known
297 # define mach_type_known
299 # if defined(_WIN32_WCE)
300 /* SH3, SH4, MIPS already defined for corresponding architectures */
301 # if defined(SH3) || defined(SH4)
311 # define mach_type_known
313 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
314 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
316 # define MSWIN32 /* or Win32s */
317 # define mach_type_known
320 # if defined(__DJGPP__)
323 # define DJGPP /* MSDOS running the DJGPP port of GCC */
325 # define mach_type_known
327 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
330 # define mach_type_known
332 # if defined(__MINGW32__)
335 # define mach_type_known
337 # if defined(__BORLANDC__)
340 # define mach_type_known
342 # if defined(_UTS) && !defined(mach_type_known)
345 # define mach_type_known
349 # define mach_type_known
351 # if defined(__embedded__) && defined(PPC)
354 # define mach_type_known
357 # if defined(__WATCOMC__) && defined(__386__)
359 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
360 # if defined(__OS2__)
363 # if defined(__WINDOWS_386__) || defined(__NT__)
370 # define mach_type_known
372 # if defined(__s390__) && defined(LINUX)
374 # define mach_type_known
376 # if defined(__GNU__)
377 # if defined(__i386__)
378 /* The Debian Hurd running on generic PC */
381 # define mach_type_known
385 /* Feel free to add more clauses here */
387 /* Or manually define the machine type here. A machine type is */
388 /* characterized by the architecture. Some */
389 /* machine types are further subdivided by OS. */
390 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
391 /* Note that SGI IRIX is treated identically to RISCOS. */
392 /* SYSV on an M68K actually means A/UX. */
393 /* The distinction in these cases is usually the stack starting address */
394 # ifndef mach_type_known
395 --> unknown machine type
397 /* Mapping is: M68K ==> Motorola 680X0 */
398 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
399 /* MACOS and AMIGA variants) */
400 /* I386 ==> Intel 386 */
401 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
402 /* FREEBSD, THREE86BSD, MSWIN32, */
403 /* BSDI,SUNOS5, NEXT, other variants) */
404 /* NS32K ==> Encore Multimax */
405 /* MIPS ==> R2000 or R3000 */
406 /* (RISCOS, ULTRIX variants) */
407 /* VAX ==> DEC VAX */
408 /* (BSD, ULTRIX variants) */
409 /* RS6000 ==> IBM RS/6000 AIX3.X */
410 /* RT ==> IBM PC/RT */
411 /* HP_PA ==> HP9000/700 & /800 */
413 /* SPARC ==> SPARC v7/v8/v9 */
414 /* (SUNOS4, SUNOS5, LINUX, */
415 /* DRSNX variants) */
416 /* ALPHA ==> DEC Alpha */
417 /* (OSF1 and LINUX variants) */
418 /* M88K ==> Motorola 88XX0 */
419 /* (CX_UX and DGUX) */
420 /* S370 ==> 370-like machine */
421 /* running Amdahl UTS4 */
422 /* S390 ==> 390-like machine */
424 /* ARM32 ==> Intel StrongARM */
425 /* IA64 ==> Intel IPF */
427 /* (LINUX and HPUX) */
428 /* IA64_32 ==> IA64 w/32 bit ABI */
430 /* SH ==> Hitachi SuperH */
431 /* (LINUX & MSWINCE) */
432 /* X86_64 ==> AMD x86-64 */
436 * For each architecture and OS, the following need to be defined:
438 * CPP_WORD_SZ is a simple integer constant representing the word size.
439 * in bits. We assume byte addressibility, where a byte has 8 bits.
440 * We also assume CPP_WORD_SZ is either 32 or 64.
441 * (We care about the length of pointers, not hardware
442 * bus widths. Thus a 64 bit processor with a C compiler that uses
443 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
445 * MACH_TYPE is a string representation of the machine type.
446 * OS_TYPE is analogous for the OS.
448 * ALIGNMENT is the largest N, such that
449 * all pointer are guaranteed to be aligned on N byte boundaries.
450 * defining it to be 1 will always work, but perform poorly.
452 * DATASTART is the beginning of the data segment.
453 * On UNIX systems, the collector will scan the area between DATASTART
454 * and DATAEND for root pointers.
456 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
457 * RTH suggests gaining access to linker script synth'd values with
458 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
459 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
460 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
461 * without any special options.
463 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
466 * STACKBOTTOM is the cool end of the stack, which is usually the
467 * highest address in the stack.
468 * Under PCR or OS/2, we have other ways of finding thread stacks.
469 * For each machine, the following should:
470 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
471 * 2) define exactly one of
472 * STACKBOTTOM (should be defined to be an expression)
475 * If either of the last two macros are defined, then STACKBOTTOM is computed
476 * during collector startup using one of the following two heuristics:
477 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
478 * the next multiple of STACK_GRAN.
479 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
480 * in small steps (decrement if STACK_GROWS_UP), and read the value
481 * at each location. Remember the value when the first
482 * Segmentation violation or Bus error is signalled. Round that
483 * to the nearest plausible page boundary, and use that instead
486 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
487 * the value of environ is a pointer that can serve as STACKBOTTOM.
488 * I expect that HEURISTIC2 can be replaced by this approach, which
489 * interferes far less with debugging. However it has the disadvantage
490 * that it's confused by a putenv call before the collector is initialized.
491 * This could be dealt with by intercepting putenv ...
493 * If no expression for STACKBOTTOM can be found, and neither of the above
494 * heuristics are usable, the collector can still be used with all of the above
495 * undefined, provided one of the following is done:
496 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
497 * without reference to STACKBOTTOM. This is appropriate for use in
498 * conjunction with thread packages, since there will be multiple stacks.
499 * (Allocating thread stacks in the heap, and treating them as ordinary
500 * heap data objects is also possible as a last resort. However, this is
501 * likely to introduce significant amounts of excess storage retention
502 * unless the dead parts of the thread stacks are periodically cleared.)
503 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
504 * If the author of the client code controls the main program, this is
505 * easily accomplished by introducing a new main program, setting
506 * GC_stackbottom to the address of a local variable, and then calling
507 * the original main program. The new main program would read something
510 * # include "gc_private.h"
512 * main(argc, argv, envp)
514 * char **argv, **envp;
518 * GC_stackbottom = (ptr_t)(&dummy);
519 * return(real_main(argc, argv, envp));
523 * Each architecture may also define the style of virtual dirty bit
524 * implementation to be used:
525 * MPROTECT_VDB: Write protect the heap and catch faults.
526 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
528 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
529 * defined GC_register_dynamic_libraries() for the architecture.
531 * An architecture may define PREFETCH(x) to preload the cache with *x.
532 * This defaults to a no-op.
534 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
536 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
537 * clear the two words at GC_malloc-aligned address x. By default,
538 * word stores of 0 are used instead.
541 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
542 * to push the relevant registers onto the stack. This generally makes
543 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
545 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
546 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
547 # define HAVE_BUILTIN_UNWIND_INIT
550 # define STACK_GRAN 0x1000000
552 # define MACH_TYPE "M68K"
555 # define OS_TYPE "OPENBSD"
558 # define DATASTART ((ptr_t)(etext))
561 # define OS_TYPE "NETBSD"
564 # define DATASTART ((ptr_t)(etext))
567 # define OS_TYPE "LINUX"
568 # define STACKBOTTOM ((ptr_t)0xf0000000)
569 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
571 # define DYNAMIC_LOADING
572 # include <features.h>
573 # if defined(__GLIBC__)&& __GLIBC__>=2
574 # define LINUX_DATA_START
576 extern char **__environ
;
577 # define DATASTART ((ptr_t)(&__environ))
578 /* hideous kludge: __environ is the first */
579 /* word in crt0.o, and delimits the start */
580 /* of the data segment, no matter which */
581 /* ld options were passed through. */
582 /* We could use _etext instead, but that */
583 /* would include .rodata, which may */
584 /* contain large read-only data tables */
585 /* that we'd rather not scan. */
586 # endif /* !GLIBC2 */
588 # define DATAEND (_end)
591 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
595 # define OS_TYPE "SUNOS4"
597 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
598 # define HEURISTIC1 /* differs */
599 # define DYNAMIC_LOADING
602 # define OS_TYPE "HP"
604 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
605 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
606 /* empirically determined. seems to work. */
608 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
611 # define OS_TYPE "SYSV"
613 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
615 +((word)etext & 0x1fff))
616 /* This only works for shared-text binaries with magic number 0413.
617 The other sorts of SysV binaries put the data at the end of the text,
618 in which case the default of etext would work. Unfortunately,
619 handling both would require having the magic-number available.
622 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
623 /* The stack starts at the top of memory, but */
624 /* 0x0 cannot be used as setjump_test complains */
625 /* that the stack direction is incorrect. Two */
626 /* bytes down from 0x0 should be safe enough. */
628 # include <sys/mmu.h>
629 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
632 # define OS_TYPE "AMIGA"
633 /* STACKBOTTOM and DATASTART handled specially */
635 # define DATAEND /* not needed */
636 # define GETPAGESIZE() 4096
642 # define OS_TYPE "MACOS"
643 /* see os_dep.c for details of global data segments. */
644 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
645 # define DATAEND /* not needed */
646 # define GETPAGESIZE() 4096
649 # define OS_TYPE "NEXT"
650 # define DATASTART ((ptr_t) get_etext())
651 # define STACKBOTTOM ((ptr_t) 0x4000000)
652 # define DATAEND /* not needed */
657 # define MACH_TYPE "POWERPC"
659 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
663 # define OS_TYPE "MACOS"
664 /* see os_dep.c for details of global data segments. */
665 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
666 # define DATAEND /* not needed */
669 # define ALIGNMENT 4 /* Guess. Can someone verify? */
670 /* This was 2, but that didn't sound right. */
671 # define OS_TYPE "LINUX"
673 # define DYNAMIC_LOADING
675 # define STACK_GRAN 0x10000000
676 /* Stack usually starts at 0x80000000 */
677 # define LINUX_DATA_START
679 # define DATAEND (_end)
682 /* There are reasons to suspect this may not be reliable. */
684 # define OS_TYPE "MACOSX"
685 # define DATASTART ((ptr_t) get_etext())
686 # define STACKBOTTOM ((ptr_t) 0xc0000000)
687 # define DATAEND /* not needed */
688 # define MPROTECT_VDB
690 # define GETPAGESIZE() getpagesize()
694 # define OS_TYPE "NETBSD"
697 # define DATASTART GC_data_start
698 # define DYNAMIC_LOADING
702 # define OS_TYPE "NOSYS"
703 extern void __end
[], __dso_handle
[];
704 # define DATASTART (__dso_handle) /* OK, that's ugly. */
705 # define DATAEND (__end)
706 /* Stack starts at 0xE0000000 for the simulator. */
708 # define STACK_GRAN 0x10000000
714 # define MACH_TYPE "VAX"
715 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
717 # define DATASTART ((ptr_t)(etext))
719 # define OS_TYPE "BSD"
721 /* HEURISTIC2 may be OK, but it's hard to test. */
724 # define OS_TYPE "ULTRIX"
725 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
730 # define MACH_TYPE "RT"
732 # define DATASTART ((ptr_t) 0x10000000)
733 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
737 # define MACH_TYPE "SPARC"
738 # if defined(__arch64__) || defined(__sparcv9)
740 # define CPP_WORDSZ 64
741 # define ELF_CLASS ELFCLASS64
743 # define ALIGNMENT 4 /* Required by hardware */
744 # define CPP_WORDSZ 32
746 # define ALIGN_DOUBLE
748 # define OS_TYPE "SUNOS5"
751 extern char * GC_SysVGetDataStart();
752 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
753 # define DATAEND (_end)
754 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
756 /* Otherwise we now use calloc. Mmap may result in the */
757 /* heap interleaved with thread stacks, which can result in */
758 /* excessive blacklisting. Sbrk is unusable since it */
759 /* doesn't interact correctly with the system malloc. */
762 # define HEAP_START (ptr_t)0x40000000
764 # define HEAP_START DATAEND
767 /* HEURISTIC1 reportedly no longer works under 2.7. */
768 /* HEURISTIC2 probably works, but this appears to be preferable. */
769 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
770 /* installations that's undefined. We work around this with a */
772 # include <sys/vmparam.h>
774 /* This should work everywhere, but doesn't. */
775 # define STACKBOTTOM USRSTACK
780 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
781 /* getpagesize() appeared to be missing from at least one */
782 /* Solaris 5.4 installation. Weird. */
783 # define DYNAMIC_LOADING
786 # define OS_TYPE "SUNOS4"
787 /* [If you have a weak stomach, don't read this.] */
788 /* We would like to use: */
789 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
790 /* This fails occasionally, due to an ancient, but very */
791 /* persistent ld bug. etext is set 32 bytes too high. */
792 /* We instead read the text segment size from the a.out */
793 /* header, which happens to be mapped into our address space */
794 /* at the start of the text segment. The detective work here */
795 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
796 /* Serpette of INRIA. */
797 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
798 # define TEXTSTART 0x2000
799 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
800 # define MPROTECT_VDB
802 # define DYNAMIC_LOADING
805 # define OS_TYPE "DRSNX"
806 extern char * GC_SysVGetDataStart();
808 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
809 # define MPROTECT_VDB
810 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
811 # define DYNAMIC_LOADING
814 # define OS_TYPE "LINUX"
816 # define DYNAMIC_LOADING
818 Linux Sparc
/a
.out
not supported
822 # define DATAEND (_end)
825 /* libc_stack_end is not set reliably for sparc64 */
826 # define STACKBOTTOM ((ptr_t) 0x80000000000)
827 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
829 # define LINUX_STACKBOTTOM
830 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
834 # define OS_TYPE "OPENBSD"
835 # define STACKBOTTOM ((ptr_t) 0xf8000000)
837 # define DATASTART ((ptr_t)(etext))
840 # define OS_TYPE "NETBSD"
843 # define DATASTART GC_data_start
844 # define DYNAMIC_LOADING
847 # define DATASTART ((ptr_t)(etext))
853 # define MACH_TYPE "I386"
854 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
855 /* except Borland. The -a4 option fixes */
857 /* Ivan Demakov: For Watcom the option is -zp4. */
858 # ifndef SMALL_CONFIG
859 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
860 /* improvement on Pentiums. */
862 # ifdef HAVE_BUILTIN_UNWIND_INIT
863 # define USE_GENERIC_PUSH_REGS
866 # define OS_TYPE "SEQUENT"
868 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
869 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
872 # define OS_TYPE "BEOS"
874 # define GETPAGESIZE() B_PAGE_SIZE
876 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
879 # define OS_TYPE "SUNOS5"
880 extern int _etext
[], _end
[];
881 extern char * GC_SysVGetDataStart();
882 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
883 # define DATAEND (_end)
884 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
885 /* but reportedly breaks under 2.8. It appears that the stack */
886 /* base is a property of the executable, so this should not break */
887 /* old executables. */
888 /* HEURISTIC2 probably works, but this appears to be preferable. */
890 # define STACKBOTTOM USRSTACK
891 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
892 /* It appears to be fixed in 2.8 and 2.9. */
893 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
896 # define DYNAMIC_LOADING
897 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
899 /* Otherwise we now use calloc. Mmap may result in the */
900 /* heap interleaved with thread stacks, which can result in */
901 /* excessive blacklisting. Sbrk is unusable since it */
902 /* doesn't interact correctly with the system malloc. */
905 # define HEAP_START (ptr_t)0x40000000
907 # define HEAP_START DATAEND
911 # define OS_TYPE "SCO"
913 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
915 +((word)etext & 0xfff))
916 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
919 # define OS_TYPE "SCO_ELF"
921 # define DATASTART ((ptr_t)(etext))
922 # define STACKBOTTOM ((ptr_t) 0x08048000)
923 # define DYNAMIC_LOADING
924 # define ELF_CLASS ELFCLASS32
928 /* The Intel compiler doesn't like inline assembly */
929 # define USE_GENERIC_PUSH_REGS
931 # define OS_TYPE "LINUX"
932 # define LINUX_STACKBOTTOM
936 # define STACK_GRAN 0x10000000
937 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
938 /* different kernel configurations. In particular, systems */
939 /* with 2GB physical memory will usually move the user */
940 /* address space limit, and hence initial SP to 0x80000000. */
942 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
943 # define MPROTECT_VDB
945 /* We seem to get random errors in incremental mode, */
946 /* possibly because Linux threads is itself a malloc client */
947 /* and can't deal with the signals. */
950 # define DYNAMIC_LOADING
951 # ifdef UNDEFINED /* includes ro data */
953 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
955 # include <features.h>
956 # if defined(__GLIBC__) && __GLIBC__ >= 2
957 # define LINUX_DATA_START
959 extern char **__environ
;
960 # define DATASTART ((ptr_t)(&__environ))
961 /* hideous kludge: __environ is the first */
962 /* word in crt0.o, and delimits the start */
963 /* of the data segment, no matter which */
964 /* ld options were passed through. */
965 /* We could use _etext instead, but that */
966 /* would include .rodata, which may */
967 /* contain large read-only data tables */
968 /* that we'd rather not scan. */
971 # define DATAEND (_end)
974 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
976 # ifdef USE_I686_PREFETCH
977 # define PREFETCH(x) \
978 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
979 /* Empirically prefetcht0 is much more effective at reducing */
980 /* cache miss stalls for the targetted load instructions. But it */
981 /* seems to interfere enough with other cache traffic that the net */
982 /* result is worse than prefetchnta. */
984 /* Using prefetches for write seems to have a slight negative */
985 /* impact on performance, at least for a PIII/500. */
986 # define PREFETCH_FOR_WRITE(x) \
987 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
990 # ifdef USE_3DNOW_PREFETCH
991 # define PREFETCH(x) \
992 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
993 # define PREFETCH_FOR_WRITE(x) \
994 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
998 # define OS_TYPE "CYGWIN32"
999 extern int _data_start__
[];
1000 extern int _data_end__
[];
1001 extern int _bss_start__
[];
1002 extern int _bss_end__
[];
1003 /* For binutils 2.9.1, we have */
1004 /* DATASTART = _data_start__ */
1005 /* DATAEND = _bss_end__ */
1006 /* whereas for some earlier versions it was */
1007 /* DATASTART = _bss_start__ */
1008 /* DATAEND = _data_end__ */
1009 /* To get it right for both, we take the */
1010 /* minumum/maximum of the two. */
1011 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1012 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1013 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1014 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1016 # define STACK_GRAN 0x10000
1020 # define OS_TYPE "OS2"
1021 /* STACKBOTTOM and DATASTART are handled specially in */
1022 /* os_dep.c. OS2 actually has the right */
1024 # define DATAEND /* not needed */
1025 # define USE_GENERIC_PUSH_REGS
1028 # define OS_TYPE "MSWIN32"
1029 /* STACKBOTTOM and DATASTART are handled specially in */
1031 # ifndef __WATCOMC__
1032 # define MPROTECT_VDB
1034 # define DATAEND /* not needed */
1037 # define OS_TYPE "MSWINCE"
1038 # define DATAEND /* not needed */
1041 # define OS_TYPE "DJGPP"
1042 # include "stubinfo.h"
1045 extern int __djgpp_stack_limit
;
1046 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1047 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1049 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1050 /* This may not be right. */
1053 # define OS_TYPE "OPENBSD"
1056 # define OS_TYPE "FREEBSD"
1057 # ifndef GC_FREEBSD_THREADS
1058 # define MPROTECT_VDB
1060 # define SIG_SUSPEND SIGUSR1
1061 # define SIG_THR_RESTART SIGUSR2
1062 # define FREEBSD_STACKBOTTOM
1064 # define DYNAMIC_LOADING
1066 /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */
1067 extern char etext
[];
1068 extern char edata
[];
1070 # define NEED_FIND_LIMIT
1071 # define DATASTART ((ptr_t)(etext))
1072 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1073 # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2))
1074 # define DATASTART2 ((ptr_t)(edata))
1075 # define DATAEND2 ((ptr_t)(end))
1078 # define OS_TYPE "NETBSD"
1080 # define DYNAMIC_LOADING
1084 # define OS_TYPE "THREE86BSD"
1087 # define OS_TYPE "BSDI"
1089 # if defined(OPENBSD) || defined(NETBSD) \
1090 || defined(THREE86BSD) || defined(BSDI)
1092 extern char etext
[];
1093 # define DATASTART ((ptr_t)(etext))
1096 # define OS_TYPE "NEXT"
1097 # define DATASTART ((ptr_t) get_etext())
1098 # define STACKBOTTOM ((ptr_t)0xc0000000)
1099 # define DATAEND /* not needed */
1102 # define OS_TYPE "DOS4GW"
1103 extern long __nullarea
;
1105 extern char *_STACKTOP
;
1106 /* Depending on calling conventions Watcom C either precedes
1107 or does not precedes with undescore names of C-variables.
1108 Make sure startup code variables always have the same names. */
1109 #pragma aux __nullarea "*";
1110 #pragma aux _end "*";
1111 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1112 /* confused? me too. */
1113 # define DATASTART ((ptr_t) &__nullarea)
1114 # define DATAEND ((ptr_t) &_end)
1117 # define OS_TYPE "HURD"
1118 # define STACK_GROWS_DOWN
1120 extern int __data_start
[];
1121 # define DATASTART ( (ptr_t) (__data_start))
1123 # define DATAEND ( (ptr_t) (_end))
1124 /* # define MPROTECT_VDB Not quite working yet? */
1125 # define DYNAMIC_LOADING
1130 # define MACH_TYPE "NS32K"
1131 # define ALIGNMENT 4
1132 extern char **environ
;
1133 # define DATASTART ((ptr_t)(&environ))
1134 /* hideous kludge: environ is the first */
1135 /* word in crt0.o, and delimits the start */
1136 /* of the data segment, no matter which */
1137 /* ld options were passed through. */
1138 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1142 # define MACH_TYPE "MIPS"
1144 /* This was developed for a linuxce style platform. Probably */
1145 /* needs to be tweaked for workstation class machines. */
1146 # define OS_TYPE "LINUX"
1147 # define DYNAMIC_LOADING
1149 # define DATAEND (_end)
1150 extern int __data_start
[];
1151 # define DATASTART ((ptr_t)(__data_start))
1152 # define ALIGNMENT 4
1153 # define USE_GENERIC_PUSH_REGS
1154 # define LINUX_STACKBOTTOM
1158 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1159 extern int _fdata
[], _end
[];
1160 # define DATASTART ((ptr_t)_fdata)
1161 # define DATAEND ((ptr_t)_end)
1162 # define CPP_WORDSZ _MIPS_SZPTR
1163 # define ALIGNMENT (_MIPS_SZPTR/8)
1165 extern int etext
[], edata
[], end
[];
1166 extern int _DYNAMIC_LINKING
[], _gp
[];
1167 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1168 + ((word)etext & 0xffff)))
1169 # define DATAEND (edata)
1170 # define DATASTART2 (_DYNAMIC_LINKING \
1171 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1173 # define DATAEND2 (end)
1174 # define ALIGNMENT 4
1176 # define OS_TYPE "EWS4800"
1177 # define USE_GENERIC_PUSH_REGS 1
1181 # define DATASTART (ptr_t)0x10000000
1182 /* Could probably be slightly higher since */
1183 /* startup code allocates lots of stuff. */
1184 # define OS_TYPE "ULTRIX"
1185 # define ALIGNMENT 4
1189 # define DATASTART (ptr_t)0x10000000
1190 # define OS_TYPE "RISCOS"
1191 # define ALIGNMENT 4 /* Required by hardware */
1195 extern int _fdata
[];
1196 # define DATASTART ((ptr_t)(_fdata))
1198 # define HEAP_START (ptr_t)0x30000000
1200 # define HEAP_START DATASTART
1202 /* Lowest plausible heap address. */
1203 /* In the MMAP case, we map there. */
1204 /* In either case it is used to identify */
1205 /* heap sections so they're not */
1206 /* considered as roots. */
1207 # define OS_TYPE "IRIX5"
1208 # define MPROTECT_VDB
1210 # define CPP_WORDSZ _MIPS_SZPTR
1211 # define ALIGNMENT (_MIPS_SZPTR/8)
1212 # if CPP_WORDSZ != 64
1213 # define ALIGN_DOUBLE
1216 # define ALIGNMENT 4
1217 # define ALIGN_DOUBLE
1219 # define DYNAMIC_LOADING
1222 # define OS_TYPE "MSWINCE"
1223 # define ALIGNMENT 4
1224 # define DATAEND /* not needed */
1226 # if defined(NETBSD)
1227 # define OS_TYPE "NETBSD"
1228 # define ALIGNMENT 4
1230 # define USE_GENERIC_PUSH_REGS
1231 extern int _fdata
[];
1232 # define DATASTART ((ptr_t)(_fdata))
1234 # define DATAEND ((ptr_t)(_end))
1235 # define DYNAMIC_LOADING
1240 # define MACH_TYPE "RS6000"
1242 # define ALIGNMENT 8
1243 # define CPP_WORDSZ 64
1245 # define ALIGNMENT 4
1246 # define CPP_WORDSZ 32
1248 extern int _data
[], _end
[];
1249 # define DATASTART ((ptr_t)((ulong)_data))
1250 # define DATAEND ((ptr_t)((ulong)_end))
1252 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1253 # define USE_GENERIC_PUSH_REGS
1254 # define DYNAMIC_LOADING
1255 /* For really old versions of AIX, this may have to be removed. */
1259 # define MACH_TYPE "HP_PA"
1261 # define CPP_WORDSZ 64
1262 # define ALIGNMENT 8
1264 # define CPP_WORDSZ 32
1265 # define ALIGNMENT 4
1266 # define ALIGN_DOUBLE
1268 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1269 # ifndef LINUX /* For now. */
1270 # define MPROTECT_VDB
1273 # define GENERIC_COMPARE_AND_SWAP
1274 /* No compare-and-swap instruction. Use pthread mutexes */
1275 /* when we absolutely have to. */
1276 # ifdef PARALLEL_MARK
1277 # define USE_MARK_BYTES
1278 /* Minimize compare-and-swap usage. */
1281 # define STACK_GROWS_UP
1283 # define OS_TYPE "HPUX"
1284 extern int __data_start
[];
1285 # define DATASTART ((ptr_t)(__data_start))
1287 /* The following appears to work for 7xx systems running HP/UX */
1288 /* 9.xx Furthermore, it might result in much faster */
1289 /* collections than HEURISTIC2, which may involve scanning */
1290 /* segments that directly precede the stack. It is not the */
1291 /* default, since it may not work on older machine/OS */
1292 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1294 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1296 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1297 /* to this. Note that the GC must be initialized before the */
1298 /* first putenv call. */
1299 extern char ** environ
;
1300 # define STACKBOTTOM ((ptr_t)environ)
1302 # define DYNAMIC_LOADING
1303 # include <unistd.h>
1304 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1306 # define PREFETCH(x) { \
1307 register long addr = (long)(x); \
1308 (void) _asm ("LDW", 0, 0, addr, 0); \
1313 # define OS_TYPE "LINUX"
1314 # define LINUX_STACKBOTTOM
1315 # define DYNAMIC_LOADING
1316 # define LINUX_DATA_START
1318 # define DATAEND (_end)
1323 # define MACH_TYPE "ALPHA"
1324 # define ALIGNMENT 8
1326 # define OS_TYPE "NETBSD"
1328 # define DATASTART GC_data_start
1329 # define ELFCLASS32 32
1330 # define ELFCLASS64 64
1331 # define ELF_CLASS ELFCLASS64
1332 # define CPP_WORDSZ 64
1333 # define DYNAMIC_LOADING
1336 # define OS_TYPE "OPENBSD"
1338 # define CPP_WORDSZ 64
1339 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1340 # define DATASTART GC_data_start
1341 # define ELFCLASS32 32
1342 # define ELFCLASS64 64
1343 # define ELF_CLASS ELFCLASS64
1344 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1345 # define DATASTART ((ptr_t) 0x140000000)
1349 # define OS_TYPE "FREEBSD"
1350 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1351 # define SIG_SUSPEND SIGUSR1
1352 # define SIG_THR_RESTART SIGUSR2
1353 # define FREEBSD_STACKBOTTOM
1355 # define DYNAMIC_LOADING
1357 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1358 extern char etext
[];
1359 extern char edata
[];
1361 # define NEED_FIND_LIMIT
1362 # define DATASTART ((ptr_t)(etext))
1363 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1364 # define DATASTART2 ((ptr_t)(edata))
1365 # define DATAEND2 ((ptr_t)(end))
1366 # define CPP_WORDSZ 64
1369 # define OS_TYPE "OSF1"
1370 # define DATASTART ((ptr_t) 0x140000000)
1372 # define DATAEND ((ptr_t) _end)
1373 extern char ** environ
;
1374 /* round up from the value of environ to the nearest page boundary */
1375 /* Probably breaks if putenv is called before collector */
1376 /* initialization. */
1377 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1378 /* # define HEURISTIC2 */
1379 /* Normally HEURISTIC2 is too conervative, since */
1380 /* the text segment immediately follows the stack. */
1381 /* Hence we give an upper pound. */
1382 /* This is currently unused, since we disabled HEURISTIC2 */
1383 extern int __start
[];
1384 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1385 # define CPP_WORDSZ 64
1386 # define MPROTECT_VDB
1387 # define DYNAMIC_LOADING
1390 # define OS_TYPE "LINUX"
1391 # define CPP_WORDSZ 64
1392 # define STACKBOTTOM ((ptr_t) 0x120000000)
1394 # define SEARCH_FOR_DATA_START
1395 # define DATASTART GC_data_start
1396 # define DYNAMIC_LOADING
1398 # define DATASTART ((ptr_t) 0x140000000)
1401 # define DATAEND (_end)
1402 # define MPROTECT_VDB
1403 /* Has only been superficially tested. May not */
1404 /* work on all versions. */
1409 # define MACH_TYPE "IA64"
1410 # define USE_GENERIC_PUSH_REGS
1411 /* We need to get preserved registers in addition to register */
1412 /* windows. That's easiest to do with setjmp. */
1413 # ifdef PARALLEL_MARK
1414 # define USE_MARK_BYTES
1415 /* Compare-and-exchange is too expensive to use for */
1416 /* setting mark bits. */
1420 # define CPP_WORDSZ 32
1421 # define ALIGN_DOUBLE
1422 /* Requires 8 byte alignment for malloc */
1423 # define ALIGNMENT 4
1428 # define CPP_WORDSZ 64
1429 # define ALIGN_DOUBLE
1430 /* Requires 16 byte alignment for malloc */
1431 # define ALIGNMENT 8
1433 # define OS_TYPE "HPUX"
1434 extern int __data_start
[];
1435 # define DATASTART ((ptr_t)(__data_start))
1436 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1437 /* to this. Note that the GC must be initialized before the */
1438 /* first putenv call. */
1439 extern char ** environ
;
1440 # define STACKBOTTOM ((ptr_t)environ)
1441 # define DYNAMIC_LOADING
1442 # include <unistd.h>
1443 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1444 /* The following was empirically determined, and is probably */
1445 /* not very robust. */
1446 /* Note that the backing store base seems to be at a nice */
1447 /* address minus one page. */
1448 # define BACKING_STORE_DISPLACEMENT 0x1000000
1449 # define BACKING_STORE_ALIGNMENT 0x1000
1450 # define BACKING_STORE_BASE \
1451 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1452 & ~(BACKING_STORE_ALIGNMENT - 1))
1455 # define CPP_WORDSZ 64
1456 # define ALIGN_DOUBLE
1457 /* Requires 16 byte alignment for malloc */
1458 # define ALIGNMENT 8
1459 # define OS_TYPE "LINUX"
1460 /* The following works on NUE and older kernels: */
1461 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1462 /* This does not work on NUE: */
1463 # define LINUX_STACKBOTTOM
1464 /* We also need the base address of the register stack */
1465 /* backing store. This is computed in */
1466 /* GC_linux_register_stack_base based on the following */
1468 # define BACKING_STORE_ALIGNMENT 0x100000
1469 # define BACKING_STORE_DISPLACEMENT 0x80000000
1470 extern char * GC_register_stackbottom
;
1471 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1472 # define SEARCH_FOR_DATA_START
1473 # define DATASTART GC_data_start
1475 # define DYNAMIC_LOADING
1477 /* In the Intel compiler environment, we seem to end up with */
1478 /* statically linked executables and an undefined reference */
1481 # define MPROTECT_VDB
1482 /* Requires Linux 2.3.47 or later. */
1484 # define DATAEND (_end)
1486 # define PREFETCH(x) \
1487 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1488 # define PREFETCH_FOR_WRITE(x) \
1489 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1490 # define CLEAR_DOUBLE(x) \
1491 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1497 # define MACH_TYPE "M88K"
1498 # define ALIGNMENT 4
1499 # define ALIGN_DOUBLE
1502 # define OS_TYPE "CX_UX"
1503 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1506 # define OS_TYPE "DGUX"
1507 extern char * GC_SysVGetDataStart();
1508 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1510 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1514 # define MACH_TYPE "S370"
1515 # define ALIGNMENT 4 /* Required by hardware */
1516 # define USE_GENERIC_PUSH_REGS
1518 # define OS_TYPE "UTS4"
1520 extern int _etext
[];
1522 extern char * GC_SysVGetDataStart();
1523 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1524 # define DATAEND (_end)
1530 # define MACH_TYPE "S390"
1531 # define USE_GENERIC_PUSH_REGS
1533 # define ALIGNMENT 4
1534 # define CPP_WORDSZ 32
1536 # define ALIGNMENT 8
1537 # define CPP_WORDSZ 64
1538 # define HBLKSIZE 4096
1541 # define OS_TYPE "LINUX"
1542 # define LINUX_STACKBOTTOM
1543 # define DYNAMIC_LOADING
1544 extern int __data_start
[];
1545 # define DATASTART ((ptr_t)(__data_start))
1547 # define DATAEND (_end)
1548 # define CACHE_LINE_SIZE 256
1549 # define GETPAGESIZE() 4096
1554 # define ALIGNMENT 4
1555 extern int _etext
[];
1556 # define DATASTART ((ptr_t)(_etext))
1561 # define CPP_WORDSZ 32
1562 # define MACH_TYPE "ARM32"
1563 # define ALIGNMENT 4
1565 # define OS_TYPE "NETBSD"
1567 extern char etext
[];
1568 # define DATASTART ((ptr_t)(etext))
1569 # define USE_GENERIC_PUSH_REGS
1572 # define OS_TYPE "LINUX"
1575 # define STACK_GRAN 0x10000000
1576 # define USE_GENERIC_PUSH_REGS
1578 # define DYNAMIC_LOADING
1579 # include <features.h>
1580 # if defined(__GLIBC__) && __GLIBC__ >= 2
1581 # define LINUX_DATA_START
1583 extern char **__environ
;
1584 # define DATASTART ((ptr_t)(&__environ))
1585 /* hideous kludge: __environ is the first */
1586 /* word in crt0.o, and delimits the start */
1587 /* of the data segment, no matter which */
1588 /* ld options were passed through. */
1589 /* We could use _etext instead, but that */
1590 /* would include .rodata, which may */
1591 /* contain large read-only data tables */
1592 /* that we'd rather not scan. */
1595 # define DATAEND (_end)
1598 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1602 # define OS_TYPE "MSWINCE"
1603 # define DATAEND /* not needed */
1606 /* __data_start is usually defined in the target linker script. */
1607 extern int __data_start
[];
1608 # define DATASTART (ptr_t)(__data_start)
1609 # define USE_GENERIC_PUSH_REGS
1610 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1611 extern void *__stack_base__
;
1612 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1617 # define MACH_TYPE "SH"
1618 # define ALIGNMENT 4
1620 # define OS_TYPE "MSWINCE"
1621 # define DATAEND /* not needed */
1624 # define OS_TYPE "LINUX"
1625 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1626 # define USE_GENERIC_PUSH_REGS
1627 # define DYNAMIC_LOADING
1628 # define LINUX_DATA_START
1630 # define DATAEND (_end)
1635 # define MACH_TYPE "SH4"
1636 # define OS_TYPE "MSWINCE"
1637 # define ALIGNMENT 4
1638 # define DATAEND /* not needed */
1642 # define MACH_TYPE "X86_64"
1643 # define ALIGNMENT 8
1644 # define CPP_WORDSZ 64
1645 # define CACHE_LINE_SIZE 64
1646 # define USE_GENERIC_PUSH_REGS
1648 # define OS_TYPE "LINUX"
1649 # define LINUX_STACKBOTTOM
1650 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1651 # define MPROTECT_VDB
1653 /* We seem to get random errors in incremental mode, */
1654 /* possibly because Linux threads is itself a malloc client */
1655 /* and can't deal with the signals. */
1658 # define DYNAMIC_LOADING
1659 # ifdef UNDEFINED /* includes ro data */
1660 extern int _etext
[];
1661 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1663 # include <features.h>
1664 # define LINUX_DATA_START
1666 # define DATAEND (_end)
1669 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1671 # define PREFETCH(x) \
1672 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1673 # define PREFETCH_FOR_WRITE(x) \
1674 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1678 #ifdef LINUX_DATA_START
1679 /* Some Linux distributions arrange to define __data_start. Some */
1680 /* define data_start as a weak symbol. The latter is technically */
1681 /* broken, since the user program may define data_start, in which */
1682 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1683 /* We assume gcc. */
1684 # pragma weak __data_start
1685 extern int __data_start
[];
1686 # pragma weak data_start
1687 extern int data_start
[];
1688 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1691 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1692 /* Rld appears to allocate some memory with its own allocator, and */
1693 /* some through malloc, which might be redirected. To make this */
1694 /* work with collectable memory, we have to scan memory allocated */
1695 /* by rld's internal malloc. */
1696 # define USE_PROC_FOR_LIBRARIES
1699 # ifndef STACK_GROWS_UP
1700 # define STACK_GROWS_DOWN
1704 # define CPP_WORDSZ 32
1713 # define DATAEND (end)
1716 # if defined(SVR4) && !defined(GETPAGESIZE)
1717 # include <unistd.h>
1718 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1721 # ifndef GETPAGESIZE
1722 # if defined(SUNOS5) || defined(IRIX5)
1723 # include <unistd.h>
1725 # define GETPAGESIZE() getpagesize()
1728 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1729 /* OS has SVR4 generic features. Probably others also qualify. */
1733 # if defined(SUNOS5) || defined(DRSNX)
1734 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1737 /* OS has SUNOS5 style signal handlers. */
1745 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1746 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1747 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1748 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1751 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1756 # undef DYNAMIC_LOADING
1761 # undef MPROTECT_VDB
1766 /* Postponed for now. */
1768 # undef MPROTECT_VDB
1771 # ifdef SMALL_CONFIG
1772 /* Presumably not worth the space it takes. */
1774 # undef MPROTECT_VDB
1778 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1781 # ifdef PARALLEL_MARK
1782 # undef MPROTECT_VDB /* For now. */
1785 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1786 # define DEFAULT_VDB
1790 # define PREFETCH(x)
1791 # define NO_PREFETCH
1794 # ifndef PREFETCH_FOR_WRITE
1795 # define PREFETCH_FOR_WRITE(x)
1796 # define NO_PREFETCH_FOR_WRITE
1799 # ifndef CACHE_LINE_SIZE
1800 # define CACHE_LINE_SIZE 32 /* Wild guess */
1803 # ifndef CLEAR_DOUBLE
1804 # define CLEAR_DOUBLE(x) \
1805 ((word*)x)[0] = 0; \
1807 # endif /* CLEAR_DOUBLE */
1809 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1810 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1811 # define GC_SOLARIS_THREADS
1814 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1815 --> inconsistent configuration
1817 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1818 --> inconsistent configuration
1820 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1821 --> inconsistent configuration
1823 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1824 --> inconsistent configuration
1826 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1827 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1828 /* the necessary code is mostly there, but nobody has actually made */
1829 /* sure the right combination of pieces is compiled in, etc. */
1830 --> inconsistent configuration
1833 # if defined(PCR) || defined(SRC_M3) || \
1834 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1835 defined(GC_PTHREADS)
1839 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1840 || defined(LINT) || defined(MSWINCE) \
1841 || (defined(I386) && defined(__LCC__))
1842 /* Use setjmp based hack to mark from callee-save registers. */
1843 /* The define should move to the individual platform */
1845 # define USE_GENERIC_PUSH_REGS
1849 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1850 /* include assembly code to do it well. */
1853 /* Can we save call chain in objects for debugging? */
1854 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1855 /* to reasonable values for the platform. */
1856 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1857 /* build time, though we feel free to adjust it slightly. */
1858 /* Define NEED_CALLINFO if we either save the call stack or */
1859 /* GC_ADD_CALLER is defined. */
1861 # include <features.h>
1862 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1863 # define HAVE_BUILTIN_BACKTRACE
1868 # define CAN_SAVE_CALL_STACKS
1869 # define CAN_SAVE_CALL_ARGS
1871 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1872 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1873 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1874 # define CAN_SAVE_CALL_STACKS
1875 # define CAN_SAVE_CALL_ARGS
1877 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1878 # define CAN_SAVE_CALL_STACKS
1881 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1882 && defined(CAN_SAVE_CALL_STACKS)
1883 # define SAVE_CALL_CHAIN
1885 # ifdef SAVE_CALL_CHAIN
1886 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1887 # define NARGS SAVE_CALL_NARGS
1889 # define NARGS 0 /* Number of arguments to save for each call. */
1892 # ifdef SAVE_CALL_CHAIN
1893 # ifndef SAVE_CALL_COUNT
1894 # define NFRAMES 6 /* Number of frames to save. Even for */
1895 /* alignment reasons. */
1897 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1899 # define NEED_CALLINFO
1900 # endif /* SAVE_CALL_CHAIN */
1901 # ifdef GC_ADD_CALLER
1904 # define NEED_CALLINFO
1907 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1908 # define DBG_HDRS_ALL
1911 # endif /* GCCONFIG_H */