2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
5 * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
21 /* Machine dependent parameters. Some tuning parameters can be found */
22 /* near the top of gc_private.h. */
24 /* Machine specific parts contributed by various people. See README file. */
26 /* First a unified test for Linux: */
27 # if defined(linux) || defined(__linux__)
31 /* And one for NetBSD: */
32 # if defined(__NetBSD__)
36 /* And one for OpenBSD: */
37 # if defined(__OpenBSD__)
41 /* And one for FreeBSD: */
42 # if defined(__FreeBSD__)
46 /* Determine the machine type: */
47 # if defined(__XSCALE__)
51 # define mach_type_known
54 # if defined(sun) && defined(mc68000)
57 # define mach_type_known
59 # if defined(hp9000s300)
62 # define mach_type_known
64 # if defined(OPENBSD) && defined(m68k)
66 # define mach_type_known
68 # if defined(OPENBSD) && defined(__sparc__)
70 # define mach_type_known
72 # if defined(NETBSD) && defined(m68k)
74 # define mach_type_known
76 # if defined(NETBSD) && defined(__powerpc__)
78 # define mach_type_known
80 # if defined(NETBSD) && defined(__arm32__)
82 # define mach_type_known
91 # define mach_type_known
93 # if defined(mips) || defined(__mips) || defined(_mips)
95 # if defined(nec_ews) || defined(_nec_ews)
98 # if !defined(LINUX) && !defined(EWS4800)
99 # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
102 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
103 || defined(__SYSTYPE_SVR4__)
104 # define IRIX5 /* or IRIX 6.X */
106 # define RISCOS /* or IRIX 4.X */
110 # if defined(__NetBSD__) && defined(__MIPSEL__)
113 # define mach_type_known
115 # if defined(sequent) && (defined(i386) || defined(__i386__))
118 # define mach_type_known
120 # if defined(sun) && (defined(i386) || defined(__i386__))
123 # define mach_type_known
125 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
128 # define mach_type_known
132 # define mach_type_known
134 # if defined(sun) && (defined(sparc) || defined(__sparc))
136 /* Test for SunOS 5.x */
143 # define mach_type_known
145 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
146 && !defined(__OpenBSD__) && !(__NetBSD__)
149 # define mach_type_known
153 # define mach_type_known
155 # if defined(__NetBSD__) && defined(__sparc__)
157 # define mach_type_known
159 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
160 /* The above test may need refinement */
162 # if defined(_SCO_ELF)
167 # define mach_type_known
169 # if defined(_AUX_SOURCE)
172 # define mach_type_known
174 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
175 || defined(hppa) || defined(__hppa__)
180 # define mach_type_known
182 # if defined(__ia64) && defined(_HPUX_SOURCE)
185 # define mach_type_known
187 # if defined(__BEOS__) && defined(_X86_)
190 # define mach_type_known
192 # if defined(LINUX) && (defined(i386) || defined(__i386__))
194 # define mach_type_known
196 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
198 # define mach_type_known
200 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
202 # define mach_type_known
204 # if defined(LINUX) && defined(__mc68000__)
206 # define mach_type_known
208 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
210 # define mach_type_known
212 # if defined(LINUX) && defined(__arm__)
214 # define mach_type_known
216 # if defined(LINUX) && defined(__sh__)
218 # define mach_type_known
220 # if defined(__alpha) || defined(__alpha__)
222 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
223 # define OSF1 /* a.k.a Digital Unix */
225 # define mach_type_known
227 # if defined(_AMIGA) && !defined(AMIGA)
232 # define mach_type_known
234 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
237 # define mach_type_known
239 # if defined(__MWERKS__) && defined(__powerc)
242 # define mach_type_known
244 # if defined(macosx) || \
245 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
248 # define mach_type_known
250 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
253 --> Not really supported, but at least we recognize it.
255 # if defined(NeXT) && defined(mc68000)
258 # define mach_type_known
260 # if defined(NeXT) && (defined(i386) || defined(__i386__))
263 # define mach_type_known
265 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
268 # define mach_type_known
270 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
272 # define mach_type_known
274 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
276 # define mach_type_known
278 # if defined(bsdi) && (defined(i386) || defined(__i386__))
281 # define mach_type_known
283 # if !defined(mach_type_known) && defined(__386BSD__)
286 # define mach_type_known
288 # if defined(_CX_UX) && defined(_M88K)
291 # define mach_type_known
296 # define mach_type_known
298 # if defined(_WIN32_WCE)
299 /* SH3, SH4, MIPS already defined for corresponding architectures */
300 # if defined(SH3) || defined(SH4)
310 # define mach_type_known
312 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
313 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
315 # define MSWIN32 /* or Win32s */
316 # define mach_type_known
319 # if defined(__DJGPP__)
322 # define DJGPP /* MSDOS running the DJGPP port of GCC */
324 # define mach_type_known
326 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
329 # define mach_type_known
331 # if defined(__MINGW32__)
334 # define mach_type_known
336 # if defined(__BORLANDC__)
339 # define mach_type_known
341 # if defined(_UTS) && !defined(mach_type_known)
344 # define mach_type_known
348 # define mach_type_known
350 # if defined(__embedded__) && defined(PPC)
353 # define mach_type_known
356 # if defined(__WATCOMC__) && defined(__386__)
358 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
359 # if defined(__OS2__)
362 # if defined(__WINDOWS_386__) || defined(__NT__)
369 # define mach_type_known
371 # if defined(__s390__) && defined(LINUX)
373 # define mach_type_known
375 # if defined(__GNU__)
376 # if defined(__i386__)
377 /* The Debian Hurd running on generic PC */
380 # define mach_type_known
384 /* Feel free to add more clauses here */
386 /* Or manually define the machine type here. A machine type is */
387 /* characterized by the architecture. Some */
388 /* machine types are further subdivided by OS. */
389 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
390 /* Note that SGI IRIX is treated identically to RISCOS. */
391 /* SYSV on an M68K actually means A/UX. */
392 /* The distinction in these cases is usually the stack starting address */
393 # ifndef mach_type_known
394 --> unknown machine type
396 /* Mapping is: M68K ==> Motorola 680X0 */
397 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
398 /* MACOS and AMIGA variants) */
399 /* I386 ==> Intel 386 */
400 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
401 /* FREEBSD, THREE86BSD, MSWIN32, */
402 /* BSDI,SUNOS5, NEXT, other variants) */
403 /* NS32K ==> Encore Multimax */
404 /* MIPS ==> R2000 or R3000 */
405 /* (RISCOS, ULTRIX variants) */
406 /* VAX ==> DEC VAX */
407 /* (BSD, ULTRIX variants) */
408 /* RS6000 ==> IBM RS/6000 AIX3.X */
409 /* RT ==> IBM PC/RT */
410 /* HP_PA ==> HP9000/700 & /800 */
412 /* SPARC ==> SPARC v7/v8/v9 */
413 /* (SUNOS4, SUNOS5, LINUX, */
414 /* DRSNX variants) */
415 /* ALPHA ==> DEC Alpha */
416 /* (OSF1 and LINUX variants) */
417 /* M88K ==> Motorola 88XX0 */
418 /* (CX_UX and DGUX) */
419 /* S370 ==> 370-like machine */
420 /* running Amdahl UTS4 */
421 /* or a 390 running LINUX */
422 /* ARM32 ==> Intel StrongARM */
423 /* IA64 ==> Intel IPF */
425 /* (LINUX and HPUX) */
426 /* IA64_32 ==> IA64 w/32 bit ABI */
428 /* SH ==> Hitachi SuperH */
429 /* (LINUX & MSWINCE) */
433 * For each architecture and OS, the following need to be defined:
435 * CPP_WORD_SZ is a simple integer constant representing the word size.
436 * in bits. We assume byte addressibility, where a byte has 8 bits.
437 * We also assume CPP_WORD_SZ is either 32 or 64.
438 * (We care about the length of pointers, not hardware
439 * bus widths. Thus a 64 bit processor with a C compiler that uses
440 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
442 * MACH_TYPE is a string representation of the machine type.
443 * OS_TYPE is analogous for the OS.
445 * ALIGNMENT is the largest N, such that
446 * all pointer are guaranteed to be aligned on N byte boundaries.
447 * defining it to be 1 will always work, but perform poorly.
449 * DATASTART is the beginning of the data segment.
450 * On UNIX systems, the collector will scan the area between DATASTART
451 * and DATAEND for root pointers.
453 * DATAEND, if not &end.
455 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
458 * STACKBOTTOM is the cool end of the stack, which is usually the
459 * highest address in the stack.
460 * Under PCR or OS/2, we have other ways of finding thread stacks.
461 * For each machine, the following should:
462 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
463 * 2) define exactly one of
464 * STACKBOTTOM (should be defined to be an expression)
467 * If either of the last two macros are defined, then STACKBOTTOM is computed
468 * during collector startup using one of the following two heuristics:
469 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
470 * the next multiple of STACK_GRAN.
471 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
472 * in small steps (decrement if STACK_GROWS_UP), and read the value
473 * at each location. Remember the value when the first
474 * Segmentation violation or Bus error is signalled. Round that
475 * to the nearest plausible page boundary, and use that instead
478 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
479 * the value of environ is a pointer that can serve as STACKBOTTOM.
480 * I expect that HEURISTIC2 can be replaced by this approach, which
481 * interferes far less with debugging. However it has the disadvantage
482 * that it's confused by a putenv call before the collector is initialized.
483 * This could be dealt with by intercepting putenv ...
485 * If no expression for STACKBOTTOM can be found, and neither of the above
486 * heuristics are usable, the collector can still be used with all of the above
487 * undefined, provided one of the following is done:
488 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
489 * without reference to STACKBOTTOM. This is appropriate for use in
490 * conjunction with thread packages, since there will be multiple stacks.
491 * (Allocating thread stacks in the heap, and treating them as ordinary
492 * heap data objects is also possible as a last resort. However, this is
493 * likely to introduce significant amounts of excess storage retention
494 * unless the dead parts of the thread stacks are periodically cleared.)
495 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
496 * If the author of the client code controls the main program, this is
497 * easily accomplished by introducing a new main program, setting
498 * GC_stackbottom to the address of a local variable, and then calling
499 * the original main program. The new main program would read something
502 * # include "gc_private.h"
504 * main(argc, argv, envp)
506 * char **argv, **envp;
510 * GC_stackbottom = (ptr_t)(&dummy);
511 * return(real_main(argc, argv, envp));
515 * Each architecture may also define the style of virtual dirty bit
516 * implementation to be used:
517 * MPROTECT_VDB: Write protect the heap and catch faults.
518 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
520 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
521 * defined GC_register_dynamic_libraries() for the architecture.
523 * An architecture may define PREFETCH(x) to preload the cache with *x.
524 * This defaults to a no-op.
526 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
528 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
529 * clear the two words at GC_malloc-aligned address x. By default,
530 * word stores of 0 are used instead.
533 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
534 * to push the relevant registers onto the stack. This generally makes
535 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
537 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
538 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
539 # define HAVE_BUILTIN_UNWIND_INIT
542 # define STACK_GRAN 0x1000000
544 # define MACH_TYPE "M68K"
547 # define OS_TYPE "OPENBSD"
550 # define DATASTART ((ptr_t)(&etext))
553 # define OS_TYPE "NETBSD"
556 # define DATASTART ((ptr_t)(&etext))
559 # define OS_TYPE "LINUX"
560 # define STACKBOTTOM ((ptr_t)0xf0000000)
561 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
563 # define DYNAMIC_LOADING
564 # include <features.h>
565 # if defined(__GLIBC__)&& __GLIBC__>=2
566 # define LINUX_DATA_START
568 extern char **__environ;
569 # define DATASTART ((ptr_t)(&__environ))
570 /* hideous kludge: __environ is the first */
571 /* word in crt0.o, and delimits the start */
572 /* of the data segment, no matter which */
573 /* ld options were passed through. */
574 /* We could use _etext instead, but that */
575 /* would include .rodata, which may */
576 /* contain large read-only data tables */
577 /* that we'd rather not scan. */
578 # endif /* !GLIBC2 */
580 # define DATAEND (&_end)
583 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
587 # define OS_TYPE "SUNOS4"
589 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
590 # define HEURISTIC1 /* differs */
591 # define DYNAMIC_LOADING
594 # define OS_TYPE "HP"
596 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
597 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
598 /* empirically determined. seems to work. */
600 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
603 # define OS_TYPE "SYSV"
605 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
607 +((word)&etext & 0x1fff))
608 /* This only works for shared-text binaries with magic number 0413.
609 The other sorts of SysV binaries put the data at the end of the text,
610 in which case the default of &etext would work. Unfortunately,
611 handling both would require having the magic-number available.
614 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
615 /* The stack starts at the top of memory, but */
616 /* 0x0 cannot be used as setjump_test complains */
617 /* that the stack direction is incorrect. Two */
618 /* bytes down from 0x0 should be safe enough. */
620 # include <sys/mmu.h>
621 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
624 # define OS_TYPE "AMIGA"
625 /* STACKBOTTOM and DATASTART handled specially */
627 # define DATAEND /* not needed */
628 # define GETPAGESIZE() 4096
634 # define OS_TYPE "MACOS"
635 /* see os_dep.c for details of global data segments. */
636 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
637 # define DATAEND /* not needed */
638 # define GETPAGESIZE() 4096
641 # define OS_TYPE "NEXT"
642 # define DATASTART ((ptr_t) get_etext())
643 # define STACKBOTTOM ((ptr_t) 0x4000000)
644 # define DATAEND /* not needed */
649 # define MACH_TYPE "POWERPC"
651 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
655 # define OS_TYPE "MACOS"
656 /* see os_dep.c for details of global data segments. */
657 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
658 # define DATAEND /* not needed */
661 # define ALIGNMENT 4 /* Guess. Can someone verify? */
662 /* This was 2, but that didn't sound right. */
663 # define OS_TYPE "LINUX"
665 # define DYNAMIC_LOADING
667 # define STACK_GRAN 0x10000000
668 /* Stack usually starts at 0x80000000 */
669 # define LINUX_DATA_START
671 # define DATAEND (&_end)
674 /* There are reasons to suspect this may not be reliable. */
676 # define OS_TYPE "MACOSX"
677 # define DATASTART ((ptr_t) get_etext())
678 # define STACKBOTTOM ((ptr_t) 0xc0000000)
679 # define DATAEND /* not needed */
680 # define MPROTECT_VDB
682 # define GETPAGESIZE() getpagesize()
686 # define OS_TYPE "NETBSD"
689 # define DATASTART GC_data_start
690 # define DYNAMIC_LOADING
694 # define OS_TYPE "NOSYS"
695 extern void __end, __dso_handle;
696 # define DATASTART (&__dso_handle) /* OK, that's ugly. */
697 # define DATAEND (&__end)
698 /* Stack starts at 0xE0000000 for the simulator. */
700 # define STACK_GRAN 0x10000000
706 # define MACH_TYPE "VAX"
707 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
709 # define DATASTART ((ptr_t)(&etext))
711 # define OS_TYPE "BSD"
713 /* HEURISTIC2 may be OK, but it's hard to test. */
716 # define OS_TYPE "ULTRIX"
717 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
722 # define MACH_TYPE "RT"
724 # define DATASTART ((ptr_t) 0x10000000)
725 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
729 # define MACH_TYPE "SPARC"
730 # if defined(__arch64__) || defined(__sparcv9)
732 # define CPP_WORDSZ 64
733 # define ELF_CLASS ELFCLASS64
735 # define ALIGNMENT 4 /* Required by hardware */
736 # define CPP_WORDSZ 32
738 # define ALIGN_DOUBLE
740 # define OS_TYPE "SUNOS5"
743 extern char * GC_SysVGetDataStart();
744 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
745 # define DATAEND (&_end)
746 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
748 /* Otherwise we now use calloc. Mmap may result in the */
749 /* heap interleaved with thread stacks, which can result in */
750 /* excessive blacklisting. Sbrk is unusable since it */
751 /* doesn't interact correctly with the system malloc. */
754 # define HEAP_START (ptr_t)0x40000000
756 # define HEAP_START DATAEND
759 /* HEURISTIC1 reportedly no longer works under 2.7. */
760 /* HEURISTIC2 probably works, but this appears to be preferable. */
761 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
762 /* installations that's undefined. We work around this with a */
764 # include <sys/vmparam.h>
766 /* This should work everywhere, but doesn't. */
767 # define STACKBOTTOM USRSTACK
772 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
773 /* getpagesize() appeared to be missing from at least one */
774 /* Solaris 5.4 installation. Weird. */
775 # if CPP_WORDSZ == 32
776 # define DYNAMIC_LOADING
780 # define OS_TYPE "SUNOS4"
781 /* [If you have a weak stomach, don't read this.] */
782 /* We would like to use: */
783 /* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
784 /* This fails occasionally, due to an ancient, but very */
785 /* persistent ld bug. &etext is set 32 bytes too high. */
786 /* We instead read the text segment size from the a.out */
787 /* header, which happens to be mapped into our address space */
788 /* at the start of the text segment. The detective work here */
789 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
790 /* Serpette of INRIA. */
791 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
792 # define TEXTSTART 0x2000
793 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
794 # define MPROTECT_VDB
796 # define DYNAMIC_LOADING
799 # define OS_TYPE "DRSNX"
800 extern char * GC_SysVGetDataStart();
802 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
803 # define MPROTECT_VDB
804 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
805 # define DYNAMIC_LOADING
808 # define OS_TYPE "LINUX"
810 # define DYNAMIC_LOADING
812 Linux Sparc/a.out not supported
816 # define DATAEND (&_end)
819 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
820 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, &_etext)
822 # define STACKBOTTOM ((ptr_t) 0xf0000000)
823 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
827 # define OS_TYPE "OPENBSD"
828 # define STACKBOTTOM ((ptr_t) 0xf8000000)
830 # define DATASTART ((ptr_t)(&etext))
833 # define OS_TYPE "NETBSD"
836 # define DATASTART GC_data_start
837 # define DYNAMIC_LOADING
840 # define DATASTART ((ptr_t)(&etext))
846 # define MACH_TYPE "I386"
847 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
848 /* except Borland. The -a4 option fixes */
850 /* Ivan Demakov: For Watcom the option is -zp4. */
851 # ifndef SMALL_CONFIG
852 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
853 /* improvement on Pentiums. */
855 # ifdef HAVE_BUILTIN_UNWIND_INIT
856 # define USE_GENERIC_PUSH_REGS
859 # define OS_TYPE "SEQUENT"
861 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
862 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
865 # define OS_TYPE "BEOS"
867 # define GETPAGESIZE() B_PAGE_SIZE
869 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
872 # define OS_TYPE "SUNOS5"
873 extern int _etext, _end;
874 extern char * GC_SysVGetDataStart();
875 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
876 # define DATAEND (&_end)
877 /* # define STACKBOTTOM ((ptr_t)(&_start)) worked through 2.7, */
878 /* but reportedly breaks under 2.8. It appears that the stack */
879 /* base is a property of the executable, so this should not break */
880 /* old executables. */
881 /* HEURISTIC2 probably works, but this appears to be preferable. */
883 # define STACKBOTTOM USRSTACK
884 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
885 /* It appears to be fixed in 2.8 and 2.9. */
886 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
889 # define DYNAMIC_LOADING
890 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
892 /* Otherwise we now use calloc. Mmap may result in the */
893 /* heap interleaved with thread stacks, which can result in */
894 /* excessive blacklisting. Sbrk is unusable since it */
895 /* doesn't interact correctly with the system malloc. */
898 # define HEAP_START (ptr_t)0x40000000
900 # define HEAP_START DATAEND
904 # define OS_TYPE "SCO"
906 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
908 +((word)&etext & 0xfff))
909 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
912 # define OS_TYPE "SCO_ELF"
914 # define DATASTART ((ptr_t)(&etext))
915 # define STACKBOTTOM ((ptr_t) 0x08048000)
916 # define DYNAMIC_LOADING
917 # define ELF_CLASS ELFCLASS32
921 /* The Intel compiler doesn't like inline assembly */
922 # define USE_GENERIC_PUSH_REGS
924 # define OS_TYPE "LINUX"
925 # define LINUX_STACKBOTTOM
929 # define STACK_GRAN 0x10000000
930 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
931 /* different kernel configurations. In particular, systems */
932 /* with 2GB physical memory will usually move the user */
933 /* address space limit, and hence initial SP to 0x80000000. */
935 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
936 # define MPROTECT_VDB
938 /* We seem to get random errors in incremental mode, */
939 /* possibly because Linux threads is itself a malloc client */
940 /* and can't deal with the signals. */
943 # define DYNAMIC_LOADING
944 # ifdef UNDEFINED /* includes ro data */
946 # define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
948 # include <features.h>
949 # if defined(__GLIBC__) && __GLIBC__ >= 2
950 # define LINUX_DATA_START
952 extern char **__environ;
953 # define DATASTART ((ptr_t)(&__environ))
954 /* hideous kludge: __environ is the first */
955 /* word in crt0.o, and delimits the start */
956 /* of the data segment, no matter which */
957 /* ld options were passed through. */
958 /* We could use _etext instead, but that */
959 /* would include .rodata, which may */
960 /* contain large read-only data tables */
961 /* that we'd rather not scan. */
964 # define DATAEND (&_end)
967 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
969 # ifdef USE_I686_PREFETCH
970 # define PREFETCH(x) \
971 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
972 /* Empirically prefetcht0 is much more effective at reducing */
973 /* cache miss stalls for the targetted load instructions. But it */
974 /* seems to interfere enough with other cache traffic that the net */
975 /* result is worse than prefetchnta. */
977 /* Using prefetches for write seems to have a slight negative */
978 /* impact on performance, at least for a PIII/500. */
979 # define PREFETCH_FOR_WRITE(x) \
980 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
983 # ifdef USE_3DNOW_PREFETCH
984 # define PREFETCH(x) \
985 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
986 # define PREFETCH_FOR_WRITE(x) \
987 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
991 # define OS_TYPE "CYGWIN32"
992 extern int _data_start__;
993 extern int _data_end__;
994 extern int _bss_start__;
995 extern int _bss_end__;
996 /* For binutils 2.9.1, we have */
997 /* DATASTART = _data_start__ */
998 /* DATAEND = _bss_end__ */
999 /* whereas for some earlier versions it was */
1000 /* DATASTART = _bss_start__ */
1001 /* DATAEND = _data_end__ */
1002 /* To get it right for both, we take the */
1003 /* minumum/maximum of the two. */
1004 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1005 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1006 # define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
1007 # define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__))
1009 # define STACK_GRAN 0x10000
1013 # define OS_TYPE "OS2"
1014 /* STACKBOTTOM and DATASTART are handled specially in */
1015 /* os_dep.c. OS2 actually has the right */
1017 # define DATAEND /* not needed */
1018 # define USE_GENERIC_PUSH_REGS
1021 # define OS_TYPE "MSWIN32"
1022 /* STACKBOTTOM and DATASTART are handled specially in */
1024 # ifndef __WATCOMC__
1025 # define MPROTECT_VDB
1027 # define DATAEND /* not needed */
1030 # define OS_TYPE "MSWINCE"
1031 # define DATAEND /* not needed */
1034 # define OS_TYPE "DJGPP"
1035 # include "stubinfo.h"
1038 extern int __djgpp_stack_limit;
1039 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
1040 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1042 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1043 /* This may not be right. */
1046 # define OS_TYPE "OPENBSD"
1049 # define OS_TYPE "FREEBSD"
1050 # ifndef GC_FREEBSD_THREADS
1051 # define MPROTECT_VDB
1053 # define SIG_SUSPEND SIGUSR1
1054 # define SIG_THR_RESTART SIGUSR2
1055 # define FREEBSD_STACKBOTTOM
1057 # define DYNAMIC_LOADING
1060 # define DATASTART ((ptr_t)(&etext))
1063 # define OS_TYPE "NETBSD"
1066 # define OS_TYPE "THREE86BSD"
1069 # define OS_TYPE "BSDI"
1071 # if defined(OPENBSD) || defined(NETBSD) \
1072 || defined(THREE86BSD) || defined(BSDI)
1075 # define DATASTART ((ptr_t)(&etext))
1078 # define OS_TYPE "NEXT"
1079 # define DATASTART ((ptr_t) get_etext())
1080 # define STACKBOTTOM ((ptr_t)0xc0000000)
1081 # define DATAEND /* not needed */
1084 # define OS_TYPE "DOS4GW"
1085 extern long __nullarea;
1087 extern char *_STACKTOP;
1088 /* Depending on calling conventions Watcom C either precedes
1089 or does not precedes with undescore names of C-variables.
1090 Make sure startup code variables always have the same names. */
1091 #pragma aux __nullarea "*";
1092 #pragma aux _end "*";
1093 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1094 /* confused? me too. */
1095 # define DATASTART ((ptr_t) &__nullarea)
1096 # define DATAEND ((ptr_t) &_end)
1099 # define OS_TYPE "HURD"
1100 # define STACK_GROWS_DOWN
1102 extern int __data_start;
1103 # define DATASTART ( (ptr_t) (&__data_start))
1105 # define DATAEND ( (ptr_t) (&_end))
1106 /* # define MPROTECT_VDB Not quite working yet? */
1107 # define DYNAMIC_LOADING
1112 # define MACH_TYPE "NS32K"
1113 # define ALIGNMENT 4
1114 extern char **environ;
1115 # define DATASTART ((ptr_t)(&environ))
1116 /* hideous kludge: environ is the first */
1117 /* word in crt0.o, and delimits the start */
1118 /* of the data segment, no matter which */
1119 /* ld options were passed through. */
1120 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1124 # define MACH_TYPE "MIPS"
1126 /* This was developed for a linuxce style platform. Probably */
1127 /* needs to be tweaked for workstation class machines. */
1128 # define OS_TYPE "LINUX"
1129 extern int __data_start;
1130 # define DATASTART ((ptr_t)(&__data_start))
1131 # define ALIGNMENT 4
1132 # define USE_GENERIC_PUSH_REGS
1133 # define STACKBOTTOM ((ptr_t)0x7fff8000)
1134 /* Older toolchains may need 0x80000000. */
1135 /* In many cases, this should probably use LINUX_STACKBOTTOM */
1136 /* instead. But some kernel versions seem to give the wrong */
1137 /* value from /proc. */
1141 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1142 extern int _fdata[], _end[];
1143 # define DATASTART ((ptr_t)_fdata)
1144 # define DATAEND ((ptr_t)_end)
1145 # define CPP_WORDSZ _MIPS_SZPTR
1146 # define ALIGNMENT (_MIPS_SZPTR/8)
1148 extern int etext, edata, end;
1149 extern int _DYNAMIC_LINKING, _gp;
1150 # define DATASTART ((ptr_t)((((word)&etext + 0x3ffff) & ~0x3ffff) \
1151 + ((word)&etext & 0xffff)))
1152 # define DATAEND (&edata)
1153 # define DATASTART2 (&_DYNAMIC_LINKING \
1154 ? (ptr_t)(((word)&_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1156 # define DATAEND2 (&end)
1157 # define ALIGNMENT 4
1159 # define OS_TYPE "EWS4800"
1160 # define USE_GENERIC_PUSH_REGS 1
1164 # define DATASTART (ptr_t)0x10000000
1165 /* Could probably be slightly higher since */
1166 /* startup code allocates lots of stuff. */
1167 # define OS_TYPE "ULTRIX"
1168 # define ALIGNMENT 4
1172 # define DATASTART (ptr_t)0x10000000
1173 # define OS_TYPE "RISCOS"
1174 # define ALIGNMENT 4 /* Required by hardware */
1179 # define DATASTART ((ptr_t)(&_fdata))
1181 # define HEAP_START (ptr_t)0x30000000
1183 # define HEAP_START DATASTART
1185 /* Lowest plausible heap address. */
1186 /* In the MMAP case, we map there. */
1187 /* In either case it is used to identify */
1188 /* heap sections so they're not */
1189 /* considered as roots. */
1190 # define OS_TYPE "IRIX5"
1191 # define MPROTECT_VDB
1193 # define CPP_WORDSZ _MIPS_SZPTR
1194 # define ALIGNMENT (_MIPS_SZPTR/8)
1195 # if CPP_WORDSZ != 64
1196 # define ALIGN_DOUBLE
1199 # define ALIGNMENT 4
1200 # define ALIGN_DOUBLE
1202 # define DYNAMIC_LOADING
1205 # define OS_TYPE "MSWINCE"
1206 # define ALIGNMENT 4
1207 # define DATAEND /* not needed */
1209 # if defined(NETBSD)
1210 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1211 /* should be handled at the top of the file. */
1212 # define ALIGNMENT 4
1213 # define OS_TYPE "NETBSD"
1215 # define USE_GENERIC_PUSH_REGS
1218 # define DATASTART GC_data_start
1219 # define NEED_FIND_LIMIT
1220 # define DYNAMIC_LOADING
1222 # define DATASTART ((ptr_t) 0x10000000)
1223 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1229 # define MACH_TYPE "RS6000"
1231 # define ALIGNMENT 8
1232 # define CPP_WORDSZ 64
1234 # define ALIGNMENT 4
1235 # define CPP_WORDSZ 32
1237 extern int _data, _end;
1238 # define DATASTART ((ptr_t)((ulong)&_data))
1239 # define DATAEND ((ptr_t)((ulong)&_end))
1241 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1242 # define USE_GENERIC_PUSH_REGS
1243 # define DYNAMIC_LOADING
1244 /* For really old versions of AIX, this may have to be removed. */
1248 # define MACH_TYPE "HP_PA"
1250 # define CPP_WORDSZ 64
1251 # define ALIGNMENT 8
1253 # define CPP_WORDSZ 32
1254 # define ALIGNMENT 4
1255 # define ALIGN_DOUBLE
1257 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1258 # ifndef LINUX /* For now. */
1259 # define MPROTECT_VDB
1262 # define GENERIC_COMPARE_AND_SWAP
1263 /* No compare-and-swap instruction. Use pthread mutexes */
1264 /* when we absolutely have to. */
1265 # ifdef PARALLEL_MARK
1266 # define USE_MARK_BYTES
1267 /* Minimize compare-and-swap usage. */
1270 # define STACK_GROWS_UP
1272 # define OS_TYPE "HPUX"
1273 extern int __data_start;
1274 # define DATASTART ((ptr_t)(&__data_start))
1276 /* The following appears to work for 7xx systems running HP/UX */
1277 /* 9.xx Furthermore, it might result in much faster */
1278 /* collections than HEURISTIC2, which may involve scanning */
1279 /* segments that directly precede the stack. It is not the */
1280 /* default, since it may not work on older machine/OS */
1281 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1283 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1285 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1286 /* to this. Note that the GC must be initialized before the */
1287 /* first putenv call. */
1288 extern char ** environ;
1289 # define STACKBOTTOM ((ptr_t)environ)
1291 # define DYNAMIC_LOADING
1292 # include <unistd.h>
1293 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1295 # define PREFETCH(x) { \
1296 register long addr = (long)(x); \
1297 (void) _asm ("LDW", 0, 0, addr, 0); \
1302 # define OS_TYPE "LINUX"
1303 # define LINUX_STACKBOTTOM
1304 # define DYNAMIC_LOADING
1305 # define LINUX_DATA_START
1307 # define DATAEND (&_end)
1312 # define MACH_TYPE "ALPHA"
1313 # define ALIGNMENT 8
1315 # define OS_TYPE "NETBSD"
1317 # define DATASTART GC_data_start
1318 # define ELFCLASS32 32
1319 # define ELFCLASS64 64
1320 # define ELF_CLASS ELFCLASS64
1321 # define CPP_WORDSZ 64
1322 # define DYNAMIC_LOADING
1325 # define OS_TYPE "OPENBSD"
1327 # define CPP_WORDSZ 64
1328 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1329 # define DATASTART GC_data_start
1330 # define ELFCLASS32 32
1331 # define ELFCLASS64 64
1332 # define ELF_CLASS ELFCLASS64
1333 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1334 # define DATASTART ((ptr_t) 0x140000000)
1338 # define OS_TYPE "FREEBSD"
1339 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1340 # define SIG_SUSPEND SIGUSR1
1341 # define SIG_THR_RESTART SIGUSR2
1342 # define FREEBSD_STACKBOTTOM
1344 # define DYNAMIC_LOADING
1346 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1350 # define NEED_FIND_LIMIT
1351 # define DATASTART ((ptr_t)(&etext))
1352 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1353 # define DATASTART2 ((ptr_t)(&edata))
1354 # define DATAEND2 ((ptr_t)(&end))
1355 # define CPP_WORDSZ 64
1358 # define OS_TYPE "OSF1"
1359 # define DATASTART ((ptr_t) 0x140000000)
1361 # define DATAEND ((ptr_t) &_end)
1362 extern char ** environ;
1363 /* round up from the value of environ to the nearest page boundary */
1364 /* Probably breaks if putenv is called before collector */
1365 /* initialization. */
1366 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1367 /* # define HEURISTIC2 */
1368 /* Normally HEURISTIC2 is too conervative, since */
1369 /* the text segment immediately follows the stack. */
1370 /* Hence we give an upper pound. */
1371 /* This is currently unused, since we disabled HEURISTIC2 */
1373 # define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
1374 # define CPP_WORDSZ 64
1375 # define MPROTECT_VDB
1376 # define DYNAMIC_LOADING
1379 # define OS_TYPE "LINUX"
1380 # define CPP_WORDSZ 64
1381 # define STACKBOTTOM ((ptr_t) 0x120000000)
1383 # define SEARCH_FOR_DATA_START
1384 # define DATASTART GC_data_start
1385 # define DYNAMIC_LOADING
1387 # define DATASTART ((ptr_t) 0x140000000)
1390 # define DATAEND (&_end)
1391 # define MPROTECT_VDB
1392 /* Has only been superficially tested. May not */
1393 /* work on all versions. */
1398 # define MACH_TYPE "IA64"
1399 # define USE_GENERIC_PUSH_REGS
1400 /* We need to get preserved registers in addition to register */
1401 /* windows. That's easiest to do with setjmp. */
1402 # ifdef PARALLEL_MARK
1403 # define USE_MARK_BYTES
1404 /* Compare-and-exchange is too expensive to use for */
1405 /* setting mark bits. */
1409 # define CPP_WORDSZ 32
1410 # define ALIGN_DOUBLE
1411 /* Requires 8 byte alignment for malloc */
1412 # define ALIGNMENT 4
1417 # define CPP_WORDSZ 64
1418 # define ALIGN_DOUBLE
1419 /* Requires 16 byte alignment for malloc */
1420 # define ALIGNMENT 8
1422 # define OS_TYPE "HPUX"
1423 extern int __data_start;
1424 # define DATASTART ((ptr_t)(&__data_start))
1425 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1426 /* to this. Note that the GC must be initialized before the */
1427 /* first putenv call. */
1428 extern char ** environ;
1429 # define STACKBOTTOM ((ptr_t)environ)
1430 # define DYNAMIC_LOADING
1431 # include <unistd.h>
1432 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1433 /* The following was empirically determined, and is probably */
1434 /* not very robust. */
1435 /* Note that the backing store base seems to be at a nice */
1436 /* address minus one page. */
1437 # define BACKING_STORE_DISPLACEMENT 0x1000000
1438 # define BACKING_STORE_ALIGNMENT 0x1000
1439 # define BACKING_STORE_BASE \
1440 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1441 & ~(BACKING_STORE_ALIGNMENT - 1))
1444 # define CPP_WORDSZ 64
1445 # define ALIGN_DOUBLE
1446 /* Requires 16 byte alignment for malloc */
1447 # define ALIGNMENT 8
1448 # define OS_TYPE "LINUX"
1449 /* The following works on NUE and older kernels: */
1450 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1451 /* This does not work on NUE: */
1452 # define LINUX_STACKBOTTOM
1453 /* We also need the base address of the register stack */
1454 /* backing store. This is computed in */
1455 /* GC_linux_register_stack_base based on the following */
1457 # define BACKING_STORE_ALIGNMENT 0x100000
1458 # define BACKING_STORE_DISPLACEMENT 0x80000000
1459 extern char * GC_register_stackbottom;
1460 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1461 # define SEARCH_FOR_DATA_START
1462 # define DATASTART GC_data_start
1464 # define DYNAMIC_LOADING
1466 /* In the Intel compiler environment, we seem to end up with */
1467 /* statically linked executables and an undefined reference */
1470 # define MPROTECT_VDB
1471 /* Requires Linux 2.3.47 or later. */
1473 # define DATAEND (&_end)
1475 # define PREFETCH(x) \
1476 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1477 # define PREFETCH_FOR_WRITE(x) \
1478 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1479 # define CLEAR_DOUBLE(x) \
1480 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1486 # define MACH_TYPE "M88K"
1487 # define ALIGNMENT 4
1488 # define ALIGN_DOUBLE
1491 # define OS_TYPE "CX_UX"
1492 # define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1495 # define OS_TYPE "DGUX"
1496 extern char * GC_SysVGetDataStart();
1497 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
1499 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1503 # define MACH_TYPE "S370"
1504 # define ALIGNMENT 4 /* Required by hardware */
1505 # define USE_GENERIC_PUSH_REGS
1507 # define OS_TYPE "UTS4"
1511 extern char * GC_SysVGetDataStart();
1512 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
1513 # define DATAEND (&_end)
1517 # define OS_TYPE "LINUX"
1519 # define DYNAMIC_LOADING
1520 extern int __data_start;
1521 # define DATASTART ((ptr_t)(&__data_start))
1526 # define ALIGNMENT 4
1528 # define DATASTART ((ptr_t)(&_etext))
1533 # define CPP_WORDSZ 32
1534 # define MACH_TYPE "ARM32"
1535 # define ALIGNMENT 4
1537 # define OS_TYPE "NETBSD"
1540 # define DATASTART ((ptr_t)(&etext))
1541 # define USE_GENERIC_PUSH_REGS
1544 # define OS_TYPE "LINUX"
1547 # define STACK_GRAN 0x10000000
1548 # define USE_GENERIC_PUSH_REGS
1550 # define DYNAMIC_LOADING
1551 # include <features.h>
1552 # if defined(__GLIBC__) && __GLIBC__ >= 2
1553 # define LINUX_DATA_START
1555 extern char **__environ;
1556 # define DATASTART ((ptr_t)(&__environ))
1557 /* hideous kludge: __environ is the first */
1558 /* word in crt0.o, and delimits the start */
1559 /* of the data segment, no matter which */
1560 /* ld options were passed through. */
1561 /* We could use _etext instead, but that */
1562 /* would include .rodata, which may */
1563 /* contain large read-only data tables */
1564 /* that we'd rather not scan. */
1567 # define DATAEND (&_end)
1570 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
1574 # define OS_TYPE "MSWINCE"
1575 # define DATAEND /* not needed */
1578 /* __data_start is usually defined in the target linker script. */
1579 extern int __data_start;
1580 # define DATASTART (ptr_t)(&__data_start)
1581 # define USE_GENERIC_PUSH_REGS
1582 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1583 extern void *__stack_base__;
1584 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1589 # define MACH_TYPE "SH"
1590 # define ALIGNMENT 4
1592 # define OS_TYPE "MSWINCE"
1593 # define DATAEND /* not needed */
1596 # define OS_TYPE "LINUX"
1597 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1598 # define USE_GENERIC_PUSH_REGS
1599 # define DYNAMIC_LOADING
1600 # define LINUX_DATA_START
1602 # define DATAEND (&_end)
1607 # define MACH_TYPE "SH4"
1608 # define OS_TYPE "MSWINCE"
1609 # define ALIGNMENT 4
1610 # define DATAEND /* not needed */
1613 #ifdef LINUX_DATA_START
1614 /* Some Linux distributions arrange to define __data_start. Some */
1615 /* define data_start as a weak symbol. The latter is technically */
1616 /* broken, since the user program may define data_start, in which */
1617 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1618 /* We assume gcc. */
1619 # pragma weak __data_start
1620 extern int __data_start;
1621 # pragma weak data_start
1622 extern int data_start;
1623 # define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
1626 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1627 /* Rld appears to allocate some memory with its own allocator, and */
1628 /* some through malloc, which might be redirected. To make this */
1629 /* work with collectable memory, we have to scan memory allocated */
1630 /* by rld's internal malloc. */
1631 # define USE_PROC_FOR_LIBRARIES
1634 # ifndef STACK_GROWS_UP
1635 # define STACK_GROWS_DOWN
1639 # define CPP_WORDSZ 32
1648 # define DATAEND (&end)
1651 # if defined(SVR4) && !defined(GETPAGESIZE)
1652 # include <unistd.h>
1653 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1656 # ifndef GETPAGESIZE
1657 # if defined(SUNOS5) || defined(IRIX5)
1658 # include <unistd.h>
1660 # define GETPAGESIZE() getpagesize()
1663 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1664 /* OS has SVR4 generic features. Probably others also qualify. */
1668 # if defined(SUNOS5) || defined(DRSNX)
1669 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1672 /* OS has SUNOS5 style signal handlers. */
1680 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1681 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1682 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1683 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1686 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1691 # undef DYNAMIC_LOADING
1696 # undef MPROTECT_VDB
1701 /* Postponed for now. */
1703 # undef MPROTECT_VDB
1706 # ifdef SMALL_CONFIG
1707 /* Presumably not worth the space it takes. */
1709 # undef MPROTECT_VDB
1713 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1716 # ifdef PARALLEL_MARK
1717 # undef MPROTECT_VDB /* For now. */
1720 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1721 # define DEFAULT_VDB
1725 # define PREFETCH(x)
1726 # define NO_PREFETCH
1729 # ifndef PREFETCH_FOR_WRITE
1730 # define PREFETCH_FOR_WRITE(x)
1731 # define NO_PREFETCH_FOR_WRITE
1734 # ifndef CACHE_LINE_SIZE
1735 # define CACHE_LINE_SIZE 32 /* Wild guess */
1738 # ifndef CLEAR_DOUBLE
1739 # define CLEAR_DOUBLE(x) \
1740 ((word*)x)[0] = 0; \
1742 # endif /* CLEAR_DOUBLE */
1744 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1745 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1746 # define GC_SOLARIS_THREADS
1749 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1750 --> inconsistent configuration
1752 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1753 --> inconsistent configuration
1755 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1756 --> inconsistent configuration
1758 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1759 --> inconsistent configuration
1761 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1762 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1763 /* the necessary code is mostly there, but nobody has actually made */
1764 /* sure the right combination of pieces is compiled in, etc. */
1765 --> inconsistent configuration
1768 # if defined(PCR) || defined(SRC_M3) || \
1769 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1770 defined(GC_PTHREADS)
1774 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1775 || defined(LINT) || defined(MSWINCE) \
1776 || (defined(I386) && defined(__LCC__))
1777 /* Use setjmp based hack to mark from callee-save registers. */
1778 /* The define should move to the individual platform */
1780 # define USE_GENERIC_PUSH_REGS
1784 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1785 /* include assembly code to do it well. */
1788 /* Can we save call chain in objects for debugging? */
1789 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1790 /* to reasonable values for the platform. */
1791 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1792 /* build time, though we feel free to adjust it slightly. */
1793 /* Define NEED_CALLINFO if we either save the call stack or */
1794 /* GC_ADD_CALLER is defined. */
1796 # include <features.h>
1797 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1798 # define HAVE_BUILTIN_BACKTRACE
1803 # define CAN_SAVE_CALL_STACKS
1804 # define CAN_SAVE_CALL_ARGS
1806 #if defined(I386) && defined(LINUX)
1807 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1808 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1809 # define CAN_SAVE_CALL_STACKS
1810 # define CAN_SAVE_CALL_ARGS
1812 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1813 # define CAN_SAVE_CALL_STACKS
1816 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1817 && defined(CAN_SAVE_CALL_STACKS)
1818 # define SAVE_CALL_CHAIN
1820 # ifdef SAVE_CALL_CHAIN
1821 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1822 # define NARGS SAVE_CALL_NARGS
1824 # define NARGS 0 /* Number of arguments to save for each call. */
1827 # ifdef SAVE_CALL_CHAIN
1828 # ifndef SAVE_CALL_COUNT
1829 # define NFRAMES 6 /* Number of frames to save. Even for */
1830 /* alignment reasons. */
1832 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1834 # define NEED_CALLINFO
1835 # endif /* SAVE_CALL_CHAIN */
1836 # ifdef GC_ADD_CALLER
1839 # define NEED_CALLINFO
1842 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1843 # define DBG_HDRS_ALL
1846 # endif /* GCCONFIG_H */