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) && !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 /* or a 390 running LINUX */
423 /* ARM32 ==> Intel StrongARM */
424 /* IA64 ==> Intel IPF */
426 /* (LINUX and HPUX) */
427 /* IA64_32 ==> IA64 w/32 bit ABI */
429 /* SH ==> Hitachi SuperH */
430 /* (LINUX & MSWINCE) */
431 /* X86_64 ==> AMD x86-64 */
435 * For each architecture and OS, the following need to be defined:
437 * CPP_WORD_SZ is a simple integer constant representing the word size.
438 * in bits. We assume byte addressibility, where a byte has 8 bits.
439 * We also assume CPP_WORD_SZ is either 32 or 64.
440 * (We care about the length of pointers, not hardware
441 * bus widths. Thus a 64 bit processor with a C compiler that uses
442 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
444 * MACH_TYPE is a string representation of the machine type.
445 * OS_TYPE is analogous for the OS.
447 * ALIGNMENT is the largest N, such that
448 * all pointer are guaranteed to be aligned on N byte boundaries.
449 * defining it to be 1 will always work, but perform poorly.
451 * DATASTART is the beginning of the data segment.
452 * On UNIX systems, the collector will scan the area between DATASTART
453 * and DATAEND for root pointers.
455 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
456 * RTH suggests gaining access to linker script synth'd values with
457 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
458 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
459 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
460 * without any special options.
462 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
465 * STACKBOTTOM is the cool end of the stack, which is usually the
466 * highest address in the stack.
467 * Under PCR or OS/2, we have other ways of finding thread stacks.
468 * For each machine, the following should:
469 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
470 * 2) define exactly one of
471 * STACKBOTTOM (should be defined to be an expression)
474 * If either of the last two macros are defined, then STACKBOTTOM is computed
475 * during collector startup using one of the following two heuristics:
476 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
477 * the next multiple of STACK_GRAN.
478 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
479 * in small steps (decrement if STACK_GROWS_UP), and read the value
480 * at each location. Remember the value when the first
481 * Segmentation violation or Bus error is signalled. Round that
482 * to the nearest plausible page boundary, and use that instead
485 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
486 * the value of environ is a pointer that can serve as STACKBOTTOM.
487 * I expect that HEURISTIC2 can be replaced by this approach, which
488 * interferes far less with debugging. However it has the disadvantage
489 * that it's confused by a putenv call before the collector is initialized.
490 * This could be dealt with by intercepting putenv ...
492 * If no expression for STACKBOTTOM can be found, and neither of the above
493 * heuristics are usable, the collector can still be used with all of the above
494 * undefined, provided one of the following is done:
495 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
496 * without reference to STACKBOTTOM. This is appropriate for use in
497 * conjunction with thread packages, since there will be multiple stacks.
498 * (Allocating thread stacks in the heap, and treating them as ordinary
499 * heap data objects is also possible as a last resort. However, this is
500 * likely to introduce significant amounts of excess storage retention
501 * unless the dead parts of the thread stacks are periodically cleared.)
502 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
503 * If the author of the client code controls the main program, this is
504 * easily accomplished by introducing a new main program, setting
505 * GC_stackbottom to the address of a local variable, and then calling
506 * the original main program. The new main program would read something
509 * # include "gc_private.h"
511 * main(argc, argv, envp)
513 * char **argv, **envp;
517 * GC_stackbottom = (ptr_t)(&dummy);
518 * return(real_main(argc, argv, envp));
522 * Each architecture may also define the style of virtual dirty bit
523 * implementation to be used:
524 * MPROTECT_VDB: Write protect the heap and catch faults.
525 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
527 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
528 * defined GC_register_dynamic_libraries() for the architecture.
530 * An architecture may define PREFETCH(x) to preload the cache with *x.
531 * This defaults to a no-op.
533 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
535 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
536 * clear the two words at GC_malloc-aligned address x. By default,
537 * word stores of 0 are used instead.
540 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
541 * to push the relevant registers onto the stack. This generally makes
542 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
544 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
545 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
546 # define HAVE_BUILTIN_UNWIND_INIT
549 # define STACK_GRAN 0x1000000
551 # define MACH_TYPE "M68K"
554 # define OS_TYPE "OPENBSD"
557 # define DATASTART ((ptr_t)(etext))
560 # define OS_TYPE "NETBSD"
563 # define DATASTART ((ptr_t)(etext))
566 # define OS_TYPE "LINUX"
567 # define STACKBOTTOM ((ptr_t)0xf0000000)
568 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
570 # define DYNAMIC_LOADING
571 # include <features.h>
572 # if defined(__GLIBC__)&& __GLIBC__>=2
573 # define LINUX_DATA_START
575 extern char **__environ
;
576 # define DATASTART ((ptr_t)(&__environ))
577 /* hideous kludge: __environ is the first */
578 /* word in crt0.o, and delimits the start */
579 /* of the data segment, no matter which */
580 /* ld options were passed through. */
581 /* We could use _etext instead, but that */
582 /* would include .rodata, which may */
583 /* contain large read-only data tables */
584 /* that we'd rather not scan. */
585 # endif /* !GLIBC2 */
587 # define DATAEND (_end)
590 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
594 # define OS_TYPE "SUNOS4"
596 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
597 # define HEURISTIC1 /* differs */
598 # define DYNAMIC_LOADING
601 # define OS_TYPE "HP"
603 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
604 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
605 /* empirically determined. seems to work. */
607 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
610 # define OS_TYPE "SYSV"
612 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
614 +((word)etext & 0x1fff))
615 /* This only works for shared-text binaries with magic number 0413.
616 The other sorts of SysV binaries put the data at the end of the text,
617 in which case the default of etext would work. Unfortunately,
618 handling both would require having the magic-number available.
621 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
622 /* The stack starts at the top of memory, but */
623 /* 0x0 cannot be used as setjump_test complains */
624 /* that the stack direction is incorrect. Two */
625 /* bytes down from 0x0 should be safe enough. */
627 # include <sys/mmu.h>
628 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
631 # define OS_TYPE "AMIGA"
632 /* STACKBOTTOM and DATASTART handled specially */
634 # define DATAEND /* not needed */
635 # define GETPAGESIZE() 4096
641 # define OS_TYPE "MACOS"
642 /* see os_dep.c for details of global data segments. */
643 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
644 # define DATAEND /* not needed */
645 # define GETPAGESIZE() 4096
648 # define OS_TYPE "NEXT"
649 # define DATASTART ((ptr_t) get_etext())
650 # define STACKBOTTOM ((ptr_t) 0x4000000)
651 # define DATAEND /* not needed */
656 # define MACH_TYPE "POWERPC"
658 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
662 # define OS_TYPE "MACOS"
663 /* see os_dep.c for details of global data segments. */
664 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
665 # define DATAEND /* not needed */
668 # define ALIGNMENT 4 /* Guess. Can someone verify? */
669 /* This was 2, but that didn't sound right. */
670 # define OS_TYPE "LINUX"
672 # define DYNAMIC_LOADING
674 # define STACK_GRAN 0x10000000
675 /* Stack usually starts at 0x80000000 */
676 # define LINUX_DATA_START
678 # define DATAEND (_end)
681 /* There are reasons to suspect this may not be reliable. */
683 # define OS_TYPE "MACOSX"
684 # define DATASTART ((ptr_t) get_etext())
685 # define STACKBOTTOM ((ptr_t) 0xc0000000)
686 # define DATAEND /* not needed */
687 # define MPROTECT_VDB
689 # define GETPAGESIZE() getpagesize()
693 # define OS_TYPE "NETBSD"
696 # define DATASTART GC_data_start
697 # define DYNAMIC_LOADING
701 # define OS_TYPE "NOSYS"
702 extern void __end
[], __dso_handle
[];
703 # define DATASTART (__dso_handle) /* OK, that's ugly. */
704 # define DATAEND (__end)
705 /* Stack starts at 0xE0000000 for the simulator. */
707 # define STACK_GRAN 0x10000000
713 # define MACH_TYPE "VAX"
714 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
716 # define DATASTART ((ptr_t)(etext))
718 # define OS_TYPE "BSD"
720 /* HEURISTIC2 may be OK, but it's hard to test. */
723 # define OS_TYPE "ULTRIX"
724 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
729 # define MACH_TYPE "RT"
731 # define DATASTART ((ptr_t) 0x10000000)
732 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
736 # define MACH_TYPE "SPARC"
737 # if defined(__arch64__) || defined(__sparcv9)
739 # define CPP_WORDSZ 64
740 # define ELF_CLASS ELFCLASS64
742 # define ALIGNMENT 4 /* Required by hardware */
743 # define CPP_WORDSZ 32
745 # define ALIGN_DOUBLE
747 # define OS_TYPE "SUNOS5"
750 extern char * GC_SysVGetDataStart();
751 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
752 # define DATAEND (_end)
753 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
755 /* Otherwise we now use calloc. Mmap may result in the */
756 /* heap interleaved with thread stacks, which can result in */
757 /* excessive blacklisting. Sbrk is unusable since it */
758 /* doesn't interact correctly with the system malloc. */
761 # define HEAP_START (ptr_t)0x40000000
763 # define HEAP_START DATAEND
766 /* HEURISTIC1 reportedly no longer works under 2.7. */
767 /* HEURISTIC2 probably works, but this appears to be preferable. */
768 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
769 /* installations that's undefined. We work around this with a */
771 # include <sys/vmparam.h>
773 /* This should work everywhere, but doesn't. */
774 # define STACKBOTTOM USRSTACK
779 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
780 /* getpagesize() appeared to be missing from at least one */
781 /* Solaris 5.4 installation. Weird. */
782 # define DYNAMIC_LOADING
785 # define OS_TYPE "SUNOS4"
786 /* [If you have a weak stomach, don't read this.] */
787 /* We would like to use: */
788 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
789 /* This fails occasionally, due to an ancient, but very */
790 /* persistent ld bug. etext is set 32 bytes too high. */
791 /* We instead read the text segment size from the a.out */
792 /* header, which happens to be mapped into our address space */
793 /* at the start of the text segment. The detective work here */
794 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
795 /* Serpette of INRIA. */
796 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
797 # define TEXTSTART 0x2000
798 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
799 # define MPROTECT_VDB
801 # define DYNAMIC_LOADING
804 # define OS_TYPE "DRSNX"
805 extern char * GC_SysVGetDataStart();
807 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
808 # define MPROTECT_VDB
809 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
810 # define DYNAMIC_LOADING
813 # define OS_TYPE "LINUX"
815 # define DYNAMIC_LOADING
817 Linux Sparc
/a
.out
not supported
821 # define DATAEND (_end)
824 /* libc_stack_end is not set reliably for sparc64 */
825 # define STACKBOTTOM ((ptr_t) 0x80000000000)
826 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
828 # define LINUX_STACKBOTTOM
829 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
833 # define OS_TYPE "OPENBSD"
834 # define STACKBOTTOM ((ptr_t) 0xf8000000)
836 # define DATASTART ((ptr_t)(etext))
839 # define OS_TYPE "NETBSD"
842 # define DATASTART GC_data_start
843 # define DYNAMIC_LOADING
846 # define DATASTART ((ptr_t)(etext))
852 # define MACH_TYPE "I386"
853 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
854 /* except Borland. The -a4 option fixes */
856 /* Ivan Demakov: For Watcom the option is -zp4. */
857 # ifndef SMALL_CONFIG
858 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
859 /* improvement on Pentiums. */
861 # ifdef HAVE_BUILTIN_UNWIND_INIT
862 # define USE_GENERIC_PUSH_REGS
865 # define OS_TYPE "SEQUENT"
867 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
868 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
871 # define OS_TYPE "BEOS"
873 # define GETPAGESIZE() B_PAGE_SIZE
875 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
878 # define OS_TYPE "SUNOS5"
879 extern int _etext
[], _end
[];
880 extern char * GC_SysVGetDataStart();
881 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
882 # define DATAEND (_end)
883 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
884 /* but reportedly breaks under 2.8. It appears that the stack */
885 /* base is a property of the executable, so this should not break */
886 /* old executables. */
887 /* HEURISTIC2 probably works, but this appears to be preferable. */
889 # define STACKBOTTOM USRSTACK
890 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
891 /* It appears to be fixed in 2.8 and 2.9. */
892 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
895 # define DYNAMIC_LOADING
896 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
898 /* Otherwise we now use calloc. Mmap may result in the */
899 /* heap interleaved with thread stacks, which can result in */
900 /* excessive blacklisting. Sbrk is unusable since it */
901 /* doesn't interact correctly with the system malloc. */
904 # define HEAP_START (ptr_t)0x40000000
906 # define HEAP_START DATAEND
910 # define OS_TYPE "SCO"
912 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
914 +((word)etext & 0xfff))
915 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
918 # define OS_TYPE "SCO_ELF"
920 # define DATASTART ((ptr_t)(etext))
921 # define STACKBOTTOM ((ptr_t) 0x08048000)
922 # define DYNAMIC_LOADING
923 # define ELF_CLASS ELFCLASS32
927 /* The Intel compiler doesn't like inline assembly */
928 # define USE_GENERIC_PUSH_REGS
930 # define OS_TYPE "LINUX"
931 # define LINUX_STACKBOTTOM
935 # define STACK_GRAN 0x10000000
936 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
937 /* different kernel configurations. In particular, systems */
938 /* with 2GB physical memory will usually move the user */
939 /* address space limit, and hence initial SP to 0x80000000. */
941 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
942 # define MPROTECT_VDB
944 /* We seem to get random errors in incremental mode, */
945 /* possibly because Linux threads is itself a malloc client */
946 /* and can't deal with the signals. */
949 # define DYNAMIC_LOADING
950 # ifdef UNDEFINED /* includes ro data */
952 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
954 # include <features.h>
955 # if defined(__GLIBC__) && __GLIBC__ >= 2
956 # define LINUX_DATA_START
958 extern char **__environ
;
959 # define DATASTART ((ptr_t)(&__environ))
960 /* hideous kludge: __environ is the first */
961 /* word in crt0.o, and delimits the start */
962 /* of the data segment, no matter which */
963 /* ld options were passed through. */
964 /* We could use _etext instead, but that */
965 /* would include .rodata, which may */
966 /* contain large read-only data tables */
967 /* that we'd rather not scan. */
970 # define DATAEND (_end)
973 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
975 # ifdef USE_I686_PREFETCH
976 # define PREFETCH(x) \
977 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
978 /* Empirically prefetcht0 is much more effective at reducing */
979 /* cache miss stalls for the targetted load instructions. But it */
980 /* seems to interfere enough with other cache traffic that the net */
981 /* result is worse than prefetchnta. */
983 /* Using prefetches for write seems to have a slight negative */
984 /* impact on performance, at least for a PIII/500. */
985 # define PREFETCH_FOR_WRITE(x) \
986 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
989 # ifdef USE_3DNOW_PREFETCH
990 # define PREFETCH(x) \
991 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
992 # define PREFETCH_FOR_WRITE(x) \
993 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
997 # define OS_TYPE "CYGWIN32"
998 extern int _data_start__
[];
999 extern int _data_end__
[];
1000 extern int _bss_start__
[];
1001 extern int _bss_end__
[];
1002 /* For binutils 2.9.1, we have */
1003 /* DATASTART = _data_start__ */
1004 /* DATAEND = _bss_end__ */
1005 /* whereas for some earlier versions it was */
1006 /* DATASTART = _bss_start__ */
1007 /* DATAEND = _data_end__ */
1008 /* To get it right for both, we take the */
1009 /* minumum/maximum of the two. */
1010 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1011 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1012 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1013 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1015 # define STACK_GRAN 0x10000
1019 # define OS_TYPE "OS2"
1020 /* STACKBOTTOM and DATASTART are handled specially in */
1021 /* os_dep.c. OS2 actually has the right */
1023 # define DATAEND /* not needed */
1024 # define USE_GENERIC_PUSH_REGS
1027 # define OS_TYPE "MSWIN32"
1028 /* STACKBOTTOM and DATASTART are handled specially in */
1030 # ifndef __WATCOMC__
1031 # define MPROTECT_VDB
1033 # define DATAEND /* not needed */
1036 # define OS_TYPE "MSWINCE"
1037 # define DATAEND /* not needed */
1040 # define OS_TYPE "DJGPP"
1041 # include "stubinfo.h"
1044 extern int __djgpp_stack_limit
;
1045 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1046 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1048 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1049 /* This may not be right. */
1052 # define OS_TYPE "OPENBSD"
1055 # define OS_TYPE "FREEBSD"
1056 # ifndef GC_FREEBSD_THREADS
1057 # define MPROTECT_VDB
1059 # define SIG_SUSPEND SIGUSR1
1060 # define SIG_THR_RESTART SIGUSR2
1061 # define FREEBSD_STACKBOTTOM
1063 # define DYNAMIC_LOADING
1065 /* Handle unmapped hole i386*-*-freebsd[45]* may put between etext and edata. */
1066 extern char etext
[];
1067 extern char edata
[];
1069 # define NEED_FIND_LIMIT
1070 # define DATASTART ((ptr_t)(etext))
1071 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1072 # define DATAEND (MIN (GC_find_limit (DATASTART, TRUE), DATASTART2))
1073 # define DATASTART2 ((ptr_t)(edata))
1074 # define DATAEND2 ((ptr_t)(end))
1077 # define OS_TYPE "NETBSD"
1079 # define DYNAMIC_LOADING
1083 # define OS_TYPE "THREE86BSD"
1086 # define OS_TYPE "BSDI"
1088 # if defined(OPENBSD) || defined(NETBSD) \
1089 || defined(THREE86BSD) || defined(BSDI)
1091 extern char etext
[];
1092 # define DATASTART ((ptr_t)(etext))
1095 # define OS_TYPE "NEXT"
1096 # define DATASTART ((ptr_t) get_etext())
1097 # define STACKBOTTOM ((ptr_t)0xc0000000)
1098 # define DATAEND /* not needed */
1101 # define OS_TYPE "DOS4GW"
1102 extern long __nullarea
;
1104 extern char *_STACKTOP
;
1105 /* Depending on calling conventions Watcom C either precedes
1106 or does not precedes with undescore names of C-variables.
1107 Make sure startup code variables always have the same names. */
1108 #pragma aux __nullarea "*";
1109 #pragma aux _end "*";
1110 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1111 /* confused? me too. */
1112 # define DATASTART ((ptr_t) &__nullarea)
1113 # define DATAEND ((ptr_t) &_end)
1116 # define OS_TYPE "HURD"
1117 # define STACK_GROWS_DOWN
1119 extern int __data_start
[];
1120 # define DATASTART ( (ptr_t) (__data_start))
1122 # define DATAEND ( (ptr_t) (_end))
1123 /* # define MPROTECT_VDB Not quite working yet? */
1124 # define DYNAMIC_LOADING
1129 # define MACH_TYPE "NS32K"
1130 # define ALIGNMENT 4
1131 extern char **environ
;
1132 # define DATASTART ((ptr_t)(&environ))
1133 /* hideous kludge: environ is the first */
1134 /* word in crt0.o, and delimits the start */
1135 /* of the data segment, no matter which */
1136 /* ld options were passed through. */
1137 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1141 # define MACH_TYPE "MIPS"
1143 /* This was developed for a linuxce style platform. Probably */
1144 /* needs to be tweaked for workstation class machines. */
1145 # define OS_TYPE "LINUX"
1146 # define DYNAMIC_LOADING
1148 # define DATAEND (_end)
1149 extern int __data_start
[];
1150 # define DATASTART ((ptr_t)(__data_start))
1151 # define ALIGNMENT 4
1152 # define USE_GENERIC_PUSH_REGS
1153 # define LINUX_STACKBOTTOM
1157 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1158 extern int _fdata
[], _end
[];
1159 # define DATASTART ((ptr_t)_fdata)
1160 # define DATAEND ((ptr_t)_end)
1161 # define CPP_WORDSZ _MIPS_SZPTR
1162 # define ALIGNMENT (_MIPS_SZPTR/8)
1164 extern int etext
[], edata
[], end
[];
1165 extern int _DYNAMIC_LINKING
[], _gp
[];
1166 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1167 + ((word)etext & 0xffff)))
1168 # define DATAEND (edata)
1169 # define DATASTART2 (_DYNAMIC_LINKING \
1170 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1172 # define DATAEND2 (end)
1173 # define ALIGNMENT 4
1175 # define OS_TYPE "EWS4800"
1176 # define USE_GENERIC_PUSH_REGS 1
1180 # define DATASTART (ptr_t)0x10000000
1181 /* Could probably be slightly higher since */
1182 /* startup code allocates lots of stuff. */
1183 # define OS_TYPE "ULTRIX"
1184 # define ALIGNMENT 4
1188 # define DATASTART (ptr_t)0x10000000
1189 # define OS_TYPE "RISCOS"
1190 # define ALIGNMENT 4 /* Required by hardware */
1194 extern int _fdata
[];
1195 # define DATASTART ((ptr_t)(_fdata))
1197 # define HEAP_START (ptr_t)0x30000000
1199 # define HEAP_START DATASTART
1201 /* Lowest plausible heap address. */
1202 /* In the MMAP case, we map there. */
1203 /* In either case it is used to identify */
1204 /* heap sections so they're not */
1205 /* considered as roots. */
1206 # define OS_TYPE "IRIX5"
1207 # define MPROTECT_VDB
1209 # define CPP_WORDSZ _MIPS_SZPTR
1210 # define ALIGNMENT (_MIPS_SZPTR/8)
1211 # if CPP_WORDSZ != 64
1212 # define ALIGN_DOUBLE
1215 # define ALIGNMENT 4
1216 # define ALIGN_DOUBLE
1218 # define DYNAMIC_LOADING
1221 # define OS_TYPE "MSWINCE"
1222 # define ALIGNMENT 4
1223 # define DATAEND /* not needed */
1225 # if defined(NETBSD)
1226 # define OS_TYPE "NETBSD"
1227 # define ALIGNMENT 4
1229 # define USE_GENERIC_PUSH_REGS
1230 extern int _fdata
[];
1231 # define DATASTART ((ptr_t)(_fdata))
1233 # define DATAEND ((ptr_t)(_end))
1234 # define DYNAMIC_LOADING
1239 # define MACH_TYPE "RS6000"
1241 # define ALIGNMENT 8
1242 # define CPP_WORDSZ 64
1244 # define ALIGNMENT 4
1245 # define CPP_WORDSZ 32
1247 extern int _data
[], _end
[];
1248 # define DATASTART ((ptr_t)((ulong)_data))
1249 # define DATAEND ((ptr_t)((ulong)_end))
1251 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1252 # define USE_GENERIC_PUSH_REGS
1253 # define DYNAMIC_LOADING
1254 /* For really old versions of AIX, this may have to be removed. */
1258 # define MACH_TYPE "HP_PA"
1260 # define CPP_WORDSZ 64
1261 # define ALIGNMENT 8
1263 # define CPP_WORDSZ 32
1264 # define ALIGNMENT 4
1265 # define ALIGN_DOUBLE
1267 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1268 # ifndef LINUX /* For now. */
1269 # define MPROTECT_VDB
1272 # define GENERIC_COMPARE_AND_SWAP
1273 /* No compare-and-swap instruction. Use pthread mutexes */
1274 /* when we absolutely have to. */
1275 # ifdef PARALLEL_MARK
1276 # define USE_MARK_BYTES
1277 /* Minimize compare-and-swap usage. */
1280 # define STACK_GROWS_UP
1282 # define OS_TYPE "HPUX"
1283 extern int __data_start
[];
1284 # define DATASTART ((ptr_t)(__data_start))
1286 /* The following appears to work for 7xx systems running HP/UX */
1287 /* 9.xx Furthermore, it might result in much faster */
1288 /* collections than HEURISTIC2, which may involve scanning */
1289 /* segments that directly precede the stack. It is not the */
1290 /* default, since it may not work on older machine/OS */
1291 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1293 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1295 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1296 /* to this. Note that the GC must be initialized before the */
1297 /* first putenv call. */
1298 extern char ** environ
;
1299 # define STACKBOTTOM ((ptr_t)environ)
1301 # define DYNAMIC_LOADING
1302 # include <unistd.h>
1303 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1305 # define PREFETCH(x) { \
1306 register long addr = (long)(x); \
1307 (void) _asm ("LDW", 0, 0, addr, 0); \
1312 # define OS_TYPE "LINUX"
1313 # define LINUX_STACKBOTTOM
1314 # define DYNAMIC_LOADING
1315 # define LINUX_DATA_START
1317 # define DATAEND (_end)
1322 # define MACH_TYPE "ALPHA"
1323 # define ALIGNMENT 8
1325 # define OS_TYPE "NETBSD"
1327 # define DATASTART GC_data_start
1328 # define ELFCLASS32 32
1329 # define ELFCLASS64 64
1330 # define ELF_CLASS ELFCLASS64
1331 # define CPP_WORDSZ 64
1332 # define DYNAMIC_LOADING
1335 # define OS_TYPE "OPENBSD"
1337 # define CPP_WORDSZ 64
1338 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1339 # define DATASTART GC_data_start
1340 # define ELFCLASS32 32
1341 # define ELFCLASS64 64
1342 # define ELF_CLASS ELFCLASS64
1343 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1344 # define DATASTART ((ptr_t) 0x140000000)
1348 # define OS_TYPE "FREEBSD"
1349 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1350 # define SIG_SUSPEND SIGUSR1
1351 # define SIG_THR_RESTART SIGUSR2
1352 # define FREEBSD_STACKBOTTOM
1354 # define DYNAMIC_LOADING
1356 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1357 extern char etext
[];
1358 extern char edata
[];
1360 # define NEED_FIND_LIMIT
1361 # define DATASTART ((ptr_t)(etext))
1362 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1363 # define DATASTART2 ((ptr_t)(edata))
1364 # define DATAEND2 ((ptr_t)(end))
1365 # define CPP_WORDSZ 64
1368 # define OS_TYPE "OSF1"
1369 # define DATASTART ((ptr_t) 0x140000000)
1371 # define DATAEND ((ptr_t) _end)
1372 extern char ** environ
;
1373 /* round up from the value of environ to the nearest page boundary */
1374 /* Probably breaks if putenv is called before collector */
1375 /* initialization. */
1376 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1377 /* # define HEURISTIC2 */
1378 /* Normally HEURISTIC2 is too conervative, since */
1379 /* the text segment immediately follows the stack. */
1380 /* Hence we give an upper pound. */
1381 /* This is currently unused, since we disabled HEURISTIC2 */
1382 extern int __start
[];
1383 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1384 # define CPP_WORDSZ 64
1385 # define MPROTECT_VDB
1386 # define DYNAMIC_LOADING
1389 # define OS_TYPE "LINUX"
1390 # define CPP_WORDSZ 64
1391 # define STACKBOTTOM ((ptr_t) 0x120000000)
1393 # define SEARCH_FOR_DATA_START
1394 # define DATASTART GC_data_start
1395 # define DYNAMIC_LOADING
1397 # define DATASTART ((ptr_t) 0x140000000)
1400 # define DATAEND (_end)
1401 # define MPROTECT_VDB
1402 /* Has only been superficially tested. May not */
1403 /* work on all versions. */
1408 # define MACH_TYPE "IA64"
1409 # define USE_GENERIC_PUSH_REGS
1410 /* We need to get preserved registers in addition to register */
1411 /* windows. That's easiest to do with setjmp. */
1412 # ifdef PARALLEL_MARK
1413 # define USE_MARK_BYTES
1414 /* Compare-and-exchange is too expensive to use for */
1415 /* setting mark bits. */
1419 # define CPP_WORDSZ 32
1420 # define ALIGN_DOUBLE
1421 /* Requires 8 byte alignment for malloc */
1422 # define ALIGNMENT 4
1427 # define CPP_WORDSZ 64
1428 # define ALIGN_DOUBLE
1429 /* Requires 16 byte alignment for malloc */
1430 # define ALIGNMENT 8
1432 # define OS_TYPE "HPUX"
1433 extern int __data_start
[];
1434 # define DATASTART ((ptr_t)(__data_start))
1435 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1436 /* to this. Note that the GC must be initialized before the */
1437 /* first putenv call. */
1438 extern char ** environ
;
1439 # define STACKBOTTOM ((ptr_t)environ)
1440 # define DYNAMIC_LOADING
1441 # include <unistd.h>
1442 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1443 /* The following was empirically determined, and is probably */
1444 /* not very robust. */
1445 /* Note that the backing store base seems to be at a nice */
1446 /* address minus one page. */
1447 # define BACKING_STORE_DISPLACEMENT 0x1000000
1448 # define BACKING_STORE_ALIGNMENT 0x1000
1449 # define BACKING_STORE_BASE \
1450 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1451 & ~(BACKING_STORE_ALIGNMENT - 1))
1454 # define CPP_WORDSZ 64
1455 # define ALIGN_DOUBLE
1456 /* Requires 16 byte alignment for malloc */
1457 # define ALIGNMENT 8
1458 # define OS_TYPE "LINUX"
1459 /* The following works on NUE and older kernels: */
1460 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1461 /* This does not work on NUE: */
1462 # define LINUX_STACKBOTTOM
1463 /* We also need the base address of the register stack */
1464 /* backing store. This is computed in */
1465 /* GC_linux_register_stack_base based on the following */
1467 # define BACKING_STORE_ALIGNMENT 0x100000
1468 # define BACKING_STORE_DISPLACEMENT 0x80000000
1469 extern char * GC_register_stackbottom
;
1470 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1471 # define SEARCH_FOR_DATA_START
1472 # define DATASTART GC_data_start
1474 # define DYNAMIC_LOADING
1476 /* In the Intel compiler environment, we seem to end up with */
1477 /* statically linked executables and an undefined reference */
1480 # define MPROTECT_VDB
1481 /* Requires Linux 2.3.47 or later. */
1483 # define DATAEND (_end)
1485 # define PREFETCH(x) \
1486 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1487 # define PREFETCH_FOR_WRITE(x) \
1488 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1489 # define CLEAR_DOUBLE(x) \
1490 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1496 # define MACH_TYPE "M88K"
1497 # define ALIGNMENT 4
1498 # define ALIGN_DOUBLE
1501 # define OS_TYPE "CX_UX"
1502 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1505 # define OS_TYPE "DGUX"
1506 extern char * GC_SysVGetDataStart();
1507 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1509 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1513 # define MACH_TYPE "S370"
1514 # define ALIGNMENT 4 /* Required by hardware */
1515 # define USE_GENERIC_PUSH_REGS
1517 # define OS_TYPE "UTS4"
1519 extern int _etext
[];
1521 extern char * GC_SysVGetDataStart();
1522 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1523 # define DATAEND (_end)
1527 # define OS_TYPE "LINUX"
1529 # define DYNAMIC_LOADING
1530 extern int __data_start
[];
1531 # define DATASTART ((ptr_t)(__data_start))
1536 # define ALIGNMENT 4
1537 extern int _etext
[];
1538 # define DATASTART ((ptr_t)(_etext))
1543 # define CPP_WORDSZ 32
1544 # define MACH_TYPE "ARM32"
1545 # define ALIGNMENT 4
1547 # define OS_TYPE "NETBSD"
1549 extern char etext
[];
1550 # define DATASTART ((ptr_t)(etext))
1551 # define USE_GENERIC_PUSH_REGS
1554 # define OS_TYPE "LINUX"
1557 # define STACK_GRAN 0x10000000
1558 # define USE_GENERIC_PUSH_REGS
1560 # define DYNAMIC_LOADING
1561 # include <features.h>
1562 # if defined(__GLIBC__) && __GLIBC__ >= 2
1563 # define LINUX_DATA_START
1565 extern char **__environ
;
1566 # define DATASTART ((ptr_t)(&__environ))
1567 /* hideous kludge: __environ is the first */
1568 /* word in crt0.o, and delimits the start */
1569 /* of the data segment, no matter which */
1570 /* ld options were passed through. */
1571 /* We could use _etext instead, but that */
1572 /* would include .rodata, which may */
1573 /* contain large read-only data tables */
1574 /* that we'd rather not scan. */
1577 # define DATAEND (_end)
1580 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1584 # define OS_TYPE "MSWINCE"
1585 # define DATAEND /* not needed */
1588 /* __data_start is usually defined in the target linker script. */
1589 extern int __data_start
[];
1590 # define DATASTART (ptr_t)(__data_start)
1591 # define USE_GENERIC_PUSH_REGS
1592 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1593 extern void *__stack_base__
;
1594 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1599 # define MACH_TYPE "SH"
1600 # define ALIGNMENT 4
1602 # define OS_TYPE "MSWINCE"
1603 # define DATAEND /* not needed */
1606 # define OS_TYPE "LINUX"
1607 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1608 # define USE_GENERIC_PUSH_REGS
1609 # define DYNAMIC_LOADING
1610 # define LINUX_DATA_START
1612 # define DATAEND (_end)
1617 # define MACH_TYPE "SH4"
1618 # define OS_TYPE "MSWINCE"
1619 # define ALIGNMENT 4
1620 # define DATAEND /* not needed */
1624 # define MACH_TYPE "X86_64"
1625 # define ALIGNMENT 8
1626 # define CPP_WORDSZ 64
1627 # define CACHE_LINE_SIZE 64
1628 # define USE_GENERIC_PUSH_REGS
1630 # define OS_TYPE "LINUX"
1631 # define LINUX_STACKBOTTOM
1632 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1633 # define MPROTECT_VDB
1635 /* We seem to get random errors in incremental mode, */
1636 /* possibly because Linux threads is itself a malloc client */
1637 /* and can't deal with the signals. */
1640 # define DYNAMIC_LOADING
1641 # ifdef UNDEFINED /* includes ro data */
1642 extern int _etext
[];
1643 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1645 # include <features.h>
1646 # define LINUX_DATA_START
1648 # define DATAEND (_end)
1651 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1653 # define PREFETCH(x) \
1654 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1655 # define PREFETCH_FOR_WRITE(x) \
1656 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1660 #ifdef LINUX_DATA_START
1661 /* Some Linux distributions arrange to define __data_start. Some */
1662 /* define data_start as a weak symbol. The latter is technically */
1663 /* broken, since the user program may define data_start, in which */
1664 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1665 /* We assume gcc. */
1666 # pragma weak __data_start
1667 extern int __data_start
[];
1668 # pragma weak data_start
1669 extern int data_start
[];
1670 # define DATASTART ((ptr_t)(__data_start != 0? __data_start : data_start))
1673 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1674 /* Rld appears to allocate some memory with its own allocator, and */
1675 /* some through malloc, which might be redirected. To make this */
1676 /* work with collectable memory, we have to scan memory allocated */
1677 /* by rld's internal malloc. */
1678 # define USE_PROC_FOR_LIBRARIES
1681 # ifndef STACK_GROWS_UP
1682 # define STACK_GROWS_DOWN
1686 # define CPP_WORDSZ 32
1695 # define DATAEND (end)
1698 # if defined(SVR4) && !defined(GETPAGESIZE)
1699 # include <unistd.h>
1700 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1703 # ifndef GETPAGESIZE
1704 # if defined(SUNOS5) || defined(IRIX5)
1705 # include <unistd.h>
1707 # define GETPAGESIZE() getpagesize()
1710 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1711 /* OS has SVR4 generic features. Probably others also qualify. */
1715 # if defined(SUNOS5) || defined(DRSNX)
1716 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1719 /* OS has SUNOS5 style signal handlers. */
1727 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1728 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1729 || defined(BSD) || defined(_AIX) || defined(MACOSX) || defined(OSF1)
1730 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1733 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1738 # undef DYNAMIC_LOADING
1743 # undef MPROTECT_VDB
1748 /* Postponed for now. */
1750 # undef MPROTECT_VDB
1753 # ifdef SMALL_CONFIG
1754 /* Presumably not worth the space it takes. */
1756 # undef MPROTECT_VDB
1760 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1763 # ifdef PARALLEL_MARK
1764 # undef MPROTECT_VDB /* For now. */
1767 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1768 # define DEFAULT_VDB
1772 # define PREFETCH(x)
1773 # define NO_PREFETCH
1776 # ifndef PREFETCH_FOR_WRITE
1777 # define PREFETCH_FOR_WRITE(x)
1778 # define NO_PREFETCH_FOR_WRITE
1781 # ifndef CACHE_LINE_SIZE
1782 # define CACHE_LINE_SIZE 32 /* Wild guess */
1785 # ifndef CLEAR_DOUBLE
1786 # define CLEAR_DOUBLE(x) \
1787 ((word*)x)[0] = 0; \
1789 # endif /* CLEAR_DOUBLE */
1791 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1792 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1793 # define GC_SOLARIS_THREADS
1796 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1797 --> inconsistent configuration
1799 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1800 --> inconsistent configuration
1802 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1803 --> inconsistent configuration
1805 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1806 --> inconsistent configuration
1808 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1809 /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */
1810 /* the necessary code is mostly there, but nobody has actually made */
1811 /* sure the right combination of pieces is compiled in, etc. */
1812 --> inconsistent configuration
1815 # if defined(PCR) || defined(SRC_M3) || \
1816 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1817 defined(GC_PTHREADS)
1821 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1822 || defined(LINT) || defined(MSWINCE) \
1823 || (defined(I386) && defined(__LCC__))
1824 /* Use setjmp based hack to mark from callee-save registers. */
1825 /* The define should move to the individual platform */
1827 # define USE_GENERIC_PUSH_REGS
1831 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1832 /* include assembly code to do it well. */
1835 /* Can we save call chain in objects for debugging? */
1836 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1837 /* to reasonable values for the platform. */
1838 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1839 /* build time, though we feel free to adjust it slightly. */
1840 /* Define NEED_CALLINFO if we either save the call stack or */
1841 /* GC_ADD_CALLER is defined. */
1843 # include <features.h>
1844 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1845 # define HAVE_BUILTIN_BACKTRACE
1850 # define CAN_SAVE_CALL_STACKS
1851 # define CAN_SAVE_CALL_ARGS
1853 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1854 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1855 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1856 # define CAN_SAVE_CALL_STACKS
1857 # define CAN_SAVE_CALL_ARGS
1859 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1860 # define CAN_SAVE_CALL_STACKS
1863 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1864 && defined(CAN_SAVE_CALL_STACKS)
1865 # define SAVE_CALL_CHAIN
1867 # ifdef SAVE_CALL_CHAIN
1868 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1869 # define NARGS SAVE_CALL_NARGS
1871 # define NARGS 0 /* Number of arguments to save for each call. */
1874 # ifdef SAVE_CALL_CHAIN
1875 # ifndef SAVE_CALL_COUNT
1876 # define NFRAMES 6 /* Number of frames to save. Even for */
1877 /* alignment reasons. */
1879 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1881 # define NEED_CALLINFO
1882 # endif /* SAVE_CALL_CHAIN */
1883 # ifdef GC_ADD_CALLER
1886 # define NEED_CALLINFO
1889 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1890 # define DBG_HDRS_ALL
1893 # endif /* GCCONFIG_H */