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-2004 Hewlett-Packard Development Company, L.P.
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.
18 * This header is private to the gc. It is almost always included from
19 * gc_priv.h. However it is possible to include it by itself if just the
20 * configuration macros are needed. In that
21 * case, a few declarations relying on types declared in gc_priv.h will be
30 /* Fake ptr_t declaration, just to avoid compilation errors. */
31 /* This avoids many instances if "ifndef GC_PRIVATE_H" below. */
32 typedef struct GC_undefined_struct * ptr_t;
35 /* Machine dependent parameters. Some tuning parameters can be found */
36 /* near the top of gc_private.h. */
38 /* Machine specific parts contributed by various people. See README file. */
40 /* First a unified test for Linux: */
41 # if defined(linux) || defined(__linux__)
47 /* And one for NetBSD: */
48 # if defined(__NetBSD__)
52 /* And one for OpenBSD: */
53 # if defined(__OpenBSD__)
57 /* And one for FreeBSD: */
58 # if defined(__FreeBSD__) && !defined(FREEBSD)
62 /* And one for Darwin: */
63 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
67 /* Determine the machine type: */
68 # if defined(__native_client__)
71 # define mach_type_known
73 # if defined(__arm__) || defined(__thumb__)
75 # if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN)
77 # define mach_type_known
80 # if defined(sun) && defined(mc68000)
83 # define mach_type_known
85 # if defined(hp9000s300)
88 # define mach_type_known
90 # if defined(OPENBSD) && defined(m68k)
92 # define mach_type_known
94 # if defined(OPENBSD) && defined(__sparc__)
96 # define mach_type_known
98 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
100 # define mach_type_known
102 # if defined(NETBSD) && defined(__powerpc__)
104 # define mach_type_known
106 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
108 # define mach_type_known
110 # if defined(NETBSD) && defined(__sh__)
112 # define mach_type_known
121 # define mach_type_known
123 # if defined(__NetBSD__) && defined(__vax__)
125 # define mach_type_known
127 # if defined(mips) || defined(__mips) || defined(_mips)
129 # if defined(nec_ews) || defined(_nec_ews)
132 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
133 # if defined(ultrix) || defined(__ultrix)
136 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
137 || defined(__SYSTYPE_SVR4__)
138 # define IRIX5 /* or IRIX 6.X */
140 # define RISCOS /* or IRIX 4.X */
144 # if defined(__NetBSD__) && defined(__MIPSEL__)
147 # define mach_type_known
149 # if defined(DGUX) && (defined(i386) || defined(__i386__))
154 # define mach_type_known
156 # if defined(sequent) && (defined(i386) || defined(__i386__))
159 # define mach_type_known
161 # if defined(sun) && (defined(i386) || defined(__i386__))
164 # define mach_type_known
166 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
169 # define mach_type_known
173 # define mach_type_known
175 # if defined(sun) && (defined(sparc) || defined(__sparc))
177 /* Test for SunOS 5.x */
184 # define mach_type_known
186 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
187 && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
190 # define mach_type_known
194 # define mach_type_known
196 # if defined(__NetBSD__) && defined(__sparc__)
198 # define mach_type_known
200 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
201 /* The above test may need refinement */
203 # if defined(_SCO_ELF)
208 # define mach_type_known
210 # if defined(_AUX_SOURCE)
213 # define mach_type_known
215 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
216 || defined(hppa) || defined(__hppa__)
218 # if !defined(LINUX) && !defined(HPUX)
221 # define mach_type_known
223 # if defined(__ia64) && defined(_HPUX_SOURCE)
228 # define mach_type_known
230 # if defined(__BEOS__) && defined(_X86_)
233 # define mach_type_known
235 # if defined(LINUX) && (defined(i386) || defined(__i386__))
237 # define mach_type_known
239 # if defined(OPENBSD) && defined(__amd64__)
241 # define mach_type_known
243 # if defined(LINUX) && defined(__x86_64__)
245 # define mach_type_known
247 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
249 # define mach_type_known
251 # if defined(LINUX) && defined(__arm__)
253 # define mach_type_known
255 # if defined(LINUX) && defined(__cris__)
259 # define mach_type_known
261 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
262 defined(powerpc64) || defined(__powerpc64__))
264 # define mach_type_known
266 # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
268 # define mach_type_known
270 # if defined(LINUX) && defined(__mc68000__)
272 # define mach_type_known
274 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
276 # define mach_type_known
278 # if defined(LINUX) && defined(__arm__)
280 # define mach_type_known
282 # if defined(LINUX) && defined(__sh__)
284 # define mach_type_known
286 # if defined(LINUX) && defined(__m32r__)
288 # define mach_type_known
290 # if defined(__alpha) || defined(__alpha__)
292 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
293 # define OSF1 /* a.k.a Digital Unix */
295 # define mach_type_known
297 # if defined(_AMIGA) && !defined(AMIGA)
302 # define mach_type_known
304 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
307 # define mach_type_known
309 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
312 # define mach_type_known
315 # if defined(__ppc__) || defined(__ppc64__)
317 # define mach_type_known
318 # elif defined(__i386__)
320 # define mach_type_known
321 # define DARWIN_DONT_PARSE_STACK
322 # define OS_TYPE "DARWIN"
323 # define DYNAMIC_LOADING
324 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
325 These aren't used when dyld support is enabled (it is by default) */
326 # define DATASTART ((ptr_t) get_etext())
327 # define DATAEND ((ptr_t) get_end())
328 # define STACKBOTTOM ((ptr_t) pthread_get_stackaddr_np(pthread_self()))
332 # define USE_MMAP_ANON
333 # define USE_ASM_PUSH_REGS
334 /* This is potentially buggy. It needs more testing. See the comments in
335 os_dep.c. It relies on threads to track writes. */
336 # ifdef GC_DARWIN_THREADS
337 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
340 # define GETPAGESIZE() getpagesize()
341 # elif defined(__arm__)
343 # define mach_type_known
344 # define DARWIN_DONT_PARSE_STACK
345 # define GC_DONT_REGISTER_MAIN_STATIC_DATA
346 # elif defined(__x86_64)
348 # define mach_type_known
351 # if defined(NeXT) && defined(mc68000)
354 # define mach_type_known
356 # if defined(NeXT) && (defined(i386) || defined(__i386__))
359 # define mach_type_known
361 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
364 # define mach_type_known
366 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
368 # define mach_type_known
370 # if defined(FREEBSD) && defined(__x86_64__)
372 # define mach_type_known
374 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
376 # define mach_type_known
378 # if defined(__NetBSD__) && defined(__x86_64__)
380 # define mach_type_known
382 # if defined(FREEBSD) && defined(__sparc__)
384 # define mach_type_known
386 # if defined(bsdi) && (defined(i386) || defined(__i386__))
389 # define mach_type_known
391 # if !defined(mach_type_known) && defined(__386BSD__)
394 # define mach_type_known
396 # if defined(_CX_UX) && defined(_M88K)
399 # define mach_type_known
401 # if defined(DGUX) && defined(m88k)
404 # define mach_type_known
406 # if defined(_WIN32_WCE)
407 /* SH3, SH4, MIPS already defined for corresponding architectures */
408 # if defined(SH3) || defined(SH4)
418 # define mach_type_known
420 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
421 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
422 # if defined(__LP64__) || defined(_WIN64)
427 # define MSWIN32 /* or Win64 */
428 # define mach_type_known
430 # if defined(_MSC_VER) && defined(_M_IA64)
432 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
433 /* variants as a differnt platform. */
436 # if defined(__DJGPP__)
439 # define DJGPP /* MSDOS running the DJGPP port of GCC */
441 # define mach_type_known
443 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
446 # define mach_type_known
448 # if defined(__MINGW32__)
451 # define mach_type_known
453 # if defined(__BORLANDC__)
456 # define mach_type_known
458 # if defined(_UTS) && !defined(mach_type_known)
461 # define mach_type_known
465 # define mach_type_known
467 # if defined(__embedded__) && defined(PPC)
470 # define mach_type_known
473 # if defined(__WATCOMC__) && defined(__386__)
475 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
476 # if defined(__OS2__)
479 # if defined(__WINDOWS_386__) || defined(__NT__)
486 # define mach_type_known
488 # if defined(__s390__) && defined(LINUX)
490 # define mach_type_known
492 # if defined(__GNU__)
493 # if defined(__i386__)
494 /* The Debian Hurd running on generic PC */
497 # define mach_type_known
501 /* Feel free to add more clauses here */
503 /* Or manually define the machine type here. A machine type is */
504 /* characterized by the architecture. Some */
505 /* machine types are further subdivided by OS. */
506 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
507 /* Note that SGI IRIX is treated identically to RISCOS. */
508 /* SYSV on an M68K actually means A/UX. */
509 /* The distinction in these cases is usually the stack starting address */
510 # ifndef mach_type_known
511 --> unknown machine type
513 /* Mapping is: M68K ==> Motorola 680X0 */
514 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
515 /* MACOS and AMIGA variants) */
516 /* I386 ==> Intel 386 */
517 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
518 /* FREEBSD, THREE86BSD, MSWIN32, */
519 /* BSDI,SUNOS5, NEXT, other variants) */
520 /* NS32K ==> Encore Multimax */
521 /* MIPS ==> R2000 or R3000 */
522 /* (RISCOS, ULTRIX variants) */
523 /* VAX ==> DEC VAX */
524 /* (BSD, ULTRIX variants) */
525 /* RS6000 ==> IBM RS/6000 AIX3.X */
526 /* RT ==> IBM PC/RT */
527 /* HP_PA ==> HP9000/700 & /800 */
529 /* SPARC ==> SPARC v7/v8/v9 */
530 /* (SUNOS4, SUNOS5, LINUX, */
531 /* DRSNX variants) */
532 /* ALPHA ==> DEC Alpha */
533 /* (OSF1 and LINUX variants) */
534 /* M88K ==> Motorola 88XX0 */
535 /* (CX_UX and DGUX) */
536 /* S370 ==> 370-like machine */
537 /* running Amdahl UTS4 */
538 /* S390 ==> 390-like machine */
540 /* ARM32 ==> Intel StrongARM */
541 /* IA64 ==> Intel IPF */
543 /* (LINUX and HPUX) */
544 /* SH ==> Hitachi SuperH */
545 /* (LINUX & MSWINCE) */
546 /* X86_64 ==> AMD x86-64 */
547 /* POWERPC ==> IBM/Apple PowerPC */
548 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
549 /* LINUX, NETBSD, NOSYS variants) */
550 /* Handles 32 and 64-bit variants. */
551 /* AIX should be handled here, but */
552 /* that's called an RS6000. */
553 /* CRIS ==> Axis Etrax */
554 /* M32R ==> Renesas M32R */
558 * For each architecture and OS, the following need to be defined:
560 * CPP_WORDSZ is a simple integer constant representing the word size.
561 * in bits. We assume byte addressibility, where a byte has 8 bits.
562 * We also assume CPP_WORDSZ is either 32 or 64.
563 * (We care about the length of pointers, not hardware
564 * bus widths. Thus a 64 bit processor with a C compiler that uses
565 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
567 * MACH_TYPE is a string representation of the machine type.
568 * OS_TYPE is analogous for the OS.
570 * ALIGNMENT is the largest N, such that
571 * all pointer are guaranteed to be aligned on N byte boundaries.
572 * defining it to be 1 will always work, but perform poorly.
574 * DATASTART is the beginning of the data segment.
575 * On some platforms SEARCH_FOR_DATA_START is defined.
576 * SEARCH_FOR_DATASTART will cause GC_data_start to
577 * be set to an address determined by accessing data backwards from _end
578 * until an unmapped page is found. DATASTART will be defined to be
580 * On UNIX-like systems, the collector will scan the area between DATASTART
581 * and DATAEND for root pointers.
583 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
584 * RTH suggests gaining access to linker script synth'd values with
585 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
586 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
587 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
588 * without any special options.
590 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
593 * STACKBOTTOM is the cool end of the stack, which is usually the
594 * highest address in the stack.
595 * Under PCR or OS/2, we have other ways of finding thread stacks.
596 * For each machine, the following should:
597 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
598 * 2) define exactly one of
599 * STACKBOTTOM (should be defined to be an expression)
603 * If STACKBOTTOM is defined, then it's value will be used directly as the
604 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
605 * with a method appropriate for most Linux systems. Currently we look
606 * first for __libc_stack_end, and if that fails read it from /proc.
607 * If either of the last two macros are defined, then STACKBOTTOM is computed
608 * during collector startup using one of the following two heuristics:
609 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
610 * the next multiple of STACK_GRAN.
611 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
612 * in small steps (decrement if STACK_GROWS_UP), and read the value
613 * at each location. Remember the value when the first
614 * Segmentation violation or Bus error is signalled. Round that
615 * to the nearest plausible page boundary, and use that instead
618 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
619 * the value of environ is a pointer that can serve as STACKBOTTOM.
620 * I expect that HEURISTIC2 can be replaced by this approach, which
621 * interferes far less with debugging. However it has the disadvantage
622 * that it's confused by a putenv call before the collector is initialized.
623 * This could be dealt with by intercepting putenv ...
625 * If no expression for STACKBOTTOM can be found, and neither of the above
626 * heuristics are usable, the collector can still be used with all of the above
627 * undefined, provided one of the following is done:
628 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
629 * without reference to STACKBOTTOM. This is appropriate for use in
630 * conjunction with thread packages, since there will be multiple stacks.
631 * (Allocating thread stacks in the heap, and treating them as ordinary
632 * heap data objects is also possible as a last resort. However, this is
633 * likely to introduce significant amounts of excess storage retention
634 * unless the dead parts of the thread stacks are periodically cleared.)
635 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
636 * If the author of the client code controls the main program, this is
637 * easily accomplished by introducing a new main program, setting
638 * GC_stackbottom to the address of a local variable, and then calling
639 * the original main program. The new main program would read something
642 * # include "gc_private.h"
644 * main(argc, argv, envp)
646 * char **argv, **envp;
650 * GC_stackbottom = (ptr_t)(&dummy);
651 * return(real_main(argc, argv, envp));
655 * Each architecture may also define the style of virtual dirty bit
656 * implementation to be used:
657 * MPROTECT_VDB: Write protect the heap and catch faults.
658 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
660 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
661 * defined GC_register_dynamic_libraries() for the architecture.
663 * An architecture may define PREFETCH(x) to preload the cache with *x.
664 * This defaults to a no-op.
666 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
668 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
669 * clear the two words at GC_malloc-aligned address x. By default,
670 * word stores of 0 are used instead.
672 * HEAP_START may be defined as the initial address hint for mmap-based
676 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
677 * to push the relevant registers onto the stack. This generally makes
678 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
680 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
681 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
682 && !defined(__INTEL_COMPILER) \
683 && !defined(__PATHCC__)
684 # define HAVE_BUILTIN_UNWIND_INIT
687 # define STACK_GRAN 0x1000000
689 # define MACH_TYPE "M68K"
692 # define OS_TYPE "OPENBSD"
695 # define DATASTART GC_data_start
696 # define DYNAMIC_LOADING
699 # define DATASTART ((ptr_t)(etext))
701 # define USE_GENERIC_PUSH_REGS
704 # define OS_TYPE "NETBSD"
707 # define DATASTART GC_data_start
708 # define DYNAMIC_LOADING
711 # define DATASTART ((ptr_t)(etext))
713 # define USE_GENERIC_PUSH_REGS
716 # define OS_TYPE "LINUX"
717 # define STACKBOTTOM ((ptr_t)0xf0000000)
718 # define USE_GENERIC_PUSH_REGS
719 /* We never got around to the assembly version. */
720 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
722 # define DYNAMIC_LOADING
723 # include <features.h>
724 # if defined(__GLIBC__)&& __GLIBC__>=2
725 # define SEARCH_FOR_DATA_START
727 # if defined(PLATFORM_ANDROID)
728 # define __environ environ
730 extern char **__environ;
731 # define DATASTART ((ptr_t)(&__environ))
732 /* hideous kludge: __environ is the first */
733 /* word in crt0.o, and delimits the start */
734 /* of the data segment, no matter which */
735 /* ld options were passed through. */
736 /* We could use _etext instead, but that */
737 /* would include .rodata, which may */
738 /* contain large read-only data tables */
739 /* that we'd rather not scan. */
740 # endif /* !GLIBC2 */
742 # define DATAEND (_end)
745 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
749 # define OS_TYPE "SUNOS4"
751 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
752 # define HEURISTIC1 /* differs */
753 # define DYNAMIC_LOADING
756 # define OS_TYPE "HP"
758 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
759 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
760 /* empirically determined. seems to work. */
762 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
765 # define OS_TYPE "SYSV"
767 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
769 +((word)etext & 0x1fff))
770 /* This only works for shared-text binaries with magic number 0413.
771 The other sorts of SysV binaries put the data at the end of the text,
772 in which case the default of etext would work. Unfortunately,
773 handling both would require having the magic-number available.
776 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
777 /* The stack starts at the top of memory, but */
778 /* 0x0 cannot be used as setjump_test complains */
779 /* that the stack direction is incorrect. Two */
780 /* bytes down from 0x0 should be safe enough. */
782 # include <sys/mmu.h>
783 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
786 # define OS_TYPE "AMIGA"
787 /* STACKBOTTOM and DATASTART handled specially */
789 # define DATAEND /* not needed */
790 # define GETPAGESIZE() 4096
796 # define OS_TYPE "MACOS"
797 /* see os_dep.c for details of global data segments. */
798 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
799 # define DATAEND /* not needed */
800 # define GETPAGESIZE() 4096
803 # define OS_TYPE "NEXT"
804 # define DATASTART ((ptr_t) get_etext())
805 # define STACKBOTTOM ((ptr_t) 0x4000000)
806 # define DATAEND /* not needed */
810 # if defined(POWERPC)
811 # define MACH_TYPE "POWERPC"
813 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
817 # define OS_TYPE "MACOS"
818 /* see os_dep.c for details of global data segments. */
819 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
820 # define DATAEND /* not needed */
824 # if defined(__powerpc64__)
826 # define CPP_WORDSZ 64
828 # define HBLKSIZE 4096
833 # define OS_TYPE "LINUX"
834 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
835 /* executable on a 64 bit kernel. */
836 # define LINUX_STACKBOTTOM
837 # define DYNAMIC_LOADING
838 # define SEARCH_FOR_DATA_START
840 # define DATAEND (_end)
845 # define CPP_WORDSZ 64
849 # define OS_TYPE "DARWIN"
850 # define DYNAMIC_LOADING
851 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
852 These aren't used when dyld support is enabled (it is by default) */
853 # define DATASTART ((ptr_t) get_etext())
854 # define DATAEND ((ptr_t) get_end())
855 # define STACKBOTTOM ((ptr_t) 0xc0000000)
857 # define USE_MMAP_ANON
858 # define USE_ASM_PUSH_REGS
859 /* This is potentially buggy. It needs more testing. See the comments in
860 os_dep.c. It relies on threads to track writes. */
861 # ifdef GC_DARWIN_THREADS
862 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
865 # define GETPAGESIZE() getpagesize()
866 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
867 /* The performance impact of prefetches is untested */
868 # define PREFETCH(x) \
869 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
870 # define PREFETCH_FOR_WRITE(x) \
871 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
873 /* There seems to be some issues with trylock hanging on darwin. This
874 should be looked into some more */
875 # define NO_PTHREAD_TRYLOCK
879 # define OS_TYPE "FREEBSD"
880 # ifndef GC_FREEBSD_THREADS
881 # define MPROTECT_VDB
883 # define SIG_SUSPEND SIGUSR1
884 # define SIG_THR_RESTART SIGUSR2
885 # define FREEBSD_STACKBOTTOM
887 # define DYNAMIC_LOADING
890 extern char * GC_FreeBSDGetDataStart();
891 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
895 # define OS_TYPE "NETBSD"
898 # define DATASTART GC_data_start
899 # define DYNAMIC_LOADING
901 # ifdef SN_TARGET_PS3
903 # define CPP_WORDSZ 32
906 // extern int _dso_handle[];
907 extern int __bss_start;
909 # define DATAEND (_end)
910 # define DATASTART (__bss_start)
911 # define STACKBOTTOM ((ptr_t) ps3_get_stack_bottom ())
912 # define USE_GENERIC_PUSHREGS
917 # define OS_TYPE "NOSYS"
918 extern void __end[], __dso_handle[];
919 # define DATASTART (__dso_handle) /* OK, that's ugly. */
920 # define DATAEND (__end)
921 /* Stack starts at 0xE0000000 for the simulator. */
923 # define STACK_GRAN 0x10000000
929 # define MACH_TYPE "VAX"
930 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
932 # define DATASTART ((ptr_t)(etext))
934 # define OS_TYPE "BSD"
936 /* HEURISTIC2 may be OK, but it's hard to test. */
939 # define OS_TYPE "ULTRIX"
940 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
945 # define MACH_TYPE "RT"
947 # define DATASTART ((ptr_t) 0x10000000)
948 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
952 # define MACH_TYPE "SPARC"
953 # if defined(__arch64__) || defined(__sparcv9)
955 # define CPP_WORDSZ 64
956 # define ELF_CLASS ELFCLASS64
958 # define ALIGNMENT 4 /* Required by hardware */
959 # define CPP_WORDSZ 32
961 # define ALIGN_DOUBLE
962 # ifdef _FILE_OFFSET_BITS
963 # undef _FILE_OFFSET_BITS /* libelf.h & procfs.h doesn't compile with large file support */
964 # define _FILE_OFFSET_BITS 32
967 # define OS_TYPE "SUNOS5"
970 extern ptr_t GC_SysVGetDataStart();
971 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
972 # define DATAEND (_end)
973 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
975 /* Otherwise we now use calloc. Mmap may result in the */
976 /* heap interleaved with thread stacks, which can result in */
977 /* excessive blacklisting. Sbrk is unusable since it */
978 /* doesn't interact correctly with the system malloc. */
981 # define HEAP_START (ptr_t)0x40000000
983 # define HEAP_START DATAEND
986 /* HEURISTIC1 reportedly no longer works under 2.7. */
987 /* HEURISTIC2 probably works, but this appears to be preferable. */
988 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
989 /* installations that's undefined. We work around this with a */
991 # include <sys/vmparam.h>
993 /* This should work everywhere, but doesn't. */
994 # define STACKBOTTOM USRSTACK
999 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1000 /* getpagesize() appeared to be missing from at least one */
1001 /* Solaris 5.4 installation. Weird. */
1002 # define DYNAMIC_LOADING
1005 # define OS_TYPE "SUNOS4"
1006 /* [If you have a weak stomach, don't read this.] */
1007 /* We would like to use: */
1008 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
1009 /* This fails occasionally, due to an ancient, but very */
1010 /* persistent ld bug. etext is set 32 bytes too high. */
1011 /* We instead read the text segment size from the a.out */
1012 /* header, which happens to be mapped into our address space */
1013 /* at the start of the text segment. The detective work here */
1014 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
1015 /* Serpette of INRIA. */
1016 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
1017 # define TEXTSTART 0x2000
1018 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
1019 # define MPROTECT_VDB
1021 # define DYNAMIC_LOADING
1024 # define OS_TYPE "DRSNX"
1025 extern ptr_t GC_SysVGetDataStart();
1027 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1028 # define MPROTECT_VDB
1029 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
1030 # define DYNAMIC_LOADING
1033 # define OS_TYPE "LINUX"
1035 # define DYNAMIC_LOADING
1037 Linux Sparc/a.out not supported
1040 # include <features.h>
1041 # if defined(__GLIBC__) && __GLIBC__ >= 2
1042 # define SEARCH_FOR_DATA_START
1044 extern char **__environ;
1045 # define DATASTART ((ptr_t)(&__environ))
1046 /* hideous kludge: __environ is the first */
1047 /* word in crt0.o, and delimits the start */
1048 /* of the data segment, no matter which */
1049 /* ld options were passed through. */
1050 /* We could use _etext instead, but that */
1051 /* would include .rodata, which may */
1052 /* contain large read-only data tables */
1053 /* that we'd rather not scan. */
1056 # define DATAEND (_end)
1057 # define LINUX_STACKBOTTOM
1060 # define OS_TYPE "OPENBSD"
1061 # define STACKBOTTOM ((ptr_t) 0xf8000000)
1063 # define DATASTART ((ptr_t)(etext))
1066 # define OS_TYPE "NETBSD"
1069 # define DATASTART GC_data_start
1070 # define DYNAMIC_LOADING
1072 extern char etext[];
1073 # define DATASTART ((ptr_t)(etext))
1077 # define OS_TYPE "FREEBSD"
1078 # define SIG_SUSPEND SIGUSR1
1079 # define SIG_THR_RESTART SIGUSR2
1080 # define FREEBSD_STACKBOTTOM
1082 # define DYNAMIC_LOADING
1084 extern char etext[];
1085 extern char edata[];
1087 # define NEED_FIND_LIMIT
1088 # define DATASTART ((ptr_t)(&etext))
1089 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1090 # define DATASTART2 ((ptr_t)(&edata))
1091 # define DATAEND2 ((ptr_t)(&end))
1096 # if defined( NACL )
1097 # define MACH_TYPE "NACL"
1098 # define CPP_WORDSZ 32
1099 # define ALIGNMENT 4
1101 # define MACH_TYPE "I386"
1102 # if defined(__LP64__) || defined(_WIN64)
1103 # define CPP_WORDSZ 64
1104 # define ALIGNMENT 8
1106 # define CPP_WORDSZ 32
1107 # define ALIGNMENT 4
1109 /* Appears to hold for all "32 bit" compilers */
1110 /* except Borland. The -a4 option fixes */
1112 /* Ivan Demakov: For Watcom the option is -zp4. */
1114 # ifndef SMALL_CONFIG
1115 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1116 /* improvement on Pentiums. */
1118 # ifdef HAVE_BUILTIN_UNWIND_INIT
1119 # define USE_GENERIC_PUSH_REGS
1122 # define OS_TYPE "SEQUENT"
1124 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1125 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1128 # define OS_TYPE "BEOS"
1130 # define GETPAGESIZE() B_PAGE_SIZE
1132 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1135 # define OS_TYPE "SUNOS5"
1136 extern int _etext[], _end[];
1137 extern ptr_t GC_SysVGetDataStart();
1138 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1139 # define DATAEND (_end)
1140 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1141 /* but reportedly breaks under 2.8. It appears that the stack */
1142 /* base is a property of the executable, so this should not break */
1143 /* old executables. */
1144 /* HEURISTIC2 probably works, but this appears to be preferable. */
1145 # include <sys/vm.h>
1146 # define STACKBOTTOM USRSTACK
1147 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1148 /* It appears to be fixed in 2.8 and 2.9. */
1149 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1150 /* Reading of dirty bits doesn't seem to work even in solaris 10 */
1151 /*# define PROC_VDB */
1153 # define DYNAMIC_LOADING
1154 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1156 /* Otherwise we now use calloc. Mmap may result in the */
1157 /* heap interleaved with thread stacks, which can result in */
1158 /* excessive blacklisting. Sbrk is unusable since it */
1159 /* doesn't interact correctly with the system malloc. */
1162 # define HEAP_START (ptr_t)0x40000000
1164 # define HEAP_START DATAEND
1168 # define OS_TYPE "SCO"
1170 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1172 +((word)etext & 0xfff))
1173 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1176 # define OS_TYPE "SCO_ELF"
1178 # define DATASTART ((ptr_t)(etext))
1179 # define STACKBOTTOM ((ptr_t) 0x08048000)
1180 # define DYNAMIC_LOADING
1181 # define ELF_CLASS ELFCLASS32
1184 # define OS_TYPE "DGUX"
1185 extern int _etext, _end;
1186 extern ptr_t GC_SysVGetDataStart();
1187 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1188 # define DATAEND (&_end)
1189 # define STACK_GROWS_DOWN
1191 # include <unistd.h>
1192 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1193 # define DYNAMIC_LOADING
1196 # endif /* USE_MMAP */
1197 # define MAP_FAILED (void *) -1
1199 # define HEAP_START (ptr_t)0x40000000
1200 # else /* USE_MMAP */
1201 # define HEAP_START DATAEND
1202 # endif /* USE_MMAP */
1205 # define OS_TYPE "NACL"
1207 //# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1208 # define DATASTART ((ptr_t)0x10000000)
1210 # define DATAEND (_end)
1213 # endif /* STACK_GRAN */
1214 # define STACK_GRAN 0x10000
1222 # ifdef USE_MMAP_ANON
1223 # undef USE_MMAP_ANON
1225 # ifdef USE_MMAP_FIXED
1226 # undef USE_MMAP_FIXED
1228 # define GETPAGESIZE() 65536
1229 # define MAX_NACL_GC_THREADS 1024
1233 /* The Intel compiler doesn't like inline assembly */
1234 # define USE_GENERIC_PUSH_REGS
1236 # define OS_TYPE "LINUX"
1237 # define LINUX_STACKBOTTOM
1241 # define STACK_GRAN 0x10000000
1242 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1243 /* different kernel configurations. In particular, systems */
1244 /* with 2GB physical memory will usually move the user */
1245 /* address space limit, and hence initial SP to 0x80000000. */
1247 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1248 # define MPROTECT_VDB
1250 /* We seem to get random errors in incremental mode, */
1251 /* possibly because Linux threads is itself a malloc client */
1252 /* and can't deal with the signals. */
1254 # define HEAP_START (ptr_t)0x1000
1255 /* This encourages mmap to give us low addresses, */
1256 /* thus allowing the heap to grow to ~3GB */
1258 # define DYNAMIC_LOADING
1259 # ifdef UNDEFINED /* includes ro data */
1260 extern int _etext[];
1261 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1263 # include <features.h>
1264 # if defined(__GLIBC__) && __GLIBC__ >= 2
1265 # define SEARCH_FOR_DATA_START
1267 extern char **__environ;
1268 # define DATASTART ((ptr_t)(&__environ))
1269 /* hideous kludge: __environ is the first */
1270 /* word in crt0.o, and delimits the start */
1271 /* of the data segment, no matter which */
1272 /* ld options were passed through. */
1273 /* We could use _etext instead, but that */
1274 /* would include .rodata, which may */
1275 /* contain large read-only data tables */
1276 /* that we'd rather not scan. */
1279 # define DATAEND (_end)
1282 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1284 # ifdef USE_I686_PREFETCH
1285 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1286 /* for the next rtelease. */
1287 # define PREFETCH(x) \
1288 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1289 /* Empirically prefetcht0 is much more effective at reducing */
1290 /* cache miss stalls for the targetted load instructions. But it */
1291 /* seems to interfere enough with other cache traffic that the net */
1292 /* result is worse than prefetchnta. */
1294 /* Using prefetches for write seems to have a slight negative */
1295 /* impact on performance, at least for a PIII/500. */
1296 # define PREFETCH_FOR_WRITE(x) \
1297 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1300 # ifdef USE_3DNOW_PREFETCH
1301 # define PREFETCH(x) \
1302 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1303 # define PREFETCH_FOR_WRITE(x) \
1304 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1308 # define OS_TYPE "CYGWIN32"
1309 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1310 # define DATAEND ((ptr_t)GC_DATAEND)
1312 # define STACK_GRAN 0x10000
1316 # define OS_TYPE "OS2"
1317 /* STACKBOTTOM and DATASTART are handled specially in */
1318 /* os_dep.c. OS2 actually has the right */
1320 # define DATAEND /* not needed */
1321 # define USE_GENERIC_PUSH_REGS
1324 # define OS_TYPE "MSWIN32"
1325 /* STACKBOTTOM and DATASTART are handled specially in */
1327 # ifndef __WATCOMC__
1328 # define MPROTECT_VDB
1330 # define DATAEND /* not needed */
1333 # define OS_TYPE "MSWINCE"
1334 # define DATAEND /* not needed */
1337 # define OS_TYPE "DJGPP"
1338 # include "stubinfo.h"
1341 extern int __djgpp_stack_limit;
1342 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1343 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1345 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1346 /* This may not be right. */
1349 # define OS_TYPE "OPENBSD"
1350 # ifdef GC_OPENBSD_THREADS
1351 # define UTHREAD_SP_OFFSET 192
1353 # include <sys/param.h>
1354 # include <uvm/uvm_extern.h>
1355 # define STACKBOTTOM USRSTACK
1357 extern int __data_start[];
1358 # define DATASTART ((ptr_t)(__data_start))
1360 # define DATAEND ((ptr_t)(&_end))
1361 # define DYNAMIC_LOADING
1364 # define OS_TYPE "FREEBSD"
1365 # ifndef GC_FREEBSD_THREADS
1366 # define MPROTECT_VDB
1368 # define SIG_SUSPEND SIGTSTP
1369 # define SIG_THR_RESTART SIGCONT
1370 # define FREEBSD_STACKBOTTOM
1372 # define DYNAMIC_LOADING
1374 extern char etext[];
1375 extern char * GC_FreeBSDGetDataStart();
1376 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1379 # define OS_TYPE "NETBSD"
1381 # define DYNAMIC_LOADING
1385 # define OS_TYPE "THREE86BSD"
1388 # define OS_TYPE "BSDI"
1390 # if defined(OPENBSD) || defined(NETBSD) \
1391 || defined(THREE86BSD) || defined(BSDI)
1393 extern char etext[];
1394 # define DATASTART ((ptr_t)(etext))
1397 # define OS_TYPE "NEXT"
1398 # define DATASTART ((ptr_t) get_etext())
1399 # define STACKBOTTOM ((ptr_t)0xc0000000)
1400 # define DATAEND /* not needed */
1403 # define OS_TYPE "DOS4GW"
1404 extern long __nullarea;
1406 extern char *_STACKTOP;
1407 /* Depending on calling conventions Watcom C either precedes
1408 or does not precedes with undescore names of C-variables.
1409 Make sure startup code variables always have the same names. */
1410 #pragma aux __nullarea "*";
1411 #pragma aux _end "*";
1412 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1413 /* confused? me too. */
1414 # define DATASTART ((ptr_t) &__nullarea)
1415 # define DATAEND ((ptr_t) &_end)
1418 # define OS_TYPE "HURD"
1419 # define STACK_GROWS_DOWN
1421 extern int __data_start[];
1422 # define DATASTART ( (ptr_t) (__data_start))
1424 # define DATAEND ( (ptr_t) (_end))
1425 /* # define MPROTECT_VDB Not quite working yet? */
1426 # define DYNAMIC_LOADING
1431 # define MACH_TYPE "NS32K"
1432 # define ALIGNMENT 4
1433 extern char **environ;
1434 # define DATASTART ((ptr_t)(&environ))
1435 /* hideous kludge: environ is the first */
1436 /* word in crt0.o, and delimits the start */
1437 /* of the data segment, no matter which */
1438 /* ld options were passed through. */
1439 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1443 # define MACH_TYPE "MIPS"
1445 /* This was developed for a linuxce style platform. Probably */
1446 /* needs to be tweaked for workstation class machines. */
1447 # define OS_TYPE "LINUX"
1448 # define DYNAMIC_LOADING
1450 # define DATAEND (_end)
1451 #pragma weak __data_start
1452 extern int __data_start[];
1453 # define DATASTART ((ptr_t)(__data_start))
1454 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1455 # define ALIGNMENT 8
1456 # define CPP_WORDSZ 64
1458 # define ALIGNMENT 4
1460 # define USE_GENERIC_PUSH_REGS
1461 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1462 # define LINUX_STACKBOTTOM
1464 # define STACKBOTTOM 0x80000000
1469 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1470 extern int _fdata[], _end[];
1471 # define DATASTART ((ptr_t)_fdata)
1472 # define DATAEND ((ptr_t)_end)
1473 # define CPP_WORDSZ _MIPS_SZPTR
1474 # define ALIGNMENT (_MIPS_SZPTR/8)
1476 extern int etext[], edata[], end[];
1477 extern int _DYNAMIC_LINKING[], _gp[];
1478 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1479 + ((word)etext & 0xffff)))
1480 # define DATAEND (edata)
1481 # define DATASTART2 (_DYNAMIC_LINKING \
1482 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1484 # define DATAEND2 (end)
1485 # define ALIGNMENT 4
1487 # define OS_TYPE "EWS4800"
1488 # define USE_GENERIC_PUSH_REGS 1
1492 # define DATASTART (ptr_t)0x10000000
1493 /* Could probably be slightly higher since */
1494 /* startup code allocates lots of stuff. */
1495 # define OS_TYPE "ULTRIX"
1496 # define ALIGNMENT 4
1500 # define DATASTART (ptr_t)0x10000000
1501 # define OS_TYPE "RISCOS"
1502 # define ALIGNMENT 4 /* Required by hardware */
1506 extern int _fdata[];
1507 # define DATASTART ((ptr_t)(_fdata))
1509 # define HEAP_START (ptr_t)0x30000000
1511 # define HEAP_START DATASTART
1513 /* Lowest plausible heap address. */
1514 /* In the MMAP case, we map there. */
1515 /* In either case it is used to identify */
1516 /* heap sections so they're not */
1517 /* considered as roots. */
1518 # define OS_TYPE "IRIX5"
1519 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1520 /* of recent breakage. */
1522 # define CPP_WORDSZ _MIPS_SZPTR
1523 # define ALIGNMENT (_MIPS_SZPTR/8)
1524 # if CPP_WORDSZ != 64
1525 # define ALIGN_DOUBLE
1528 # define ALIGNMENT 4
1529 # define ALIGN_DOUBLE
1531 # define DYNAMIC_LOADING
1534 # define OS_TYPE "MSWINCE"
1535 # define ALIGNMENT 4
1536 # define DATAEND /* not needed */
1538 # if defined(NETBSD)
1539 # define ALIGNMENT 4
1540 # define OS_TYPE "NETBSD"
1542 # define USE_GENERIC_PUSH_REGS
1545 # define DATASTART GC_data_start
1546 # define NEED_FIND_LIMIT
1547 # define DYNAMIC_LOADING
1549 # define DATASTART ((ptr_t) 0x10000000)
1550 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1556 # define MACH_TYPE "RS6000"
1561 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1564 # define ALIGNMENT 8
1565 # define CPP_WORDSZ 64
1566 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1568 # define ALIGNMENT 4
1569 # define CPP_WORDSZ 32
1570 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1573 # define USE_MMAP_ANON
1574 /* From AIX linker man page:
1575 _text Specifies the first location of the program.
1576 _etext Specifies the first location after the program.
1577 _data Specifies the first location of the data.
1578 _edata Specifies the first location after the initialized data
1579 _end or end Specifies the first location after all data.
1581 extern int _data[], _end[];
1582 # define DATASTART ((ptr_t)((ulong)_data))
1583 # define DATAEND ((ptr_t)((ulong)_end))
1585 # define USE_GENERIC_PUSH_REGS
1586 # define DYNAMIC_LOADING
1587 /* For really old versions of AIX, this may have to be removed. */
1591 # define MACH_TYPE "HP_PA"
1593 # define CPP_WORDSZ 64
1594 # define ALIGNMENT 8
1596 # define CPP_WORDSZ 32
1597 # define ALIGNMENT 4
1598 # define ALIGN_DOUBLE
1600 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1601 # ifndef LINUX /* For now. */
1602 # define MPROTECT_VDB
1605 # define GENERIC_COMPARE_AND_SWAP
1606 /* No compare-and-swap instruction. Use pthread mutexes */
1607 /* when we absolutely have to. */
1608 # ifdef PARALLEL_MARK
1609 # define USE_MARK_BYTES
1610 /* Minimize compare-and-swap usage. */
1613 # define STACK_GROWS_UP
1615 # define OS_TYPE "HPUX"
1616 extern int __data_start[];
1617 # define DATASTART ((ptr_t)(__data_start))
1619 /* The following appears to work for 7xx systems running HP/UX */
1620 /* 9.xx Furthermore, it might result in much faster */
1621 /* collections than HEURISTIC2, which may involve scanning */
1622 /* segments that directly precede the stack. It is not the */
1623 /* default, since it may not work on older machine/OS */
1624 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1626 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1628 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1629 /* to this. Note that the GC must be initialized before the */
1630 /* first putenv call. */
1631 extern char ** environ;
1632 # define STACKBOTTOM ((ptr_t)environ)
1634 # define DYNAMIC_LOADING
1635 # include <unistd.h>
1636 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1638 # define PREFETCH(x) { \
1639 register long addr = (long)(x); \
1640 (void) _asm ("LDW", 0, 0, addr, 0); \
1645 # define OS_TYPE "LINUX"
1646 # define LINUX_STACKBOTTOM
1647 # define DYNAMIC_LOADING
1648 # define SEARCH_FOR_DATA_START
1650 # define DATAEND (&_end)
1655 # define MACH_TYPE "ALPHA"
1656 # define ALIGNMENT 8
1657 # define CPP_WORDSZ 64
1659 # define USE_GENERIC_PUSH_REGS
1660 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1661 /* fp registers in some cases when the target is a 21264. The assembly */
1662 /* code doesn't handle that yet, and version dependencies make that a */
1663 /* bit tricky. Do the easy thing for now. */
1666 # define OS_TYPE "NETBSD"
1668 # define DATASTART GC_data_start
1669 # define ELFCLASS32 32
1670 # define ELFCLASS64 64
1671 # define ELF_CLASS ELFCLASS64
1672 # define DYNAMIC_LOADING
1675 # define OS_TYPE "OPENBSD"
1677 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1678 # define DATASTART GC_data_start
1679 # define ELFCLASS32 32
1680 # define ELFCLASS64 64
1681 # define ELF_CLASS ELFCLASS64
1682 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1683 # define DATASTART ((ptr_t) 0x140000000)
1687 # define OS_TYPE "FREEBSD"
1688 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1689 # define SIG_SUSPEND SIGTSTP
1690 # define SIG_THR_RESTART SIGCONT
1691 # define FREEBSD_STACKBOTTOM
1693 # define DYNAMIC_LOADING
1695 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1696 extern char etext[];
1697 extern char edata[];
1699 # define NEED_FIND_LIMIT
1700 # define DATASTART ((ptr_t)(&etext))
1701 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1702 # define DATASTART2 ((ptr_t)(&edata))
1703 # define DATAEND2 ((ptr_t)(&end))
1706 # define OS_TYPE "OSF1"
1707 # define DATASTART ((ptr_t) 0x140000000)
1709 # define DATAEND ((ptr_t) &_end)
1710 extern char ** environ;
1711 /* round up from the value of environ to the nearest page boundary */
1712 /* Probably breaks if putenv is called before collector */
1713 /* initialization. */
1714 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1715 /* # define HEURISTIC2 */
1716 /* Normally HEURISTIC2 is too conervative, since */
1717 /* the text segment immediately follows the stack. */
1718 /* Hence we give an upper pound. */
1719 /* This is currently unused, since we disabled HEURISTIC2 */
1720 extern int __start[];
1721 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1722 # ifndef GC_OSF1_THREADS
1723 /* Unresolved signal issues with threads. */
1724 # define MPROTECT_VDB
1726 # define DYNAMIC_LOADING
1729 # define OS_TYPE "LINUX"
1730 # define LINUX_STACKBOTTOM
1732 # define SEARCH_FOR_DATA_START
1733 # define DYNAMIC_LOADING
1735 # define DATASTART ((ptr_t) 0x140000000)
1738 # define DATAEND (_end)
1739 # define MPROTECT_VDB
1740 /* Has only been superficially tested. May not */
1741 /* work on all versions. */
1746 # define MACH_TYPE "IA64"
1747 # define USE_GENERIC_PUSH_REGS
1748 /* We need to get preserved registers in addition to register */
1749 /* windows. That's easiest to do with setjmp. */
1750 # ifdef PARALLEL_MARK
1751 # define USE_MARK_BYTES
1752 /* Compare-and-exchange is too expensive to use for */
1753 /* setting mark bits. */
1757 # define CPP_WORDSZ 32
1758 # define ALIGN_DOUBLE
1759 /* Requires 8 byte alignment for malloc */
1760 # define ALIGNMENT 4
1765 # define CPP_WORDSZ 64
1766 # define ALIGN_DOUBLE
1767 /* Requires 16 byte alignment for malloc */
1768 # define ALIGNMENT 8
1770 # define OS_TYPE "HPUX"
1771 extern int __data_start[];
1772 # define DATASTART ((ptr_t)(__data_start))
1773 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1774 /* to this. Note that the GC must be initialized before the */
1775 /* first putenv call. */
1776 extern char ** environ;
1777 # define STACKBOTTOM ((ptr_t)environ)
1778 # define HPUX_STACKBOTTOM
1779 # define DYNAMIC_LOADING
1780 # include <unistd.h>
1781 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1782 /* The following was empirically determined, and is probably */
1783 /* not very robust. */
1784 /* Note that the backing store base seems to be at a nice */
1785 /* address minus one page. */
1786 # define BACKING_STORE_DISPLACEMENT 0x1000000
1787 # define BACKING_STORE_ALIGNMENT 0x1000
1788 extern ptr_t GC_register_stackbottom;
1789 # define BACKING_STORE_BASE GC_register_stackbottom
1790 /* Known to be wrong for recent HP/UX versions!!! */
1793 # define CPP_WORDSZ 64
1794 # define ALIGN_DOUBLE
1795 /* Requires 16 byte alignment for malloc */
1796 # define ALIGNMENT 8
1797 # define OS_TYPE "LINUX"
1798 /* The following works on NUE and older kernels: */
1799 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1800 /* This does not work on NUE: */
1801 # define LINUX_STACKBOTTOM
1802 /* We also need the base address of the register stack */
1803 /* backing store. This is computed in */
1804 /* GC_linux_register_stack_base based on the following */
1806 # define BACKING_STORE_ALIGNMENT 0x100000
1807 # define BACKING_STORE_DISPLACEMENT 0x80000000
1808 extern ptr_t GC_register_stackbottom;
1809 # define BACKING_STORE_BASE GC_register_stackbottom
1810 # define SEARCH_FOR_DATA_START
1812 # define DYNAMIC_LOADING
1814 /* In the Intel compiler environment, we seem to end up with */
1815 /* statically linked executables and an undefined reference */
1818 # define MPROTECT_VDB
1819 /* Requires Linux 2.3.47 or later. */
1821 # define DATAEND (_end)
1823 # ifndef __INTEL_COMPILER
1824 # define PREFETCH(x) \
1825 __asm__ (" lfetch [%0]": : "r"(x))
1826 # define PREFETCH_FOR_WRITE(x) \
1827 __asm__ (" lfetch.excl [%0]": : "r"(x))
1828 # define CLEAR_DOUBLE(x) \
1829 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1831 # include <ia64intrin.h>
1832 # define PREFETCH(x) \
1833 __lfetch(__lfhint_none, (x))
1834 # define PREFETCH_FOR_WRITE(x) \
1835 __lfetch(__lfhint_nta, (x))
1836 # define CLEAR_DOUBLE(x) \
1837 __stf_spill((void *)(x), 0)
1838 # endif // __INTEL_COMPILER
1842 /* FIXME: This is a very partial guess. There is no port, yet. */
1843 # define OS_TYPE "MSWIN32"
1844 /* STACKBOTTOM and DATASTART are handled specially in */
1846 # define DATAEND /* not needed */
1847 # if defined(_WIN64)
1848 # define CPP_WORDSZ 64
1850 # define CPP_WORDSZ 32 /* Is this possible? */
1852 # define ALIGNMENT 8
1857 # define MACH_TYPE "M88K"
1858 # define ALIGNMENT 4
1859 # define ALIGN_DOUBLE
1862 # define OS_TYPE "CX_UX"
1863 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1866 # define OS_TYPE "DGUX"
1867 extern ptr_t GC_SysVGetDataStart();
1868 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1870 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1874 /* If this still works, and if anyone cares, this should probably */
1875 /* be moved to the S390 category. */
1876 # define MACH_TYPE "S370"
1877 # define ALIGNMENT 4 /* Required by hardware */
1878 # define USE_GENERIC_PUSH_REGS
1880 # define OS_TYPE "UTS4"
1882 extern int _etext[];
1884 extern ptr_t GC_SysVGetDataStart();
1885 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1886 # define DATAEND (_end)
1892 # define MACH_TYPE "S390"
1893 # define USE_GENERIC_PUSH_REGS
1895 # define ALIGNMENT 4
1896 # define CPP_WORDSZ 32
1898 # define ALIGNMENT 8
1899 # define CPP_WORDSZ 64
1902 # define HBLKSIZE 4096
1905 # define OS_TYPE "LINUX"
1906 # define LINUX_STACKBOTTOM
1907 # define DYNAMIC_LOADING
1908 extern int __data_start[];
1909 # define DATASTART ((ptr_t)(__data_start))
1911 # define DATAEND (_end)
1912 # define CACHE_LINE_SIZE 256
1913 # define GETPAGESIZE() 4096
1918 # define ALIGNMENT 4
1919 extern int _etext[];
1920 # define DATASTART ((ptr_t)(_etext))
1925 # define CPP_WORDSZ 32
1926 # define MACH_TYPE "ARM32"
1927 # define ALIGNMENT 4
1929 # define OS_TYPE "NETBSD"
1932 # define DATASTART GC_data_start
1933 # define DYNAMIC_LOADING
1935 extern char etext[];
1936 # define DATASTART ((ptr_t)(etext))
1938 # define USE_GENERIC_PUSH_REGS
1941 # define OS_TYPE "LINUX"
1942 # define LINUX_STACKBOTTOM
1944 # define STACK_GRAN 0x10000000
1945 # define USE_GENERIC_PUSH_REGS
1947 # define DYNAMIC_LOADING
1948 # include <features.h>
1949 # if defined(__GLIBC__) && __GLIBC__ >= 2
1950 # define SEARCH_FOR_DATA_START
1951 # elif defined(PLATFORM_ANDROID)
1952 # define SEARCH_FOR_DATA_START
1954 extern char **__environ;
1955 # define DATASTART ((ptr_t)(&__environ))
1956 /* hideous kludge: __environ is the first */
1957 /* word in crt0.o, and delimits the start */
1958 /* of the data segment, no matter which */
1959 /* ld options were passed through. */
1960 /* We could use _etext instead, but that */
1961 /* would include .rodata, which may */
1962 /* contain large read-only data tables */
1963 /* that we'd rather not scan. */
1966 # define DATAEND (_end)
1969 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1973 # define OS_TYPE "MSWINCE"
1974 # define DATAEND /* not needed */
1977 # define OS_TYPE "DARWIN"
1978 # define DATASTART ((ptr_t) get_etext())
1979 # define DATAEND ((ptr_t) get_end())
1980 # define STACKBOTTOM ((ptr_t) 0x30000000)
1982 # define USE_MMAP_ANON
1986 /* __data_start is usually defined in the target linker script. */
1987 extern int __data_start[];
1988 # define DATASTART (ptr_t)(__data_start)
1989 # define USE_GENERIC_PUSH_REGS
1990 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1991 extern void *__stack_base__;
1992 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1997 # define MACH_TYPE "CRIS"
1998 # define CPP_WORDSZ 32
1999 # define ALIGNMENT 1
2000 # define OS_TYPE "LINUX"
2001 # define DYNAMIC_LOADING
2002 # define LINUX_STACKBOTTOM
2003 # define USE_GENERIC_PUSH_REGS
2004 # define SEARCH_FOR_DATA_START
2006 # define DATAEND (_end)
2010 # define MACH_TYPE "SH"
2011 # define ALIGNMENT 4
2013 # define OS_TYPE "MSWINCE"
2014 # define DATAEND /* not needed */
2017 # define OS_TYPE "LINUX"
2018 # define LINUX_STACKBOTTOM
2019 # define USE_GENERIC_PUSH_REGS
2020 # define DYNAMIC_LOADING
2021 # define SEARCH_FOR_DATA_START
2023 # define DATAEND (_end)
2026 # define OS_TYPE "NETBSD"
2028 # define DATASTART GC_data_start
2029 # define USE_GENERIC_PUSH_REGS
2030 # define DYNAMIC_LOADING
2035 # define MACH_TYPE "SH4"
2036 # define OS_TYPE "MSWINCE"
2037 # define ALIGNMENT 4
2038 # define DATAEND /* not needed */
2042 # define CPP_WORDSZ 32
2043 # define MACH_TYPE "M32R"
2044 # define ALIGNMENT 4
2046 # define OS_TYPE "LINUX"
2047 # define LINUX_STACKBOTTOM
2049 # define STACK_GRAN 0x10000000
2050 # define USE_GENERIC_PUSH_REGS
2051 # define DYNAMIC_LOADING
2052 # define SEARCH_FOR_DATA_START
2054 # define DATAEND (_end)
2059 # define MACH_TYPE "X86_64"
2060 # define ALIGNMENT 8
2061 # define CPP_WORDSZ 64
2063 # define HBLKSIZE 4096
2065 # define CACHE_LINE_SIZE 64
2066 # define USE_GENERIC_PUSH_REGS
2068 # define OS_TYPE "LINUX"
2069 # define LINUX_STACKBOTTOM
2071 # define FALLBACK_TO_MMAP
2073 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
2074 # define MPROTECT_VDB
2076 /* We seem to get random errors in incremental mode, */
2077 /* possibly because Linux threads is itself a malloc client */
2078 /* and can't deal with the signals. */
2081 # define DYNAMIC_LOADING
2082 # ifdef UNDEFINED /* includes ro data */
2083 extern int _etext[];
2084 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
2086 # include <features.h>
2087 # define SEARCH_FOR_DATA_START
2089 # define DATAEND (_end)
2092 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2094 # if defined(__GNUC__) && __GNUC >= 3
2095 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2096 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2100 # define OS_TYPE "DARWIN"
2101 # define DARWIN_DONT_PARSE_STACK
2102 # define DYNAMIC_LOADING
2103 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
2104 These aren't used when dyld support is enabled (it is by default) */
2105 # define DATASTART ((ptr_t) get_etext())
2106 # define DATAEND ((ptr_t) get_end())
2107 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
2111 # define USE_MMAP_ANON
2112 # ifdef GC_DARWIN_THREADS
2113 # define MPROTECT_VDB
2115 # include <unistd.h>
2116 # define GETPAGESIZE() getpagesize()
2117 /* There seems to be some issues with trylock hanging on darwin. This
2118 should be looked into some more */
2121 # define OS_TYPE "FREEBSD"
2122 # ifndef GC_FREEBSD_THREADS
2123 # define MPROTECT_VDB
2125 # define SIG_SUSPEND SIGTSTP
2126 # define SIG_THR_RESTART SIGCONT
2127 # define NEED_FIND_LIMIT
2128 # define FREEBSD_STACKBOTTOM
2130 # define DYNAMIC_LOADING
2132 extern char etext[];
2133 extern char * GC_FreeBSDGetDataStart();
2134 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2137 # define OS_TYPE "NETBSD"
2139 # define DYNAMIC_LOADING
2142 extern char etext[];
2143 # define SEARCH_FOR_DATA_START
2146 # define OS_TYPE "OPENBSD"
2147 # define ELF_CLASS ELFCLASS64
2148 # ifdef GC_OPENBSD_THREADS
2149 # define UTHREAD_SP_OFFSET 400
2151 # include <sys/param.h>
2152 # include <uvm/uvm_extern.h>
2153 # define STACKBOTTOM USRSTACK
2155 extern int __data_start[];
2156 # define DATASTART ((ptr_t)(__data_start))
2158 # define DATAEND ((ptr_t)(&_end))
2159 # define DYNAMIC_LOADING
2163 #if defined(LINUX) && defined(USE_MMAP)
2164 /* The kernel may do a somewhat better job merging mappings etc. */
2165 /* with anonymous mappings. */
2166 # define USE_MMAP_ANON
2169 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2170 /* Rld appears to allocate some memory with its own allocator, and */
2171 /* some through malloc, which might be redirected. To make this */
2172 /* work with collectable memory, we have to scan memory allocated */
2173 /* by rld's internal malloc. */
2174 # define USE_PROC_FOR_LIBRARIES
2177 # ifndef STACK_GROWS_UP
2178 # define STACK_GROWS_DOWN
2182 # define CPP_WORDSZ 32
2191 # define DATAEND (end)
2194 # if defined(SVR4) && !defined(GETPAGESIZE)
2195 # include <unistd.h>
2196 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2199 # ifndef GETPAGESIZE
2200 # if defined(SUNOS5) || defined(IRIX5)
2201 # include <unistd.h>
2203 # define GETPAGESIZE() getpagesize()
2206 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2207 /* OS has SVR4 generic features. Probably others also qualify. */
2211 # if defined(SUNOS5) || defined(DRSNX)
2212 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2215 /* OS has SUNOS5 style signal handlers. */
2223 # if defined(FREEBSD) && (__FreeBSD__ >= 4)
2227 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2228 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2229 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2230 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2231 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2234 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2239 # undef DYNAMIC_LOADING
2244 # undef MPROTECT_VDB
2249 /* Postponed for now. */
2251 # undef MPROTECT_VDB
2254 # ifdef SMALL_CONFIG
2255 /* Presumably not worth the space it takes. */
2257 # undef MPROTECT_VDB
2261 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2264 # ifdef PARALLEL_MARK
2265 # undef MPROTECT_VDB /* For now. */
2268 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2269 # define DEFAULT_VDB
2273 # define PREFETCH(x)
2274 # define NO_PREFETCH
2277 # ifndef PREFETCH_FOR_WRITE
2278 # define PREFETCH_FOR_WRITE(x)
2279 # define NO_PREFETCH_FOR_WRITE
2282 # ifndef CACHE_LINE_SIZE
2283 # define CACHE_LINE_SIZE 32 /* Wild guess */
2287 # define REGISTER_LIBRARIES_EARLY
2288 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2289 /* lock. This isn't safe after the world has stopped. So we must */
2290 /* call GC_register_dynamic_libraries before stopping the world. */
2291 /* For performance reasons, this may be beneficial on other */
2292 /* platforms as well, though it should be avoided in win32. */
2295 # if defined(SEARCH_FOR_DATA_START)
2296 extern ptr_t GC_data_start;
2297 # define DATASTART GC_data_start
2300 # ifndef CLEAR_DOUBLE
2301 # define CLEAR_DOUBLE(x) \
2302 ((word*)x)[0] = 0; \
2304 # endif /* CLEAR_DOUBLE */
2306 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2307 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2308 # define GC_SOLARIS_THREADS
2311 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2312 --> inconsistent configuration
2314 # if defined(GC_LINUX_THREADS) && !(defined(LINUX) || defined(NACL))
2315 --> inconsistent configuration
2317 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2318 --> inconsistent configuration
2320 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2321 --> inconsistent configuration
2323 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2324 --> inconsistent configuration
2326 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2327 --> inconsistent configuration
2330 # if defined(PCR) || defined(SRC_M3) || \
2331 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2332 defined(GC_PTHREADS) || defined(SN_TARGET_PS3)
2336 # if defined(HP_PA) || defined(M88K) \
2337 || defined(POWERPC) && !defined(DARWIN) \
2338 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2339 || (defined(I386) && defined(__LCC__))
2340 /* Use setjmp based hack to mark from callee-save registers. */
2341 /* The define should move to the individual platform */
2343 # define USE_GENERIC_PUSH_REGS
2346 # if defined(MSWINCE)
2351 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2352 /* include assembly code to do it well. */
2355 /* Can we save call chain in objects for debugging? */
2356 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2357 /* frame) to reasonable values for the platform. */
2358 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2359 /* at build time, though we feel free to adjust it slightly. */
2360 /* Define NEED_CALLINFO if we either save the call stack or */
2361 /* GC_ADD_CALLER is defined. */
2362 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2365 # define CAN_SAVE_CALL_ARGS
2367 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
2368 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2369 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2370 # define CAN_SAVE_CALL_ARGS
2373 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2374 && defined(GC_CAN_SAVE_CALL_STACKS)
2375 # define SAVE_CALL_CHAIN
2377 # ifdef SAVE_CALL_CHAIN
2378 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2379 # define NARGS SAVE_CALL_NARGS
2381 # define NARGS 0 /* Number of arguments to save for each call. */
2384 # ifdef SAVE_CALL_CHAIN
2385 # ifndef SAVE_CALL_COUNT
2386 # define NFRAMES 6 /* Number of frames to save. Even for */
2387 /* alignment reasons. */
2389 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2391 # define NEED_CALLINFO
2392 # endif /* SAVE_CALL_CHAIN */
2393 # ifdef GC_ADD_CALLER
2396 # define NEED_CALLINFO
2399 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2400 # define DBG_HDRS_ALL
2403 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2404 # define POINTER_SHIFT 0
2407 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2408 # define POINTER_MASK ((GC_word)(-1))
2411 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2412 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2415 # if defined(FIXUP_POINTER)
2416 # define NEED_FIXUP_POINTER 1
2418 # define NEED_FIXUP_POINTER 0
2419 # define FIXUP_POINTER(p)
2423 /* This relies on some type definitions from gc_priv.h, from */
2424 /* where it's normally included. */
2426 /* How to get heap memory from the OS: */
2427 /* Note that sbrk()-like allocation is preferred, since it */
2428 /* usually makes it possible to merge consecutively allocated */
2429 /* chunks. It also avoids unintented recursion with */
2430 /* -DREDIRECT_MALLOC. */
2431 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2432 /* 0 is taken to mean failure. */
2433 /* In the case os USE_MMAP, the argument must also be a */
2434 /* physical page size. */
2435 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2436 /* though we should perhaps take advantage of the case in which */
2438 struct hblk; /* See gc_priv.h. */
2440 char * real_malloc();
2441 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2445 void * os2_alloc(size_t bytes);
2446 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2450 # if defined(NEXT) || defined(DOS4GW) || \
2451 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2452 (defined(SUNOS5) && !defined(USE_MMAP))
2453 # define GET_MEM(bytes) HBLKPTR((size_t) \
2454 calloc(1, (size_t)bytes + GC_page_size) \
2458 extern ptr_t GC_win32_get_mem();
2459 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2462 # if defined(USE_TEMPORARY_MEMORY)
2463 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2464 Boolean clearMemory);
2465 # define GET_MEM(bytes) HBLKPTR( \
2466 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2469 # define GET_MEM(bytes) HBLKPTR( \
2470 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2474 extern ptr_t GC_wince_get_mem();
2475 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2477 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2478 extern void *GC_amiga_get_mem(size_t size);
2479 # define GET_MEM(bytes) HBLKPTR((size_t) \
2480 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2483 # if defined(SN_TARGET_PS3)
2484 extern void *ps3_get_mem (size_t size);
2485 # define GET_MEM(bytes) (struct hblk*) ps3_get_mem (bytes)
2487 extern ptr_t GC_unix_get_mem(word size);
2488 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2498 #endif /* GC_PRIVATE_H */
2500 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2501 /* IBMs xlc compiler doesn't appear to follow the convention of */
2502 /* defining __STDC__ to be zero in extended mode. */
2506 # endif /* GCCONFIG_H */