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()))
330 # define USE_MMAP_ANON
331 # define USE_ASM_PUSH_REGS
332 /* This is potentially buggy. It needs more testing. See the comments in
333 os_dep.c. It relies on threads to track writes. */
334 # ifdef GC_DARWIN_THREADS
335 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
338 # define GETPAGESIZE() getpagesize()
339 # elif defined(__arm__)
341 # define mach_type_known
342 # define DARWIN_DONT_PARSE_STACK
343 # define GC_DONT_REGISTER_MAIN_STATIC_DATA
344 # elif defined(__x86_64)
346 # define mach_type_known
349 # if defined(NeXT) && defined(mc68000)
352 # define mach_type_known
354 # if defined(NeXT) && (defined(i386) || defined(__i386__))
357 # define mach_type_known
359 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
362 # define mach_type_known
364 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
366 # define mach_type_known
368 # if defined(FREEBSD) && defined(__x86_64__)
370 # define mach_type_known
372 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
374 # define mach_type_known
376 # if defined(__NetBSD__) && defined(__x86_64__)
378 # define mach_type_known
380 # if defined(FREEBSD) && defined(__sparc__)
382 # define mach_type_known
384 # if defined(bsdi) && (defined(i386) || defined(__i386__))
387 # define mach_type_known
389 # if !defined(mach_type_known) && defined(__386BSD__)
392 # define mach_type_known
394 # if defined(_CX_UX) && defined(_M88K)
397 # define mach_type_known
399 # if defined(DGUX) && defined(m88k)
402 # define mach_type_known
404 # if defined(_WIN32_WCE)
405 /* SH3, SH4, MIPS already defined for corresponding architectures */
406 # if defined(SH3) || defined(SH4)
416 # define mach_type_known
418 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
419 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
420 # if defined(__LP64__) || defined(_WIN64)
425 # define MSWIN32 /* or Win64 */
426 # define mach_type_known
428 # if defined(_MSC_VER) && defined(_M_IA64)
430 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
431 /* variants as a differnt platform. */
434 # if defined(__DJGPP__)
437 # define DJGPP /* MSDOS running the DJGPP port of GCC */
439 # define mach_type_known
441 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
444 # define mach_type_known
446 # if defined(__MINGW32__)
449 # define mach_type_known
451 # if defined(__BORLANDC__)
454 # define mach_type_known
456 # if defined(_UTS) && !defined(mach_type_known)
459 # define mach_type_known
463 # define mach_type_known
465 # if defined(__embedded__) && defined(PPC)
468 # define mach_type_known
471 # if defined(__WATCOMC__) && defined(__386__)
473 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
474 # if defined(__OS2__)
477 # if defined(__WINDOWS_386__) || defined(__NT__)
484 # define mach_type_known
486 # if defined(__s390__) && defined(LINUX)
488 # define mach_type_known
490 # if defined(__GNU__)
491 # if defined(__i386__)
492 /* The Debian Hurd running on generic PC */
495 # define mach_type_known
499 /* Feel free to add more clauses here */
501 /* Or manually define the machine type here. A machine type is */
502 /* characterized by the architecture. Some */
503 /* machine types are further subdivided by OS. */
504 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
505 /* Note that SGI IRIX is treated identically to RISCOS. */
506 /* SYSV on an M68K actually means A/UX. */
507 /* The distinction in these cases is usually the stack starting address */
508 # ifndef mach_type_known
509 --> unknown machine type
511 /* Mapping is: M68K ==> Motorola 680X0 */
512 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
513 /* MACOS and AMIGA variants) */
514 /* I386 ==> Intel 386 */
515 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
516 /* FREEBSD, THREE86BSD, MSWIN32, */
517 /* BSDI,SUNOS5, NEXT, other variants) */
518 /* NS32K ==> Encore Multimax */
519 /* MIPS ==> R2000 or R3000 */
520 /* (RISCOS, ULTRIX variants) */
521 /* VAX ==> DEC VAX */
522 /* (BSD, ULTRIX variants) */
523 /* RS6000 ==> IBM RS/6000 AIX3.X */
524 /* RT ==> IBM PC/RT */
525 /* HP_PA ==> HP9000/700 & /800 */
527 /* SPARC ==> SPARC v7/v8/v9 */
528 /* (SUNOS4, SUNOS5, LINUX, */
529 /* DRSNX variants) */
530 /* ALPHA ==> DEC Alpha */
531 /* (OSF1 and LINUX variants) */
532 /* M88K ==> Motorola 88XX0 */
533 /* (CX_UX and DGUX) */
534 /* S370 ==> 370-like machine */
535 /* running Amdahl UTS4 */
536 /* S390 ==> 390-like machine */
538 /* ARM32 ==> Intel StrongARM */
539 /* IA64 ==> Intel IPF */
541 /* (LINUX and HPUX) */
542 /* SH ==> Hitachi SuperH */
543 /* (LINUX & MSWINCE) */
544 /* X86_64 ==> AMD x86-64 */
545 /* POWERPC ==> IBM/Apple PowerPC */
546 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
547 /* LINUX, NETBSD, NOSYS variants) */
548 /* Handles 32 and 64-bit variants. */
549 /* AIX should be handled here, but */
550 /* that's called an RS6000. */
551 /* CRIS ==> Axis Etrax */
552 /* M32R ==> Renesas M32R */
556 * For each architecture and OS, the following need to be defined:
558 * CPP_WORDSZ is a simple integer constant representing the word size.
559 * in bits. We assume byte addressibility, where a byte has 8 bits.
560 * We also assume CPP_WORDSZ is either 32 or 64.
561 * (We care about the length of pointers, not hardware
562 * bus widths. Thus a 64 bit processor with a C compiler that uses
563 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
565 * MACH_TYPE is a string representation of the machine type.
566 * OS_TYPE is analogous for the OS.
568 * ALIGNMENT is the largest N, such that
569 * all pointer are guaranteed to be aligned on N byte boundaries.
570 * defining it to be 1 will always work, but perform poorly.
572 * DATASTART is the beginning of the data segment.
573 * On some platforms SEARCH_FOR_DATA_START is defined.
574 * SEARCH_FOR_DATASTART will cause GC_data_start to
575 * be set to an address determined by accessing data backwards from _end
576 * until an unmapped page is found. DATASTART will be defined to be
578 * On UNIX-like systems, the collector will scan the area between DATASTART
579 * and DATAEND for root pointers.
581 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
582 * RTH suggests gaining access to linker script synth'd values with
583 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
584 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
585 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
586 * without any special options.
588 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
591 * STACKBOTTOM is the cool end of the stack, which is usually the
592 * highest address in the stack.
593 * Under PCR or OS/2, we have other ways of finding thread stacks.
594 * For each machine, the following should:
595 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
596 * 2) define exactly one of
597 * STACKBOTTOM (should be defined to be an expression)
601 * If STACKBOTTOM is defined, then it's value will be used directly as the
602 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
603 * with a method appropriate for most Linux systems. Currently we look
604 * first for __libc_stack_end, and if that fails read it from /proc.
605 * If either of the last two macros are defined, then STACKBOTTOM is computed
606 * during collector startup using one of the following two heuristics:
607 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
608 * the next multiple of STACK_GRAN.
609 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
610 * in small steps (decrement if STACK_GROWS_UP), and read the value
611 * at each location. Remember the value when the first
612 * Segmentation violation or Bus error is signalled. Round that
613 * to the nearest plausible page boundary, and use that instead
616 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
617 * the value of environ is a pointer that can serve as STACKBOTTOM.
618 * I expect that HEURISTIC2 can be replaced by this approach, which
619 * interferes far less with debugging. However it has the disadvantage
620 * that it's confused by a putenv call before the collector is initialized.
621 * This could be dealt with by intercepting putenv ...
623 * If no expression for STACKBOTTOM can be found, and neither of the above
624 * heuristics are usable, the collector can still be used with all of the above
625 * undefined, provided one of the following is done:
626 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
627 * without reference to STACKBOTTOM. This is appropriate for use in
628 * conjunction with thread packages, since there will be multiple stacks.
629 * (Allocating thread stacks in the heap, and treating them as ordinary
630 * heap data objects is also possible as a last resort. However, this is
631 * likely to introduce significant amounts of excess storage retention
632 * unless the dead parts of the thread stacks are periodically cleared.)
633 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
634 * If the author of the client code controls the main program, this is
635 * easily accomplished by introducing a new main program, setting
636 * GC_stackbottom to the address of a local variable, and then calling
637 * the original main program. The new main program would read something
640 * # include "gc_private.h"
642 * main(argc, argv, envp)
644 * char **argv, **envp;
648 * GC_stackbottom = (ptr_t)(&dummy);
649 * return(real_main(argc, argv, envp));
653 * Each architecture may also define the style of virtual dirty bit
654 * implementation to be used:
655 * MPROTECT_VDB: Write protect the heap and catch faults.
656 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
658 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
659 * defined GC_register_dynamic_libraries() for the architecture.
661 * An architecture may define PREFETCH(x) to preload the cache with *x.
662 * This defaults to a no-op.
664 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
666 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
667 * clear the two words at GC_malloc-aligned address x. By default,
668 * word stores of 0 are used instead.
670 * HEAP_START may be defined as the initial address hint for mmap-based
674 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
675 * to push the relevant registers onto the stack. This generally makes
676 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
678 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
679 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
680 && !defined(__INTEL_COMPILER) \
681 && !defined(__PATHCC__)
682 # define HAVE_BUILTIN_UNWIND_INIT
685 # define STACK_GRAN 0x1000000
687 # define MACH_TYPE "M68K"
690 # define OS_TYPE "OPENBSD"
693 # define DATASTART GC_data_start
694 # define DYNAMIC_LOADING
697 # define DATASTART ((ptr_t)(etext))
699 # define USE_GENERIC_PUSH_REGS
702 # define OS_TYPE "NETBSD"
705 # define DATASTART GC_data_start
706 # define DYNAMIC_LOADING
709 # define DATASTART ((ptr_t)(etext))
711 # define USE_GENERIC_PUSH_REGS
714 # define OS_TYPE "LINUX"
715 # define STACKBOTTOM ((ptr_t)0xf0000000)
716 # define USE_GENERIC_PUSH_REGS
717 /* We never got around to the assembly version. */
718 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
720 # define DYNAMIC_LOADING
721 # include <features.h>
722 # if defined(__GLIBC__)&& __GLIBC__>=2
723 # define SEARCH_FOR_DATA_START
725 # if defined(PLATFORM_ANDROID)
726 # define __environ environ
728 extern char **__environ;
729 # define DATASTART ((ptr_t)(&__environ))
730 /* hideous kludge: __environ is the first */
731 /* word in crt0.o, and delimits the start */
732 /* of the data segment, no matter which */
733 /* ld options were passed through. */
734 /* We could use _etext instead, but that */
735 /* would include .rodata, which may */
736 /* contain large read-only data tables */
737 /* that we'd rather not scan. */
738 # endif /* !GLIBC2 */
740 # define DATAEND (_end)
743 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
747 # define OS_TYPE "SUNOS4"
749 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
750 # define HEURISTIC1 /* differs */
751 # define DYNAMIC_LOADING
754 # define OS_TYPE "HP"
756 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
757 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
758 /* empirically determined. seems to work. */
760 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
763 # define OS_TYPE "SYSV"
765 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
767 +((word)etext & 0x1fff))
768 /* This only works for shared-text binaries with magic number 0413.
769 The other sorts of SysV binaries put the data at the end of the text,
770 in which case the default of etext would work. Unfortunately,
771 handling both would require having the magic-number available.
774 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
775 /* The stack starts at the top of memory, but */
776 /* 0x0 cannot be used as setjump_test complains */
777 /* that the stack direction is incorrect. Two */
778 /* bytes down from 0x0 should be safe enough. */
780 # include <sys/mmu.h>
781 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
784 # define OS_TYPE "AMIGA"
785 /* STACKBOTTOM and DATASTART handled specially */
787 # define DATAEND /* not needed */
788 # define GETPAGESIZE() 4096
794 # define OS_TYPE "MACOS"
795 /* see os_dep.c for details of global data segments. */
796 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
797 # define DATAEND /* not needed */
798 # define GETPAGESIZE() 4096
801 # define OS_TYPE "NEXT"
802 # define DATASTART ((ptr_t) get_etext())
803 # define STACKBOTTOM ((ptr_t) 0x4000000)
804 # define DATAEND /* not needed */
808 # if defined(POWERPC)
809 # define MACH_TYPE "POWERPC"
811 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
815 # define OS_TYPE "MACOS"
816 /* see os_dep.c for details of global data segments. */
817 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
818 # define DATAEND /* not needed */
822 # if defined(__powerpc64__)
824 # define CPP_WORDSZ 64
826 # define HBLKSIZE 4096
831 # define OS_TYPE "LINUX"
832 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
833 /* executable on a 64 bit kernel. */
834 # define LINUX_STACKBOTTOM
835 # define DYNAMIC_LOADING
836 # define SEARCH_FOR_DATA_START
838 # define DATAEND (_end)
843 # define CPP_WORDSZ 64
847 # define OS_TYPE "DARWIN"
848 # define DYNAMIC_LOADING
849 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
850 These aren't used when dyld support is enabled (it is by default) */
851 # define DATASTART ((ptr_t) get_etext())
852 # define DATAEND ((ptr_t) get_end())
853 # define STACKBOTTOM ((ptr_t) 0xc0000000)
855 # define USE_MMAP_ANON
856 # define USE_ASM_PUSH_REGS
857 /* This is potentially buggy. It needs more testing. See the comments in
858 os_dep.c. It relies on threads to track writes. */
859 # ifdef GC_DARWIN_THREADS
860 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
863 # define GETPAGESIZE() getpagesize()
864 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
865 /* The performance impact of prefetches is untested */
866 # define PREFETCH(x) \
867 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
868 # define PREFETCH_FOR_WRITE(x) \
869 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
871 /* There seems to be some issues with trylock hanging on darwin. This
872 should be looked into some more */
873 # define NO_PTHREAD_TRYLOCK
877 # define OS_TYPE "FREEBSD"
878 # ifndef GC_FREEBSD_THREADS
879 # define MPROTECT_VDB
881 # define SIG_SUSPEND SIGUSR1
882 # define SIG_THR_RESTART SIGUSR2
883 # define FREEBSD_STACKBOTTOM
885 # define DYNAMIC_LOADING
888 extern char * GC_FreeBSDGetDataStart();
889 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
893 # define OS_TYPE "NETBSD"
896 # define DATASTART GC_data_start
897 # define DYNAMIC_LOADING
899 # ifdef SN_TARGET_PS3
901 # define CPP_WORDSZ 32
904 // extern int _dso_handle[];
905 extern int __bss_start;
907 # define DATAEND (_end)
908 # define DATASTART (__bss_start)
909 # define STACKBOTTOM ((ptr_t) ps3_get_stack_bottom ())
910 # define USE_GENERIC_PUSHREGS
915 # define OS_TYPE "NOSYS"
916 extern void __end[], __dso_handle[];
917 # define DATASTART (__dso_handle) /* OK, that's ugly. */
918 # define DATAEND (__end)
919 /* Stack starts at 0xE0000000 for the simulator. */
921 # define STACK_GRAN 0x10000000
927 # define MACH_TYPE "VAX"
928 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
930 # define DATASTART ((ptr_t)(etext))
932 # define OS_TYPE "BSD"
934 /* HEURISTIC2 may be OK, but it's hard to test. */
937 # define OS_TYPE "ULTRIX"
938 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
943 # define MACH_TYPE "RT"
945 # define DATASTART ((ptr_t) 0x10000000)
946 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
950 # define MACH_TYPE "SPARC"
951 # if defined(__arch64__) || defined(__sparcv9)
953 # define CPP_WORDSZ 64
954 # define ELF_CLASS ELFCLASS64
956 # define ALIGNMENT 4 /* Required by hardware */
957 # define CPP_WORDSZ 32
959 # define ALIGN_DOUBLE
960 # ifdef _FILE_OFFSET_BITS
961 # undef _FILE_OFFSET_BITS /* libelf.h & procfs.h doesn't compile with large file support */
962 # define _FILE_OFFSET_BITS 32
965 # define OS_TYPE "SUNOS5"
968 extern ptr_t GC_SysVGetDataStart();
969 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
970 # define DATAEND (_end)
971 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
973 /* Otherwise we now use calloc. Mmap may result in the */
974 /* heap interleaved with thread stacks, which can result in */
975 /* excessive blacklisting. Sbrk is unusable since it */
976 /* doesn't interact correctly with the system malloc. */
979 # define HEAP_START (ptr_t)0x40000000
981 # define HEAP_START DATAEND
984 /* HEURISTIC1 reportedly no longer works under 2.7. */
985 /* HEURISTIC2 probably works, but this appears to be preferable. */
986 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
987 /* installations that's undefined. We work around this with a */
989 # include <sys/vmparam.h>
991 /* This should work everywhere, but doesn't. */
992 # define STACKBOTTOM USRSTACK
997 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
998 /* getpagesize() appeared to be missing from at least one */
999 /* Solaris 5.4 installation. Weird. */
1000 # define DYNAMIC_LOADING
1003 # define OS_TYPE "SUNOS4"
1004 /* [If you have a weak stomach, don't read this.] */
1005 /* We would like to use: */
1006 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
1007 /* This fails occasionally, due to an ancient, but very */
1008 /* persistent ld bug. etext is set 32 bytes too high. */
1009 /* We instead read the text segment size from the a.out */
1010 /* header, which happens to be mapped into our address space */
1011 /* at the start of the text segment. The detective work here */
1012 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
1013 /* Serpette of INRIA. */
1014 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
1015 # define TEXTSTART 0x2000
1016 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
1017 # define MPROTECT_VDB
1019 # define DYNAMIC_LOADING
1022 # define OS_TYPE "DRSNX"
1023 extern ptr_t GC_SysVGetDataStart();
1025 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1026 # define MPROTECT_VDB
1027 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
1028 # define DYNAMIC_LOADING
1031 # define OS_TYPE "LINUX"
1033 # define DYNAMIC_LOADING
1035 Linux Sparc/a.out not supported
1038 # include <features.h>
1039 # if defined(__GLIBC__) && __GLIBC__ >= 2
1040 # define SEARCH_FOR_DATA_START
1042 extern char **__environ;
1043 # define DATASTART ((ptr_t)(&__environ))
1044 /* hideous kludge: __environ is the first */
1045 /* word in crt0.o, and delimits the start */
1046 /* of the data segment, no matter which */
1047 /* ld options were passed through. */
1048 /* We could use _etext instead, but that */
1049 /* would include .rodata, which may */
1050 /* contain large read-only data tables */
1051 /* that we'd rather not scan. */
1054 # define DATAEND (_end)
1055 # define LINUX_STACKBOTTOM
1058 # define OS_TYPE "OPENBSD"
1059 # define STACKBOTTOM ((ptr_t) 0xf8000000)
1061 # define DATASTART ((ptr_t)(etext))
1064 # define OS_TYPE "NETBSD"
1067 # define DATASTART GC_data_start
1068 # define DYNAMIC_LOADING
1070 extern char etext[];
1071 # define DATASTART ((ptr_t)(etext))
1075 # define OS_TYPE "FREEBSD"
1076 # define SIG_SUSPEND SIGUSR1
1077 # define SIG_THR_RESTART SIGUSR2
1078 # define FREEBSD_STACKBOTTOM
1080 # define DYNAMIC_LOADING
1082 extern char etext[];
1083 extern char edata[];
1085 # define NEED_FIND_LIMIT
1086 # define DATASTART ((ptr_t)(&etext))
1087 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1088 # define DATASTART2 ((ptr_t)(&edata))
1089 # define DATAEND2 ((ptr_t)(&end))
1094 # if defined( NACL )
1095 # define MACH_TYPE "NACL"
1096 # define CPP_WORDSZ 32
1097 # define ALIGNMENT 4
1099 # define MACH_TYPE "I386"
1100 # if defined(__LP64__) || defined(_WIN64)
1101 # define CPP_WORDSZ 64
1102 # define ALIGNMENT 8
1104 # define CPP_WORDSZ 32
1105 # define ALIGNMENT 4
1107 /* Appears to hold for all "32 bit" compilers */
1108 /* except Borland. The -a4 option fixes */
1110 /* Ivan Demakov: For Watcom the option is -zp4. */
1112 # ifndef SMALL_CONFIG
1113 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1114 /* improvement on Pentiums. */
1116 # ifdef HAVE_BUILTIN_UNWIND_INIT
1117 # define USE_GENERIC_PUSH_REGS
1120 # define OS_TYPE "SEQUENT"
1122 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1123 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1126 # define OS_TYPE "BEOS"
1128 # define GETPAGESIZE() B_PAGE_SIZE
1130 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1133 # define OS_TYPE "SUNOS5"
1134 extern int _etext[], _end[];
1135 extern ptr_t GC_SysVGetDataStart();
1136 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1137 # define DATAEND (_end)
1138 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1139 /* but reportedly breaks under 2.8. It appears that the stack */
1140 /* base is a property of the executable, so this should not break */
1141 /* old executables. */
1142 /* HEURISTIC2 probably works, but this appears to be preferable. */
1143 # include <sys/vm.h>
1144 # define STACKBOTTOM USRSTACK
1145 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1146 /* It appears to be fixed in 2.8 and 2.9. */
1147 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1148 /* Reading of dirty bits doesn't seem to work even in solaris 10 */
1149 /*# define PROC_VDB */
1151 # define DYNAMIC_LOADING
1152 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1154 /* Otherwise we now use calloc. Mmap may result in the */
1155 /* heap interleaved with thread stacks, which can result in */
1156 /* excessive blacklisting. Sbrk is unusable since it */
1157 /* doesn't interact correctly with the system malloc. */
1160 # define HEAP_START (ptr_t)0x40000000
1162 # define HEAP_START DATAEND
1166 # define OS_TYPE "SCO"
1168 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1170 +((word)etext & 0xfff))
1171 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1174 # define OS_TYPE "SCO_ELF"
1176 # define DATASTART ((ptr_t)(etext))
1177 # define STACKBOTTOM ((ptr_t) 0x08048000)
1178 # define DYNAMIC_LOADING
1179 # define ELF_CLASS ELFCLASS32
1182 # define OS_TYPE "DGUX"
1183 extern int _etext, _end;
1184 extern ptr_t GC_SysVGetDataStart();
1185 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1186 # define DATAEND (&_end)
1187 # define STACK_GROWS_DOWN
1189 # include <unistd.h>
1190 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1191 # define DYNAMIC_LOADING
1194 # endif /* USE_MMAP */
1195 # define MAP_FAILED (void *) -1
1197 # define HEAP_START (ptr_t)0x40000000
1198 # else /* USE_MMAP */
1199 # define HEAP_START DATAEND
1200 # endif /* USE_MMAP */
1203 # define OS_TYPE "NACL"
1205 //# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1206 # define DATASTART ((ptr_t)0x10000000)
1208 # define DATAEND (_end)
1211 # endif /* STACK_GRAN */
1212 # define STACK_GRAN 0x10000
1220 # ifdef USE_MMAP_ANON
1221 # undef USE_MMAP_ANON
1223 # ifdef USE_MMAP_FIXED
1224 # undef USE_MMAP_FIXED
1226 # define GETPAGESIZE() 65536
1227 # define MAX_NACL_GC_THREADS 1024
1231 /* The Intel compiler doesn't like inline assembly */
1232 # define USE_GENERIC_PUSH_REGS
1234 # define OS_TYPE "LINUX"
1235 # define LINUX_STACKBOTTOM
1239 # define STACK_GRAN 0x10000000
1240 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1241 /* different kernel configurations. In particular, systems */
1242 /* with 2GB physical memory will usually move the user */
1243 /* address space limit, and hence initial SP to 0x80000000. */
1245 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1246 # define MPROTECT_VDB
1248 /* We seem to get random errors in incremental mode, */
1249 /* possibly because Linux threads is itself a malloc client */
1250 /* and can't deal with the signals. */
1252 # define HEAP_START (ptr_t)0x1000
1253 /* This encourages mmap to give us low addresses, */
1254 /* thus allowing the heap to grow to ~3GB */
1256 # define DYNAMIC_LOADING
1257 # ifdef UNDEFINED /* includes ro data */
1258 extern int _etext[];
1259 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1261 # include <features.h>
1262 # if defined(__GLIBC__) && __GLIBC__ >= 2
1263 # define SEARCH_FOR_DATA_START
1265 extern char **__environ;
1266 # define DATASTART ((ptr_t)(&__environ))
1267 /* hideous kludge: __environ is the first */
1268 /* word in crt0.o, and delimits the start */
1269 /* of the data segment, no matter which */
1270 /* ld options were passed through. */
1271 /* We could use _etext instead, but that */
1272 /* would include .rodata, which may */
1273 /* contain large read-only data tables */
1274 /* that we'd rather not scan. */
1277 # define DATAEND (_end)
1280 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1282 # ifdef USE_I686_PREFETCH
1283 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1284 /* for the next rtelease. */
1285 # define PREFETCH(x) \
1286 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1287 /* Empirically prefetcht0 is much more effective at reducing */
1288 /* cache miss stalls for the targetted load instructions. But it */
1289 /* seems to interfere enough with other cache traffic that the net */
1290 /* result is worse than prefetchnta. */
1292 /* Using prefetches for write seems to have a slight negative */
1293 /* impact on performance, at least for a PIII/500. */
1294 # define PREFETCH_FOR_WRITE(x) \
1295 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1298 # ifdef USE_3DNOW_PREFETCH
1299 # define PREFETCH(x) \
1300 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1301 # define PREFETCH_FOR_WRITE(x) \
1302 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1306 # define OS_TYPE "CYGWIN32"
1307 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1308 # define DATAEND ((ptr_t)GC_DATAEND)
1310 # define STACK_GRAN 0x10000
1314 # define OS_TYPE "OS2"
1315 /* STACKBOTTOM and DATASTART are handled specially in */
1316 /* os_dep.c. OS2 actually has the right */
1318 # define DATAEND /* not needed */
1319 # define USE_GENERIC_PUSH_REGS
1322 # define OS_TYPE "MSWIN32"
1323 /* STACKBOTTOM and DATASTART are handled specially in */
1325 # ifndef __WATCOMC__
1326 # define MPROTECT_VDB
1328 # define DATAEND /* not needed */
1331 # define OS_TYPE "MSWINCE"
1332 # define DATAEND /* not needed */
1335 # define OS_TYPE "DJGPP"
1336 # include "stubinfo.h"
1339 extern int __djgpp_stack_limit;
1340 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1341 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1343 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1344 /* This may not be right. */
1347 # define OS_TYPE "OPENBSD"
1348 # ifdef GC_OPENBSD_THREADS
1349 # define UTHREAD_SP_OFFSET 192
1351 # include <sys/param.h>
1352 # include <uvm/uvm_extern.h>
1353 # define STACKBOTTOM USRSTACK
1355 extern int __data_start[];
1356 # define DATASTART ((ptr_t)(__data_start))
1358 # define DATAEND ((ptr_t)(&_end))
1359 # define DYNAMIC_LOADING
1362 # define OS_TYPE "FREEBSD"
1363 # ifndef GC_FREEBSD_THREADS
1364 # define MPROTECT_VDB
1366 # define SIG_SUSPEND SIGTSTP
1367 # define SIG_THR_RESTART SIGCONT
1368 # define FREEBSD_STACKBOTTOM
1370 # define DYNAMIC_LOADING
1372 extern char etext[];
1373 extern char * GC_FreeBSDGetDataStart();
1374 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1377 # define OS_TYPE "NETBSD"
1379 # define DYNAMIC_LOADING
1383 # define OS_TYPE "THREE86BSD"
1386 # define OS_TYPE "BSDI"
1388 # if defined(OPENBSD) || defined(NETBSD) \
1389 || defined(THREE86BSD) || defined(BSDI)
1391 extern char etext[];
1392 # define DATASTART ((ptr_t)(etext))
1395 # define OS_TYPE "NEXT"
1396 # define DATASTART ((ptr_t) get_etext())
1397 # define STACKBOTTOM ((ptr_t)0xc0000000)
1398 # define DATAEND /* not needed */
1401 # define OS_TYPE "DOS4GW"
1402 extern long __nullarea;
1404 extern char *_STACKTOP;
1405 /* Depending on calling conventions Watcom C either precedes
1406 or does not precedes with undescore names of C-variables.
1407 Make sure startup code variables always have the same names. */
1408 #pragma aux __nullarea "*";
1409 #pragma aux _end "*";
1410 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1411 /* confused? me too. */
1412 # define DATASTART ((ptr_t) &__nullarea)
1413 # define DATAEND ((ptr_t) &_end)
1416 # define OS_TYPE "HURD"
1417 # define STACK_GROWS_DOWN
1419 extern int __data_start[];
1420 # define DATASTART ( (ptr_t) (__data_start))
1422 # define DATAEND ( (ptr_t) (_end))
1423 /* # define MPROTECT_VDB Not quite working yet? */
1424 # define DYNAMIC_LOADING
1429 # define MACH_TYPE "NS32K"
1430 # define ALIGNMENT 4
1431 extern char **environ;
1432 # define DATASTART ((ptr_t)(&environ))
1433 /* hideous kludge: environ is the first */
1434 /* word in crt0.o, and delimits the start */
1435 /* of the data segment, no matter which */
1436 /* ld options were passed through. */
1437 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1441 # define MACH_TYPE "MIPS"
1443 /* This was developed for a linuxce style platform. Probably */
1444 /* needs to be tweaked for workstation class machines. */
1445 # define OS_TYPE "LINUX"
1446 # define DYNAMIC_LOADING
1448 # define DATAEND (_end)
1449 #pragma weak __data_start
1450 extern int __data_start[];
1451 # define DATASTART ((ptr_t)(__data_start))
1452 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1453 # define ALIGNMENT 8
1454 # define CPP_WORDSZ 64
1456 # define ALIGNMENT 4
1458 # define USE_GENERIC_PUSH_REGS
1459 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1460 # define LINUX_STACKBOTTOM
1462 # define STACKBOTTOM 0x80000000
1467 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1468 extern int _fdata[], _end[];
1469 # define DATASTART ((ptr_t)_fdata)
1470 # define DATAEND ((ptr_t)_end)
1471 # define CPP_WORDSZ _MIPS_SZPTR
1472 # define ALIGNMENT (_MIPS_SZPTR/8)
1474 extern int etext[], edata[], end[];
1475 extern int _DYNAMIC_LINKING[], _gp[];
1476 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1477 + ((word)etext & 0xffff)))
1478 # define DATAEND (edata)
1479 # define DATASTART2 (_DYNAMIC_LINKING \
1480 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1482 # define DATAEND2 (end)
1483 # define ALIGNMENT 4
1485 # define OS_TYPE "EWS4800"
1486 # define USE_GENERIC_PUSH_REGS 1
1490 # define DATASTART (ptr_t)0x10000000
1491 /* Could probably be slightly higher since */
1492 /* startup code allocates lots of stuff. */
1493 # define OS_TYPE "ULTRIX"
1494 # define ALIGNMENT 4
1498 # define DATASTART (ptr_t)0x10000000
1499 # define OS_TYPE "RISCOS"
1500 # define ALIGNMENT 4 /* Required by hardware */
1504 extern int _fdata[];
1505 # define DATASTART ((ptr_t)(_fdata))
1507 # define HEAP_START (ptr_t)0x30000000
1509 # define HEAP_START DATASTART
1511 /* Lowest plausible heap address. */
1512 /* In the MMAP case, we map there. */
1513 /* In either case it is used to identify */
1514 /* heap sections so they're not */
1515 /* considered as roots. */
1516 # define OS_TYPE "IRIX5"
1517 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1518 /* of recent breakage. */
1520 # define CPP_WORDSZ _MIPS_SZPTR
1521 # define ALIGNMENT (_MIPS_SZPTR/8)
1522 # if CPP_WORDSZ != 64
1523 # define ALIGN_DOUBLE
1526 # define ALIGNMENT 4
1527 # define ALIGN_DOUBLE
1529 # define DYNAMIC_LOADING
1532 # define OS_TYPE "MSWINCE"
1533 # define ALIGNMENT 4
1534 # define DATAEND /* not needed */
1536 # if defined(NETBSD)
1537 # define ALIGNMENT 4
1538 # define OS_TYPE "NETBSD"
1540 # define USE_GENERIC_PUSH_REGS
1543 # define DATASTART GC_data_start
1544 # define NEED_FIND_LIMIT
1545 # define DYNAMIC_LOADING
1547 # define DATASTART ((ptr_t) 0x10000000)
1548 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1554 # define MACH_TYPE "RS6000"
1559 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1562 # define ALIGNMENT 8
1563 # define CPP_WORDSZ 64
1564 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1566 # define ALIGNMENT 4
1567 # define CPP_WORDSZ 32
1568 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1571 # define USE_MMAP_ANON
1572 /* From AIX linker man page:
1573 _text Specifies the first location of the program.
1574 _etext Specifies the first location after the program.
1575 _data Specifies the first location of the data.
1576 _edata Specifies the first location after the initialized data
1577 _end or end Specifies the first location after all data.
1579 extern int _data[], _end[];
1580 # define DATASTART ((ptr_t)((ulong)_data))
1581 # define DATAEND ((ptr_t)((ulong)_end))
1583 # define USE_GENERIC_PUSH_REGS
1584 # define DYNAMIC_LOADING
1585 /* For really old versions of AIX, this may have to be removed. */
1589 # define MACH_TYPE "HP_PA"
1591 # define CPP_WORDSZ 64
1592 # define ALIGNMENT 8
1594 # define CPP_WORDSZ 32
1595 # define ALIGNMENT 4
1596 # define ALIGN_DOUBLE
1598 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1599 # ifndef LINUX /* For now. */
1600 # define MPROTECT_VDB
1603 # define GENERIC_COMPARE_AND_SWAP
1604 /* No compare-and-swap instruction. Use pthread mutexes */
1605 /* when we absolutely have to. */
1606 # ifdef PARALLEL_MARK
1607 # define USE_MARK_BYTES
1608 /* Minimize compare-and-swap usage. */
1611 # define STACK_GROWS_UP
1613 # define OS_TYPE "HPUX"
1614 extern int __data_start[];
1615 # define DATASTART ((ptr_t)(__data_start))
1617 /* The following appears to work for 7xx systems running HP/UX */
1618 /* 9.xx Furthermore, it might result in much faster */
1619 /* collections than HEURISTIC2, which may involve scanning */
1620 /* segments that directly precede the stack. It is not the */
1621 /* default, since it may not work on older machine/OS */
1622 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1624 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1626 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1627 /* to this. Note that the GC must be initialized before the */
1628 /* first putenv call. */
1629 extern char ** environ;
1630 # define STACKBOTTOM ((ptr_t)environ)
1632 # define DYNAMIC_LOADING
1633 # include <unistd.h>
1634 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1636 # define PREFETCH(x) { \
1637 register long addr = (long)(x); \
1638 (void) _asm ("LDW", 0, 0, addr, 0); \
1643 # define OS_TYPE "LINUX"
1644 # define LINUX_STACKBOTTOM
1645 # define DYNAMIC_LOADING
1646 # define SEARCH_FOR_DATA_START
1648 # define DATAEND (&_end)
1653 # define MACH_TYPE "ALPHA"
1654 # define ALIGNMENT 8
1655 # define CPP_WORDSZ 64
1657 # define USE_GENERIC_PUSH_REGS
1658 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1659 /* fp registers in some cases when the target is a 21264. The assembly */
1660 /* code doesn't handle that yet, and version dependencies make that a */
1661 /* bit tricky. Do the easy thing for now. */
1664 # define OS_TYPE "NETBSD"
1666 # define DATASTART GC_data_start
1667 # define ELFCLASS32 32
1668 # define ELFCLASS64 64
1669 # define ELF_CLASS ELFCLASS64
1670 # define DYNAMIC_LOADING
1673 # define OS_TYPE "OPENBSD"
1675 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1676 # define DATASTART GC_data_start
1677 # define ELFCLASS32 32
1678 # define ELFCLASS64 64
1679 # define ELF_CLASS ELFCLASS64
1680 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1681 # define DATASTART ((ptr_t) 0x140000000)
1685 # define OS_TYPE "FREEBSD"
1686 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1687 # define SIG_SUSPEND SIGTSTP
1688 # define SIG_THR_RESTART SIGCONT
1689 # define FREEBSD_STACKBOTTOM
1691 # define DYNAMIC_LOADING
1693 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1694 extern char etext[];
1695 extern char edata[];
1697 # define NEED_FIND_LIMIT
1698 # define DATASTART ((ptr_t)(&etext))
1699 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1700 # define DATASTART2 ((ptr_t)(&edata))
1701 # define DATAEND2 ((ptr_t)(&end))
1704 # define OS_TYPE "OSF1"
1705 # define DATASTART ((ptr_t) 0x140000000)
1707 # define DATAEND ((ptr_t) &_end)
1708 extern char ** environ;
1709 /* round up from the value of environ to the nearest page boundary */
1710 /* Probably breaks if putenv is called before collector */
1711 /* initialization. */
1712 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1713 /* # define HEURISTIC2 */
1714 /* Normally HEURISTIC2 is too conervative, since */
1715 /* the text segment immediately follows the stack. */
1716 /* Hence we give an upper pound. */
1717 /* This is currently unused, since we disabled HEURISTIC2 */
1718 extern int __start[];
1719 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1720 # ifndef GC_OSF1_THREADS
1721 /* Unresolved signal issues with threads. */
1722 # define MPROTECT_VDB
1724 # define DYNAMIC_LOADING
1727 # define OS_TYPE "LINUX"
1728 # define LINUX_STACKBOTTOM
1730 # define SEARCH_FOR_DATA_START
1731 # define DYNAMIC_LOADING
1733 # define DATASTART ((ptr_t) 0x140000000)
1736 # define DATAEND (_end)
1737 # define MPROTECT_VDB
1738 /* Has only been superficially tested. May not */
1739 /* work on all versions. */
1744 # define MACH_TYPE "IA64"
1745 # define USE_GENERIC_PUSH_REGS
1746 /* We need to get preserved registers in addition to register */
1747 /* windows. That's easiest to do with setjmp. */
1748 # ifdef PARALLEL_MARK
1749 # define USE_MARK_BYTES
1750 /* Compare-and-exchange is too expensive to use for */
1751 /* setting mark bits. */
1755 # define CPP_WORDSZ 32
1756 # define ALIGN_DOUBLE
1757 /* Requires 8 byte alignment for malloc */
1758 # define ALIGNMENT 4
1763 # define CPP_WORDSZ 64
1764 # define ALIGN_DOUBLE
1765 /* Requires 16 byte alignment for malloc */
1766 # define ALIGNMENT 8
1768 # define OS_TYPE "HPUX"
1769 extern int __data_start[];
1770 # define DATASTART ((ptr_t)(__data_start))
1771 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1772 /* to this. Note that the GC must be initialized before the */
1773 /* first putenv call. */
1774 extern char ** environ;
1775 # define STACKBOTTOM ((ptr_t)environ)
1776 # define HPUX_STACKBOTTOM
1777 # define DYNAMIC_LOADING
1778 # include <unistd.h>
1779 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1780 /* The following was empirically determined, and is probably */
1781 /* not very robust. */
1782 /* Note that the backing store base seems to be at a nice */
1783 /* address minus one page. */
1784 # define BACKING_STORE_DISPLACEMENT 0x1000000
1785 # define BACKING_STORE_ALIGNMENT 0x1000
1786 extern ptr_t GC_register_stackbottom;
1787 # define BACKING_STORE_BASE GC_register_stackbottom
1788 /* Known to be wrong for recent HP/UX versions!!! */
1791 # define CPP_WORDSZ 64
1792 # define ALIGN_DOUBLE
1793 /* Requires 16 byte alignment for malloc */
1794 # define ALIGNMENT 8
1795 # define OS_TYPE "LINUX"
1796 /* The following works on NUE and older kernels: */
1797 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1798 /* This does not work on NUE: */
1799 # define LINUX_STACKBOTTOM
1800 /* We also need the base address of the register stack */
1801 /* backing store. This is computed in */
1802 /* GC_linux_register_stack_base based on the following */
1804 # define BACKING_STORE_ALIGNMENT 0x100000
1805 # define BACKING_STORE_DISPLACEMENT 0x80000000
1806 extern ptr_t GC_register_stackbottom;
1807 # define BACKING_STORE_BASE GC_register_stackbottom
1808 # define SEARCH_FOR_DATA_START
1810 # define DYNAMIC_LOADING
1812 /* In the Intel compiler environment, we seem to end up with */
1813 /* statically linked executables and an undefined reference */
1816 # define MPROTECT_VDB
1817 /* Requires Linux 2.3.47 or later. */
1819 # define DATAEND (_end)
1821 # ifndef __INTEL_COMPILER
1822 # define PREFETCH(x) \
1823 __asm__ (" lfetch [%0]": : "r"(x))
1824 # define PREFETCH_FOR_WRITE(x) \
1825 __asm__ (" lfetch.excl [%0]": : "r"(x))
1826 # define CLEAR_DOUBLE(x) \
1827 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1829 # include <ia64intrin.h>
1830 # define PREFETCH(x) \
1831 __lfetch(__lfhint_none, (x))
1832 # define PREFETCH_FOR_WRITE(x) \
1833 __lfetch(__lfhint_nta, (x))
1834 # define CLEAR_DOUBLE(x) \
1835 __stf_spill((void *)(x), 0)
1836 # endif // __INTEL_COMPILER
1840 /* FIXME: This is a very partial guess. There is no port, yet. */
1841 # define OS_TYPE "MSWIN32"
1842 /* STACKBOTTOM and DATASTART are handled specially in */
1844 # define DATAEND /* not needed */
1845 # if defined(_WIN64)
1846 # define CPP_WORDSZ 64
1848 # define CPP_WORDSZ 32 /* Is this possible? */
1850 # define ALIGNMENT 8
1855 # define MACH_TYPE "M88K"
1856 # define ALIGNMENT 4
1857 # define ALIGN_DOUBLE
1860 # define OS_TYPE "CX_UX"
1861 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1864 # define OS_TYPE "DGUX"
1865 extern ptr_t GC_SysVGetDataStart();
1866 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1868 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1872 /* If this still works, and if anyone cares, this should probably */
1873 /* be moved to the S390 category. */
1874 # define MACH_TYPE "S370"
1875 # define ALIGNMENT 4 /* Required by hardware */
1876 # define USE_GENERIC_PUSH_REGS
1878 # define OS_TYPE "UTS4"
1880 extern int _etext[];
1882 extern ptr_t GC_SysVGetDataStart();
1883 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1884 # define DATAEND (_end)
1890 # define MACH_TYPE "S390"
1891 # define USE_GENERIC_PUSH_REGS
1893 # define ALIGNMENT 4
1894 # define CPP_WORDSZ 32
1896 # define ALIGNMENT 8
1897 # define CPP_WORDSZ 64
1900 # define HBLKSIZE 4096
1903 # define OS_TYPE "LINUX"
1904 # define LINUX_STACKBOTTOM
1905 # define DYNAMIC_LOADING
1906 extern int __data_start[];
1907 # define DATASTART ((ptr_t)(__data_start))
1909 # define DATAEND (_end)
1910 # define CACHE_LINE_SIZE 256
1911 # define GETPAGESIZE() 4096
1916 # define ALIGNMENT 4
1917 extern int _etext[];
1918 # define DATASTART ((ptr_t)(_etext))
1923 # define CPP_WORDSZ 32
1924 # define MACH_TYPE "ARM32"
1925 # define ALIGNMENT 4
1927 # define OS_TYPE "NETBSD"
1930 # define DATASTART GC_data_start
1931 # define DYNAMIC_LOADING
1933 extern char etext[];
1934 # define DATASTART ((ptr_t)(etext))
1936 # define USE_GENERIC_PUSH_REGS
1939 # define OS_TYPE "LINUX"
1940 # define LINUX_STACKBOTTOM
1942 # define STACK_GRAN 0x10000000
1943 # define USE_GENERIC_PUSH_REGS
1945 # define DYNAMIC_LOADING
1946 # include <features.h>
1947 # if defined(__GLIBC__) && __GLIBC__ >= 2
1948 # define SEARCH_FOR_DATA_START
1949 # elif defined(PLATFORM_ANDROID)
1950 # define SEARCH_FOR_DATA_START
1952 extern char **__environ;
1953 # define DATASTART ((ptr_t)(&__environ))
1954 /* hideous kludge: __environ is the first */
1955 /* word in crt0.o, and delimits the start */
1956 /* of the data segment, no matter which */
1957 /* ld options were passed through. */
1958 /* We could use _etext instead, but that */
1959 /* would include .rodata, which may */
1960 /* contain large read-only data tables */
1961 /* that we'd rather not scan. */
1964 # define DATAEND (_end)
1967 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1971 # define OS_TYPE "MSWINCE"
1972 # define DATAEND /* not needed */
1975 # define OS_TYPE "DARWIN"
1976 # define DATASTART ((ptr_t) get_etext())
1977 # define DATAEND ((ptr_t) get_end())
1978 # define STACKBOTTOM ((ptr_t) 0x30000000)
1980 # define USE_MMAP_ANON
1984 /* __data_start is usually defined in the target linker script. */
1985 extern int __data_start[];
1986 # define DATASTART (ptr_t)(__data_start)
1987 # define USE_GENERIC_PUSH_REGS
1988 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1989 extern void *__stack_base__;
1990 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1995 # define MACH_TYPE "CRIS"
1996 # define CPP_WORDSZ 32
1997 # define ALIGNMENT 1
1998 # define OS_TYPE "LINUX"
1999 # define DYNAMIC_LOADING
2000 # define LINUX_STACKBOTTOM
2001 # define USE_GENERIC_PUSH_REGS
2002 # define SEARCH_FOR_DATA_START
2004 # define DATAEND (_end)
2008 # define MACH_TYPE "SH"
2009 # define ALIGNMENT 4
2011 # define OS_TYPE "MSWINCE"
2012 # define DATAEND /* not needed */
2015 # define OS_TYPE "LINUX"
2016 # define LINUX_STACKBOTTOM
2017 # define USE_GENERIC_PUSH_REGS
2018 # define DYNAMIC_LOADING
2019 # define SEARCH_FOR_DATA_START
2021 # define DATAEND (_end)
2024 # define OS_TYPE "NETBSD"
2026 # define DATASTART GC_data_start
2027 # define USE_GENERIC_PUSH_REGS
2028 # define DYNAMIC_LOADING
2033 # define MACH_TYPE "SH4"
2034 # define OS_TYPE "MSWINCE"
2035 # define ALIGNMENT 4
2036 # define DATAEND /* not needed */
2040 # define CPP_WORDSZ 32
2041 # define MACH_TYPE "M32R"
2042 # define ALIGNMENT 4
2044 # define OS_TYPE "LINUX"
2045 # define LINUX_STACKBOTTOM
2047 # define STACK_GRAN 0x10000000
2048 # define USE_GENERIC_PUSH_REGS
2049 # define DYNAMIC_LOADING
2050 # define SEARCH_FOR_DATA_START
2052 # define DATAEND (_end)
2057 # define MACH_TYPE "X86_64"
2058 # define ALIGNMENT 8
2059 # define CPP_WORDSZ 64
2061 # define HBLKSIZE 4096
2063 # define CACHE_LINE_SIZE 64
2064 # define USE_GENERIC_PUSH_REGS
2066 # define OS_TYPE "LINUX"
2067 # define LINUX_STACKBOTTOM
2069 # define FALLBACK_TO_MMAP
2071 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
2072 # define MPROTECT_VDB
2074 /* We seem to get random errors in incremental mode, */
2075 /* possibly because Linux threads is itself a malloc client */
2076 /* and can't deal with the signals. */
2079 # define DYNAMIC_LOADING
2080 # ifdef UNDEFINED /* includes ro data */
2081 extern int _etext[];
2082 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
2084 # include <features.h>
2085 # define SEARCH_FOR_DATA_START
2087 # define DATAEND (_end)
2090 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2092 # if defined(__GNUC__) && __GNUC >= 3
2093 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2094 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2098 # define OS_TYPE "DARWIN"
2099 # define DARWIN_DONT_PARSE_STACK
2100 # define DYNAMIC_LOADING
2101 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
2102 These aren't used when dyld support is enabled (it is by default) */
2103 # define DATASTART ((ptr_t) get_etext())
2104 # define DATAEND ((ptr_t) get_end())
2105 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
2109 # define USE_MMAP_ANON
2110 # ifdef GC_DARWIN_THREADS
2111 # define MPROTECT_VDB
2113 # include <unistd.h>
2114 # define GETPAGESIZE() getpagesize()
2115 /* There seems to be some issues with trylock hanging on darwin. This
2116 should be looked into some more */
2119 # define OS_TYPE "FREEBSD"
2120 # ifndef GC_FREEBSD_THREADS
2121 # define MPROTECT_VDB
2123 # define SIG_SUSPEND SIGTSTP
2124 # define SIG_THR_RESTART SIGCONT
2125 # define NEED_FIND_LIMIT
2126 # define FREEBSD_STACKBOTTOM
2128 # define DYNAMIC_LOADING
2130 extern char etext[];
2131 extern char * GC_FreeBSDGetDataStart();
2132 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2135 # define OS_TYPE "NETBSD"
2137 # define DYNAMIC_LOADING
2140 extern char etext[];
2141 # define SEARCH_FOR_DATA_START
2144 # define OS_TYPE "OPENBSD"
2145 # define ELF_CLASS ELFCLASS64
2146 # ifdef GC_OPENBSD_THREADS
2147 # define UTHREAD_SP_OFFSET 400
2149 # include <sys/param.h>
2150 # include <uvm/uvm_extern.h>
2151 # define STACKBOTTOM USRSTACK
2153 extern int __data_start[];
2154 # define DATASTART ((ptr_t)(__data_start))
2156 # define DATAEND ((ptr_t)(&_end))
2157 # define DYNAMIC_LOADING
2161 #if defined(LINUX) && defined(USE_MMAP)
2162 /* The kernel may do a somewhat better job merging mappings etc. */
2163 /* with anonymous mappings. */
2164 # define USE_MMAP_ANON
2167 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2168 /* Rld appears to allocate some memory with its own allocator, and */
2169 /* some through malloc, which might be redirected. To make this */
2170 /* work with collectable memory, we have to scan memory allocated */
2171 /* by rld's internal malloc. */
2172 # define USE_PROC_FOR_LIBRARIES
2175 # ifndef STACK_GROWS_UP
2176 # define STACK_GROWS_DOWN
2180 # define CPP_WORDSZ 32
2189 # define DATAEND (end)
2192 # if defined(SVR4) && !defined(GETPAGESIZE)
2193 # include <unistd.h>
2194 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2197 # ifndef GETPAGESIZE
2198 # if defined(SUNOS5) || defined(IRIX5)
2199 # include <unistd.h>
2201 # define GETPAGESIZE() getpagesize()
2204 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2205 /* OS has SVR4 generic features. Probably others also qualify. */
2209 # if defined(SUNOS5) || defined(DRSNX)
2210 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2213 /* OS has SUNOS5 style signal handlers. */
2221 # if defined(FREEBSD) && (__FreeBSD__ >= 4)
2225 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2226 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2227 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2228 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2229 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2232 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2237 # undef DYNAMIC_LOADING
2242 # undef MPROTECT_VDB
2247 /* Postponed for now. */
2249 # undef MPROTECT_VDB
2252 # ifdef SMALL_CONFIG
2253 /* Presumably not worth the space it takes. */
2255 # undef MPROTECT_VDB
2259 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2262 # ifdef PARALLEL_MARK
2263 # undef MPROTECT_VDB /* For now. */
2266 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2267 # define DEFAULT_VDB
2271 # define PREFETCH(x)
2272 # define NO_PREFETCH
2275 # ifndef PREFETCH_FOR_WRITE
2276 # define PREFETCH_FOR_WRITE(x)
2277 # define NO_PREFETCH_FOR_WRITE
2280 # ifndef CACHE_LINE_SIZE
2281 # define CACHE_LINE_SIZE 32 /* Wild guess */
2285 # define REGISTER_LIBRARIES_EARLY
2286 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2287 /* lock. This isn't safe after the world has stopped. So we must */
2288 /* call GC_register_dynamic_libraries before stopping the world. */
2289 /* For performance reasons, this may be beneficial on other */
2290 /* platforms as well, though it should be avoided in win32. */
2293 # if defined(SEARCH_FOR_DATA_START)
2294 extern ptr_t GC_data_start;
2295 # define DATASTART GC_data_start
2298 # ifndef CLEAR_DOUBLE
2299 # define CLEAR_DOUBLE(x) \
2300 ((word*)x)[0] = 0; \
2302 # endif /* CLEAR_DOUBLE */
2304 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2305 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2306 # define GC_SOLARIS_THREADS
2309 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2310 --> inconsistent configuration
2312 # if defined(GC_LINUX_THREADS) && !(defined(LINUX) || defined(NACL))
2313 --> inconsistent configuration
2315 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2316 --> inconsistent configuration
2318 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2319 --> inconsistent configuration
2321 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2322 --> inconsistent configuration
2324 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2325 --> inconsistent configuration
2328 # if defined(PCR) || defined(SRC_M3) || \
2329 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2330 defined(GC_PTHREADS) || defined(SN_TARGET_PS3)
2334 # if defined(HP_PA) || defined(M88K) \
2335 || defined(POWERPC) && !defined(DARWIN) \
2336 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2337 || (defined(I386) && defined(__LCC__))
2338 /* Use setjmp based hack to mark from callee-save registers. */
2339 /* The define should move to the individual platform */
2341 # define USE_GENERIC_PUSH_REGS
2344 # if defined(MSWINCE)
2349 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2350 /* include assembly code to do it well. */
2353 /* Can we save call chain in objects for debugging? */
2354 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2355 /* frame) to reasonable values for the platform. */
2356 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2357 /* at build time, though we feel free to adjust it slightly. */
2358 /* Define NEED_CALLINFO if we either save the call stack or */
2359 /* GC_ADD_CALLER is defined. */
2360 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2363 # define CAN_SAVE_CALL_ARGS
2365 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
2366 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2367 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2368 # define CAN_SAVE_CALL_ARGS
2371 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2372 && defined(GC_CAN_SAVE_CALL_STACKS)
2373 # define SAVE_CALL_CHAIN
2375 # ifdef SAVE_CALL_CHAIN
2376 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2377 # define NARGS SAVE_CALL_NARGS
2379 # define NARGS 0 /* Number of arguments to save for each call. */
2382 # ifdef SAVE_CALL_CHAIN
2383 # ifndef SAVE_CALL_COUNT
2384 # define NFRAMES 6 /* Number of frames to save. Even for */
2385 /* alignment reasons. */
2387 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2389 # define NEED_CALLINFO
2390 # endif /* SAVE_CALL_CHAIN */
2391 # ifdef GC_ADD_CALLER
2394 # define NEED_CALLINFO
2397 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2398 # define DBG_HDRS_ALL
2401 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2402 # define POINTER_SHIFT 0
2405 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2406 # define POINTER_MASK ((GC_word)(-1))
2409 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2410 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2413 # if defined(FIXUP_POINTER)
2414 # define NEED_FIXUP_POINTER 1
2416 # define NEED_FIXUP_POINTER 0
2417 # define FIXUP_POINTER(p)
2421 /* This relies on some type definitions from gc_priv.h, from */
2422 /* where it's normally included. */
2424 /* How to get heap memory from the OS: */
2425 /* Note that sbrk()-like allocation is preferred, since it */
2426 /* usually makes it possible to merge consecutively allocated */
2427 /* chunks. It also avoids unintented recursion with */
2428 /* -DREDIRECT_MALLOC. */
2429 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2430 /* 0 is taken to mean failure. */
2431 /* In the case os USE_MMAP, the argument must also be a */
2432 /* physical page size. */
2433 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2434 /* though we should perhaps take advantage of the case in which */
2436 struct hblk; /* See gc_priv.h. */
2438 char * real_malloc();
2439 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2443 void * os2_alloc(size_t bytes);
2444 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2448 # if defined(NEXT) || defined(DOS4GW) || \
2449 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2450 (defined(SUNOS5) && !defined(USE_MMAP))
2451 # define GET_MEM(bytes) HBLKPTR((size_t) \
2452 calloc(1, (size_t)bytes + GC_page_size) \
2456 extern ptr_t GC_win32_get_mem();
2457 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2460 # if defined(USE_TEMPORARY_MEMORY)
2461 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2462 Boolean clearMemory);
2463 # define GET_MEM(bytes) HBLKPTR( \
2464 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2467 # define GET_MEM(bytes) HBLKPTR( \
2468 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2472 extern ptr_t GC_wince_get_mem();
2473 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2475 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2476 extern void *GC_amiga_get_mem(size_t size);
2477 # define GET_MEM(bytes) HBLKPTR((size_t) \
2478 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2481 # if defined(SN_TARGET_PS3)
2482 extern void *ps3_get_mem (size_t size);
2483 # define GET_MEM(bytes) (struct hblk*) ps3_get_mem (bytes)
2485 extern ptr_t GC_unix_get_mem(word size);
2486 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2496 #endif /* GC_PRIVATE_H */
2498 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2499 /* IBMs xlc compiler doesn't appear to follow the convention of */
2500 /* defining __STDC__ to be zero in extended mode. */
2504 # endif /* GCCONFIG_H */