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(__arm__) || defined(__thumb__)
70 # if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN)
72 # define mach_type_known
75 # if defined(sun) && defined(mc68000)
78 # define mach_type_known
80 # if defined(hp9000s300)
83 # define mach_type_known
85 # if defined(OPENBSD) && defined(m68k)
87 # define mach_type_known
89 # if defined(OPENBSD) && defined(__sparc__)
91 # define mach_type_known
93 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
95 # define mach_type_known
97 # if defined(NETBSD) && defined(__powerpc__)
99 # define mach_type_known
101 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
103 # define mach_type_known
105 # if defined(NETBSD) && defined(__sh__)
107 # define mach_type_known
116 # define mach_type_known
118 # if defined(__NetBSD__) && defined(__vax__)
120 # define mach_type_known
122 # if defined(mips) || defined(__mips) || defined(_mips)
124 # if defined(nec_ews) || defined(_nec_ews)
127 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
128 # if defined(ultrix) || defined(__ultrix)
131 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
132 || defined(__SYSTYPE_SVR4__)
133 # define IRIX5 /* or IRIX 6.X */
135 # define RISCOS /* or IRIX 4.X */
139 # if defined(__NetBSD__) && defined(__MIPSEL__)
142 # define mach_type_known
144 # if defined(DGUX) && (defined(i386) || defined(__i386__))
149 # define mach_type_known
151 # if defined(sequent) && (defined(i386) || defined(__i386__))
154 # define mach_type_known
156 # if defined(sun) && (defined(i386) || defined(__i386__))
159 # define mach_type_known
161 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
164 # define mach_type_known
168 # define mach_type_known
170 # if defined(sun) && (defined(sparc) || defined(__sparc))
172 /* Test for SunOS 5.x */
179 # define mach_type_known
181 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
182 && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
185 # define mach_type_known
189 # define mach_type_known
191 # if defined(__NetBSD__) && defined(__sparc__)
193 # define mach_type_known
195 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
196 /* The above test may need refinement */
198 # if defined(_SCO_ELF)
203 # define mach_type_known
205 # if defined(_AUX_SOURCE)
208 # define mach_type_known
210 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
211 || defined(hppa) || defined(__hppa__)
213 # if !defined(LINUX) && !defined(HPUX)
216 # define mach_type_known
218 # if defined(__ia64) && defined(_HPUX_SOURCE)
223 # define mach_type_known
225 # if defined(__BEOS__) && defined(_X86_)
228 # define mach_type_known
230 # if defined(LINUX) && (defined(i386) || defined(__i386__))
232 # define mach_type_known
234 # if defined(LINUX) && defined(__x86_64__)
236 # define mach_type_known
238 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
240 # define mach_type_known
242 # if defined(LINUX) && defined(__arm__)
244 # define mach_type_known
246 # if defined(LINUX) && defined(__cris__)
250 # define mach_type_known
252 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
253 defined(powerpc64) || defined(__powerpc64__))
255 # define mach_type_known
257 # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
259 # define mach_type_known
261 # if defined(LINUX) && defined(__mc68000__)
263 # define mach_type_known
265 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
267 # define mach_type_known
269 # if defined(LINUX) && defined(__arm__)
271 # define mach_type_known
273 # if defined(LINUX) && defined(__sh__)
275 # define mach_type_known
277 # if defined(LINUX) && defined(__m32r__)
279 # define mach_type_known
281 # if defined(__alpha) || defined(__alpha__)
283 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
284 # define OSF1 /* a.k.a Digital Unix */
286 # define mach_type_known
288 # if defined(_AMIGA) && !defined(AMIGA)
293 # define mach_type_known
295 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
298 # define mach_type_known
300 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
303 # define mach_type_known
306 # if defined(__ppc__) || defined(__ppc64__)
308 # define mach_type_known
309 # elif defined(__i386__)
311 # define mach_type_known
312 # define DARWIN_DONT_PARSE_STACK
313 # define OS_TYPE "DARWIN"
314 # define DYNAMIC_LOADING
315 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
316 These aren't used when dyld support is enabled (it is by default) */
317 # define DATASTART ((ptr_t) get_etext())
318 # define DATAEND ((ptr_t) get_end())
319 # define STACKBOTTOM ((ptr_t) 0xc0000000)
321 # define USE_MMAP_ANON
322 # define USE_ASM_PUSH_REGS
323 /* This is potentially buggy. It needs more testing. See the comments in
324 os_dep.c. It relies on threads to track writes. */
325 # ifdef GC_DARWIN_THREADS
326 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
329 # define GETPAGESIZE() getpagesize()
330 # elif defined(__arm__)
332 # define mach_type_known
333 # define DARWIN_DONT_PARSE_STACK
334 # define GC_DONT_REGISTER_MAIN_STATIC_DATA
335 # elif defined(__x86_64)
337 # define mach_type_known
340 # if defined(NeXT) && defined(mc68000)
343 # define mach_type_known
345 # if defined(NeXT) && (defined(i386) || defined(__i386__))
348 # define mach_type_known
350 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
353 # define mach_type_known
355 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
357 # define mach_type_known
359 # if defined(FREEBSD) && defined(__x86_64__)
361 # define mach_type_known
363 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
365 # define mach_type_known
367 # if defined(__NetBSD__) && defined(__x86_64__)
369 # define mach_type_known
371 # if defined(FREEBSD) && defined(__sparc__)
373 # define mach_type_known
375 # if defined(bsdi) && (defined(i386) || defined(__i386__))
378 # define mach_type_known
380 # if !defined(mach_type_known) && defined(__386BSD__)
383 # define mach_type_known
385 # if defined(_CX_UX) && defined(_M88K)
388 # define mach_type_known
390 # if defined(DGUX) && defined(m88k)
393 # define mach_type_known
395 # if defined(_WIN32_WCE)
396 /* SH3, SH4, MIPS already defined for corresponding architectures */
397 # if defined(SH3) || defined(SH4)
407 # define mach_type_known
409 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
410 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
411 # if defined(__LP64__) || defined(_WIN64)
416 # define MSWIN32 /* or Win64 */
417 # define mach_type_known
419 # if defined(_MSC_VER) && defined(_M_IA64)
421 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
422 /* variants as a differnt platform. */
425 # if defined(__DJGPP__)
428 # define DJGPP /* MSDOS running the DJGPP port of GCC */
430 # define mach_type_known
432 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
435 # define mach_type_known
437 # if defined(__MINGW32__)
440 # define mach_type_known
442 # if defined(__BORLANDC__)
445 # define mach_type_known
447 # if defined(_UTS) && !defined(mach_type_known)
450 # define mach_type_known
454 # define mach_type_known
456 # if defined(__embedded__) && defined(PPC)
459 # define mach_type_known
462 # if defined(__WATCOMC__) && defined(__386__)
464 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
465 # if defined(__OS2__)
468 # if defined(__WINDOWS_386__) || defined(__NT__)
475 # define mach_type_known
477 # if defined(__s390__) && defined(LINUX)
479 # define mach_type_known
481 # if defined(__GNU__)
482 # if defined(__i386__)
483 /* The Debian Hurd running on generic PC */
486 # define mach_type_known
490 /* Feel free to add more clauses here */
492 /* Or manually define the machine type here. A machine type is */
493 /* characterized by the architecture. Some */
494 /* machine types are further subdivided by OS. */
495 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
496 /* Note that SGI IRIX is treated identically to RISCOS. */
497 /* SYSV on an M68K actually means A/UX. */
498 /* The distinction in these cases is usually the stack starting address */
499 # ifndef mach_type_known
500 --> unknown machine type
502 /* Mapping is: M68K ==> Motorola 680X0 */
503 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
504 /* MACOS and AMIGA variants) */
505 /* I386 ==> Intel 386 */
506 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
507 /* FREEBSD, THREE86BSD, MSWIN32, */
508 /* BSDI,SUNOS5, NEXT, other variants) */
509 /* NS32K ==> Encore Multimax */
510 /* MIPS ==> R2000 or R3000 */
511 /* (RISCOS, ULTRIX variants) */
512 /* VAX ==> DEC VAX */
513 /* (BSD, ULTRIX variants) */
514 /* RS6000 ==> IBM RS/6000 AIX3.X */
515 /* RT ==> IBM PC/RT */
516 /* HP_PA ==> HP9000/700 & /800 */
518 /* SPARC ==> SPARC v7/v8/v9 */
519 /* (SUNOS4, SUNOS5, LINUX, */
520 /* DRSNX variants) */
521 /* ALPHA ==> DEC Alpha */
522 /* (OSF1 and LINUX variants) */
523 /* M88K ==> Motorola 88XX0 */
524 /* (CX_UX and DGUX) */
525 /* S370 ==> 370-like machine */
526 /* running Amdahl UTS4 */
527 /* S390 ==> 390-like machine */
529 /* ARM32 ==> Intel StrongARM */
530 /* IA64 ==> Intel IPF */
532 /* (LINUX and HPUX) */
533 /* SH ==> Hitachi SuperH */
534 /* (LINUX & MSWINCE) */
535 /* X86_64 ==> AMD x86-64 */
536 /* POWERPC ==> IBM/Apple PowerPC */
537 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
538 /* LINUX, NETBSD, NOSYS variants) */
539 /* Handles 32 and 64-bit variants. */
540 /* AIX should be handled here, but */
541 /* that's called an RS6000. */
542 /* CRIS ==> Axis Etrax */
543 /* M32R ==> Renesas M32R */
547 * For each architecture and OS, the following need to be defined:
549 * CPP_WORDSZ is a simple integer constant representing the word size.
550 * in bits. We assume byte addressibility, where a byte has 8 bits.
551 * We also assume CPP_WORDSZ is either 32 or 64.
552 * (We care about the length of pointers, not hardware
553 * bus widths. Thus a 64 bit processor with a C compiler that uses
554 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
556 * MACH_TYPE is a string representation of the machine type.
557 * OS_TYPE is analogous for the OS.
559 * ALIGNMENT is the largest N, such that
560 * all pointer are guaranteed to be aligned on N byte boundaries.
561 * defining it to be 1 will always work, but perform poorly.
563 * DATASTART is the beginning of the data segment.
564 * On some platforms SEARCH_FOR_DATA_START is defined.
565 * SEARCH_FOR_DATASTART will cause GC_data_start to
566 * be set to an address determined by accessing data backwards from _end
567 * until an unmapped page is found. DATASTART will be defined to be
569 * On UNIX-like systems, the collector will scan the area between DATASTART
570 * and DATAEND for root pointers.
572 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
573 * RTH suggests gaining access to linker script synth'd values with
574 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
575 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
576 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
577 * without any special options.
579 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
582 * STACKBOTTOM is the cool end of the stack, which is usually the
583 * highest address in the stack.
584 * Under PCR or OS/2, we have other ways of finding thread stacks.
585 * For each machine, the following should:
586 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
587 * 2) define exactly one of
588 * STACKBOTTOM (should be defined to be an expression)
592 * If STACKBOTTOM is defined, then it's value will be used directly as the
593 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
594 * with a method appropriate for most Linux systems. Currently we look
595 * first for __libc_stack_end, and if that fails read it from /proc.
596 * If either of the last two macros are defined, then STACKBOTTOM is computed
597 * during collector startup using one of the following two heuristics:
598 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
599 * the next multiple of STACK_GRAN.
600 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
601 * in small steps (decrement if STACK_GROWS_UP), and read the value
602 * at each location. Remember the value when the first
603 * Segmentation violation or Bus error is signalled. Round that
604 * to the nearest plausible page boundary, and use that instead
607 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
608 * the value of environ is a pointer that can serve as STACKBOTTOM.
609 * I expect that HEURISTIC2 can be replaced by this approach, which
610 * interferes far less with debugging. However it has the disadvantage
611 * that it's confused by a putenv call before the collector is initialized.
612 * This could be dealt with by intercepting putenv ...
614 * If no expression for STACKBOTTOM can be found, and neither of the above
615 * heuristics are usable, the collector can still be used with all of the above
616 * undefined, provided one of the following is done:
617 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
618 * without reference to STACKBOTTOM. This is appropriate for use in
619 * conjunction with thread packages, since there will be multiple stacks.
620 * (Allocating thread stacks in the heap, and treating them as ordinary
621 * heap data objects is also possible as a last resort. However, this is
622 * likely to introduce significant amounts of excess storage retention
623 * unless the dead parts of the thread stacks are periodically cleared.)
624 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
625 * If the author of the client code controls the main program, this is
626 * easily accomplished by introducing a new main program, setting
627 * GC_stackbottom to the address of a local variable, and then calling
628 * the original main program. The new main program would read something
631 * # include "gc_private.h"
633 * main(argc, argv, envp)
635 * char **argv, **envp;
639 * GC_stackbottom = (ptr_t)(&dummy);
640 * return(real_main(argc, argv, envp));
644 * Each architecture may also define the style of virtual dirty bit
645 * implementation to be used:
646 * MPROTECT_VDB: Write protect the heap and catch faults.
647 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
649 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
650 * defined GC_register_dynamic_libraries() for the architecture.
652 * An architecture may define PREFETCH(x) to preload the cache with *x.
653 * This defaults to a no-op.
655 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
657 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
658 * clear the two words at GC_malloc-aligned address x. By default,
659 * word stores of 0 are used instead.
661 * HEAP_START may be defined as the initial address hint for mmap-based
665 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
666 * to push the relevant registers onto the stack. This generally makes
667 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
669 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
670 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
671 && !defined(__INTEL_COMPILER) \
672 && !defined(__PATHCC__)
673 # define HAVE_BUILTIN_UNWIND_INIT
676 # define STACK_GRAN 0x1000000
678 # define MACH_TYPE "M68K"
681 # define OS_TYPE "OPENBSD"
684 # define DATASTART GC_data_start
685 # define DYNAMIC_LOADING
688 # define DATASTART ((ptr_t)(etext))
690 # define USE_GENERIC_PUSH_REGS
693 # define OS_TYPE "NETBSD"
696 # define DATASTART GC_data_start
697 # define DYNAMIC_LOADING
700 # define DATASTART ((ptr_t)(etext))
702 # define USE_GENERIC_PUSH_REGS
705 # define OS_TYPE "LINUX"
706 # define STACKBOTTOM ((ptr_t)0xf0000000)
707 # define USE_GENERIC_PUSH_REGS
708 /* We never got around to the assembly version. */
709 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
711 # define DYNAMIC_LOADING
712 # include <features.h>
713 # if defined(__GLIBC__)&& __GLIBC__>=2
714 # define SEARCH_FOR_DATA_START
716 # if defined(PLATFORM_ANDROID)
717 # define __environ environ
719 extern char **__environ;
720 # define DATASTART ((ptr_t)(&__environ))
721 /* hideous kludge: __environ is the first */
722 /* word in crt0.o, and delimits the start */
723 /* of the data segment, no matter which */
724 /* ld options were passed through. */
725 /* We could use _etext instead, but that */
726 /* would include .rodata, which may */
727 /* contain large read-only data tables */
728 /* that we'd rather not scan. */
729 # endif /* !GLIBC2 */
731 # define DATAEND (_end)
734 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
738 # define OS_TYPE "SUNOS4"
740 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
741 # define HEURISTIC1 /* differs */
742 # define DYNAMIC_LOADING
745 # define OS_TYPE "HP"
747 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
748 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
749 /* empirically determined. seems to work. */
751 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
754 # define OS_TYPE "SYSV"
756 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
758 +((word)etext & 0x1fff))
759 /* This only works for shared-text binaries with magic number 0413.
760 The other sorts of SysV binaries put the data at the end of the text,
761 in which case the default of etext would work. Unfortunately,
762 handling both would require having the magic-number available.
765 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
766 /* The stack starts at the top of memory, but */
767 /* 0x0 cannot be used as setjump_test complains */
768 /* that the stack direction is incorrect. Two */
769 /* bytes down from 0x0 should be safe enough. */
771 # include <sys/mmu.h>
772 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
775 # define OS_TYPE "AMIGA"
776 /* STACKBOTTOM and DATASTART handled specially */
778 # define DATAEND /* not needed */
779 # define GETPAGESIZE() 4096
785 # define OS_TYPE "MACOS"
786 /* see os_dep.c for details of global data segments. */
787 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
788 # define DATAEND /* not needed */
789 # define GETPAGESIZE() 4096
792 # define OS_TYPE "NEXT"
793 # define DATASTART ((ptr_t) get_etext())
794 # define STACKBOTTOM ((ptr_t) 0x4000000)
795 # define DATAEND /* not needed */
799 # if defined(POWERPC)
800 # define MACH_TYPE "POWERPC"
802 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
806 # define OS_TYPE "MACOS"
807 /* see os_dep.c for details of global data segments. */
808 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
809 # define DATAEND /* not needed */
813 # if defined(__powerpc64__)
815 # define CPP_WORDSZ 64
817 # define HBLKSIZE 4096
822 # define OS_TYPE "LINUX"
823 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
824 /* executable on a 64 bit kernel. */
825 # define LINUX_STACKBOTTOM
826 # define DYNAMIC_LOADING
827 # define SEARCH_FOR_DATA_START
829 # define DATAEND (_end)
834 # define CPP_WORDSZ 64
838 # define OS_TYPE "DARWIN"
839 # define DYNAMIC_LOADING
840 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
841 These aren't used when dyld support is enabled (it is by default) */
842 # define DATASTART ((ptr_t) get_etext())
843 # define DATAEND ((ptr_t) get_end())
844 # define STACKBOTTOM ((ptr_t) 0xc0000000)
846 # define USE_MMAP_ANON
847 # define USE_ASM_PUSH_REGS
848 /* This is potentially buggy. It needs more testing. See the comments in
849 os_dep.c. It relies on threads to track writes. */
850 # ifdef GC_DARWIN_THREADS
851 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
854 # define GETPAGESIZE() getpagesize()
855 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
856 /* The performance impact of prefetches is untested */
857 # define PREFETCH(x) \
858 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
859 # define PREFETCH_FOR_WRITE(x) \
860 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
862 /* There seems to be some issues with trylock hanging on darwin. This
863 should be looked into some more */
864 # define NO_PTHREAD_TRYLOCK
868 # define OS_TYPE "FREEBSD"
869 # ifndef GC_FREEBSD_THREADS
870 # define MPROTECT_VDB
872 # define SIG_SUSPEND SIGUSR1
873 # define SIG_THR_RESTART SIGUSR2
874 # define FREEBSD_STACKBOTTOM
876 # define DYNAMIC_LOADING
879 extern char * GC_FreeBSDGetDataStart();
880 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
884 # define OS_TYPE "NETBSD"
887 # define DATASTART GC_data_start
888 # define DYNAMIC_LOADING
890 # ifdef SN_TARGET_PS3
892 # define CPP_WORDSZ 32
895 // extern int _dso_handle[];
896 extern int __bss_start;
898 # define DATAEND (_end)
899 # define DATASTART (__bss_start)
900 # define STACKBOTTOM ((ptr_t) ps3_get_stack_bottom ())
901 # define USE_GENERIC_PUSHREGS
906 # define OS_TYPE "NOSYS"
907 extern void __end[], __dso_handle[];
908 # define DATASTART (__dso_handle) /* OK, that's ugly. */
909 # define DATAEND (__end)
910 /* Stack starts at 0xE0000000 for the simulator. */
912 # define STACK_GRAN 0x10000000
918 # define MACH_TYPE "VAX"
919 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
921 # define DATASTART ((ptr_t)(etext))
923 # define OS_TYPE "BSD"
925 /* HEURISTIC2 may be OK, but it's hard to test. */
928 # define OS_TYPE "ULTRIX"
929 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
934 # define MACH_TYPE "RT"
936 # define DATASTART ((ptr_t) 0x10000000)
937 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
941 # define MACH_TYPE "SPARC"
942 # if defined(__arch64__) || defined(__sparcv9)
944 # define CPP_WORDSZ 64
945 # define ELF_CLASS ELFCLASS64
947 # define ALIGNMENT 4 /* Required by hardware */
948 # define CPP_WORDSZ 32
950 # define ALIGN_DOUBLE
951 # ifdef _FILE_OFFSET_BITS
952 # undef _FILE_OFFSET_BITS /* libelf.h & procfs.h doesn't compile with large file support */
953 # define _FILE_OFFSET_BITS 32
956 # define OS_TYPE "SUNOS5"
959 extern ptr_t GC_SysVGetDataStart();
960 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
961 # define DATAEND (_end)
962 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
964 /* Otherwise we now use calloc. Mmap may result in the */
965 /* heap interleaved with thread stacks, which can result in */
966 /* excessive blacklisting. Sbrk is unusable since it */
967 /* doesn't interact correctly with the system malloc. */
970 # define HEAP_START (ptr_t)0x40000000
972 # define HEAP_START DATAEND
975 /* HEURISTIC1 reportedly no longer works under 2.7. */
976 /* HEURISTIC2 probably works, but this appears to be preferable. */
977 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
978 /* installations that's undefined. We work around this with a */
980 # include <sys/vmparam.h>
982 /* This should work everywhere, but doesn't. */
983 # define STACKBOTTOM USRSTACK
988 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
989 /* getpagesize() appeared to be missing from at least one */
990 /* Solaris 5.4 installation. Weird. */
991 # define DYNAMIC_LOADING
994 # define OS_TYPE "SUNOS4"
995 /* [If you have a weak stomach, don't read this.] */
996 /* We would like to use: */
997 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
998 /* This fails occasionally, due to an ancient, but very */
999 /* persistent ld bug. etext is set 32 bytes too high. */
1000 /* We instead read the text segment size from the a.out */
1001 /* header, which happens to be mapped into our address space */
1002 /* at the start of the text segment. The detective work here */
1003 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
1004 /* Serpette of INRIA. */
1005 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
1006 # define TEXTSTART 0x2000
1007 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
1008 # define MPROTECT_VDB
1010 # define DYNAMIC_LOADING
1013 # define OS_TYPE "DRSNX"
1014 extern ptr_t GC_SysVGetDataStart();
1016 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1017 # define MPROTECT_VDB
1018 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
1019 # define DYNAMIC_LOADING
1022 # define OS_TYPE "LINUX"
1024 # define DYNAMIC_LOADING
1026 Linux Sparc/a.out not supported
1029 # include <features.h>
1030 # if defined(__GLIBC__) && __GLIBC__ >= 2
1031 # define SEARCH_FOR_DATA_START
1033 extern char **__environ;
1034 # define DATASTART ((ptr_t)(&__environ))
1035 /* hideous kludge: __environ is the first */
1036 /* word in crt0.o, and delimits the start */
1037 /* of the data segment, no matter which */
1038 /* ld options were passed through. */
1039 /* We could use _etext instead, but that */
1040 /* would include .rodata, which may */
1041 /* contain large read-only data tables */
1042 /* that we'd rather not scan. */
1045 # define DATAEND (_end)
1046 # define LINUX_STACKBOTTOM
1049 # define OS_TYPE "OPENBSD"
1050 # define STACKBOTTOM ((ptr_t) 0xf8000000)
1052 # define DATASTART ((ptr_t)(etext))
1055 # define OS_TYPE "NETBSD"
1058 # define DATASTART GC_data_start
1059 # define DYNAMIC_LOADING
1061 extern char etext[];
1062 # define DATASTART ((ptr_t)(etext))
1066 # define OS_TYPE "FREEBSD"
1067 # define SIG_SUSPEND SIGUSR1
1068 # define SIG_THR_RESTART SIGUSR2
1069 # define FREEBSD_STACKBOTTOM
1071 # define DYNAMIC_LOADING
1073 extern char etext[];
1074 extern char edata[];
1076 # define NEED_FIND_LIMIT
1077 # define DATASTART ((ptr_t)(&etext))
1078 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1079 # define DATASTART2 ((ptr_t)(&edata))
1080 # define DATAEND2 ((ptr_t)(&end))
1085 # define MACH_TYPE "I386"
1086 # if defined(__LP64__) || defined(_WIN64)
1087 # define CPP_WORDSZ 64
1088 # define ALIGNMENT 8
1090 # define CPP_WORDSZ 32
1091 # define ALIGNMENT 4
1092 /* Appears to hold for all "32 bit" compilers */
1093 /* except Borland. The -a4 option fixes */
1095 /* Ivan Demakov: For Watcom the option is -zp4. */
1097 # ifndef SMALL_CONFIG
1098 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1099 /* improvement on Pentiums. */
1101 # ifdef HAVE_BUILTIN_UNWIND_INIT
1102 # define USE_GENERIC_PUSH_REGS
1105 # define OS_TYPE "SEQUENT"
1107 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1108 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1111 # define OS_TYPE "BEOS"
1113 # define GETPAGESIZE() B_PAGE_SIZE
1115 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1118 # define OS_TYPE "SUNOS5"
1119 extern int _etext[], _end[];
1120 extern ptr_t GC_SysVGetDataStart();
1121 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1122 # define DATAEND (_end)
1123 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1124 /* but reportedly breaks under 2.8. It appears that the stack */
1125 /* base is a property of the executable, so this should not break */
1126 /* old executables. */
1127 /* HEURISTIC2 probably works, but this appears to be preferable. */
1128 # include <sys/vm.h>
1129 # define STACKBOTTOM USRSTACK
1130 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1131 /* It appears to be fixed in 2.8 and 2.9. */
1132 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1133 /* Reading of dirty bits doesn't seem to work even in solaris 10 */
1134 /*# define PROC_VDB */
1136 # define DYNAMIC_LOADING
1137 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1139 /* Otherwise we now use calloc. Mmap may result in the */
1140 /* heap interleaved with thread stacks, which can result in */
1141 /* excessive blacklisting. Sbrk is unusable since it */
1142 /* doesn't interact correctly with the system malloc. */
1145 # define HEAP_START (ptr_t)0x40000000
1147 # define HEAP_START DATAEND
1151 # define OS_TYPE "SCO"
1153 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1155 +((word)etext & 0xfff))
1156 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1159 # define OS_TYPE "SCO_ELF"
1161 # define DATASTART ((ptr_t)(etext))
1162 # define STACKBOTTOM ((ptr_t) 0x08048000)
1163 # define DYNAMIC_LOADING
1164 # define ELF_CLASS ELFCLASS32
1167 # define OS_TYPE "DGUX"
1168 extern int _etext, _end;
1169 extern ptr_t GC_SysVGetDataStart();
1170 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1171 # define DATAEND (&_end)
1172 # define STACK_GROWS_DOWN
1174 # include <unistd.h>
1175 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1176 # define DYNAMIC_LOADING
1179 # endif /* USE_MMAP */
1180 # define MAP_FAILED (void *) -1
1182 # define HEAP_START (ptr_t)0x40000000
1183 # else /* USE_MMAP */
1184 # define HEAP_START DATAEND
1185 # endif /* USE_MMAP */
1190 /* The Intel compiler doesn't like inline assembly */
1191 # define USE_GENERIC_PUSH_REGS
1193 # define OS_TYPE "LINUX"
1194 # define LINUX_STACKBOTTOM
1198 # define STACK_GRAN 0x10000000
1199 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1200 /* different kernel configurations. In particular, systems */
1201 /* with 2GB physical memory will usually move the user */
1202 /* address space limit, and hence initial SP to 0x80000000. */
1204 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1205 # define MPROTECT_VDB
1207 /* We seem to get random errors in incremental mode, */
1208 /* possibly because Linux threads is itself a malloc client */
1209 /* and can't deal with the signals. */
1211 # define HEAP_START (ptr_t)0x1000
1212 /* This encourages mmap to give us low addresses, */
1213 /* thus allowing the heap to grow to ~3GB */
1215 # define DYNAMIC_LOADING
1216 # ifdef UNDEFINED /* includes ro data */
1217 extern int _etext[];
1218 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1220 # include <features.h>
1221 # if defined(__GLIBC__) && __GLIBC__ >= 2
1222 # define SEARCH_FOR_DATA_START
1224 extern char **__environ;
1225 # define DATASTART ((ptr_t)(&__environ))
1226 /* hideous kludge: __environ is the first */
1227 /* word in crt0.o, and delimits the start */
1228 /* of the data segment, no matter which */
1229 /* ld options were passed through. */
1230 /* We could use _etext instead, but that */
1231 /* would include .rodata, which may */
1232 /* contain large read-only data tables */
1233 /* that we'd rather not scan. */
1236 # define DATAEND (_end)
1239 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1241 # ifdef USE_I686_PREFETCH
1242 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1243 /* for the next rtelease. */
1244 # define PREFETCH(x) \
1245 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1246 /* Empirically prefetcht0 is much more effective at reducing */
1247 /* cache miss stalls for the targetted load instructions. But it */
1248 /* seems to interfere enough with other cache traffic that the net */
1249 /* result is worse than prefetchnta. */
1251 /* Using prefetches for write seems to have a slight negative */
1252 /* impact on performance, at least for a PIII/500. */
1253 # define PREFETCH_FOR_WRITE(x) \
1254 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1257 # ifdef USE_3DNOW_PREFETCH
1258 # define PREFETCH(x) \
1259 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1260 # define PREFETCH_FOR_WRITE(x) \
1261 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1265 # define OS_TYPE "CYGWIN32"
1266 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1267 # define DATAEND ((ptr_t)GC_DATAEND)
1269 # define STACK_GRAN 0x10000
1273 # define OS_TYPE "OS2"
1274 /* STACKBOTTOM and DATASTART are handled specially in */
1275 /* os_dep.c. OS2 actually has the right */
1277 # define DATAEND /* not needed */
1278 # define USE_GENERIC_PUSH_REGS
1281 # define OS_TYPE "MSWIN32"
1282 /* STACKBOTTOM and DATASTART are handled specially in */
1284 # ifndef __WATCOMC__
1285 # define MPROTECT_VDB
1287 # define DATAEND /* not needed */
1290 # define OS_TYPE "MSWINCE"
1291 # define DATAEND /* not needed */
1294 # define OS_TYPE "DJGPP"
1295 # include "stubinfo.h"
1298 extern int __djgpp_stack_limit;
1299 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1300 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1302 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1303 /* This may not be right. */
1306 # define OS_TYPE "OPENBSD"
1309 # define OS_TYPE "FREEBSD"
1310 # ifndef GC_FREEBSD_THREADS
1311 # define MPROTECT_VDB
1313 # define SIG_SUSPEND SIGTSTP
1314 # define SIG_THR_RESTART SIGCONT
1315 # define FREEBSD_STACKBOTTOM
1317 # define DYNAMIC_LOADING
1319 extern char etext[];
1320 extern char * GC_FreeBSDGetDataStart();
1321 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1324 # define OS_TYPE "NETBSD"
1326 # define DYNAMIC_LOADING
1330 # define OS_TYPE "THREE86BSD"
1333 # define OS_TYPE "BSDI"
1335 # if defined(OPENBSD) || defined(NETBSD) \
1336 || defined(THREE86BSD) || defined(BSDI)
1338 extern char etext[];
1339 # define DATASTART ((ptr_t)(etext))
1342 # define OS_TYPE "NEXT"
1343 # define DATASTART ((ptr_t) get_etext())
1344 # define STACKBOTTOM ((ptr_t)0xc0000000)
1345 # define DATAEND /* not needed */
1348 # define OS_TYPE "DOS4GW"
1349 extern long __nullarea;
1351 extern char *_STACKTOP;
1352 /* Depending on calling conventions Watcom C either precedes
1353 or does not precedes with undescore names of C-variables.
1354 Make sure startup code variables always have the same names. */
1355 #pragma aux __nullarea "*";
1356 #pragma aux _end "*";
1357 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1358 /* confused? me too. */
1359 # define DATASTART ((ptr_t) &__nullarea)
1360 # define DATAEND ((ptr_t) &_end)
1363 # define OS_TYPE "HURD"
1364 # define STACK_GROWS_DOWN
1366 extern int __data_start[];
1367 # define DATASTART ( (ptr_t) (__data_start))
1369 # define DATAEND ( (ptr_t) (_end))
1370 /* # define MPROTECT_VDB Not quite working yet? */
1371 # define DYNAMIC_LOADING
1376 # define MACH_TYPE "NS32K"
1377 # define ALIGNMENT 4
1378 extern char **environ;
1379 # define DATASTART ((ptr_t)(&environ))
1380 /* hideous kludge: environ is the first */
1381 /* word in crt0.o, and delimits the start */
1382 /* of the data segment, no matter which */
1383 /* ld options were passed through. */
1384 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1388 # define MACH_TYPE "MIPS"
1390 /* This was developed for a linuxce style platform. Probably */
1391 /* needs to be tweaked for workstation class machines. */
1392 # define OS_TYPE "LINUX"
1393 # define DYNAMIC_LOADING
1395 # define DATAEND (_end)
1396 extern int __data_start[];
1397 # define DATASTART ((ptr_t)(__data_start))
1398 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1399 # define ALIGNMENT 8
1400 # define CPP_WORDSZ 64
1402 # define ALIGNMENT 4
1404 # define USE_GENERIC_PUSH_REGS
1405 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1406 # define LINUX_STACKBOTTOM
1408 # define STACKBOTTOM 0x80000000
1413 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1414 extern int _fdata[], _end[];
1415 # define DATASTART ((ptr_t)_fdata)
1416 # define DATAEND ((ptr_t)_end)
1417 # define CPP_WORDSZ _MIPS_SZPTR
1418 # define ALIGNMENT (_MIPS_SZPTR/8)
1420 extern int etext[], edata[], end[];
1421 extern int _DYNAMIC_LINKING[], _gp[];
1422 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1423 + ((word)etext & 0xffff)))
1424 # define DATAEND (edata)
1425 # define DATASTART2 (_DYNAMIC_LINKING \
1426 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1428 # define DATAEND2 (end)
1429 # define ALIGNMENT 4
1431 # define OS_TYPE "EWS4800"
1432 # define USE_GENERIC_PUSH_REGS 1
1436 # define DATASTART (ptr_t)0x10000000
1437 /* Could probably be slightly higher since */
1438 /* startup code allocates lots of stuff. */
1439 # define OS_TYPE "ULTRIX"
1440 # define ALIGNMENT 4
1444 # define DATASTART (ptr_t)0x10000000
1445 # define OS_TYPE "RISCOS"
1446 # define ALIGNMENT 4 /* Required by hardware */
1450 extern int _fdata[];
1451 # define DATASTART ((ptr_t)(_fdata))
1453 # define HEAP_START (ptr_t)0x30000000
1455 # define HEAP_START DATASTART
1457 /* Lowest plausible heap address. */
1458 /* In the MMAP case, we map there. */
1459 /* In either case it is used to identify */
1460 /* heap sections so they're not */
1461 /* considered as roots. */
1462 # define OS_TYPE "IRIX5"
1463 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1464 /* of recent breakage. */
1466 # define CPP_WORDSZ _MIPS_SZPTR
1467 # define ALIGNMENT (_MIPS_SZPTR/8)
1468 # if CPP_WORDSZ != 64
1469 # define ALIGN_DOUBLE
1472 # define ALIGNMENT 4
1473 # define ALIGN_DOUBLE
1475 # define DYNAMIC_LOADING
1478 # define OS_TYPE "MSWINCE"
1479 # define ALIGNMENT 4
1480 # define DATAEND /* not needed */
1482 # if defined(NETBSD)
1483 # define ALIGNMENT 4
1484 # define OS_TYPE "NETBSD"
1486 # define USE_GENERIC_PUSH_REGS
1489 # define DATASTART GC_data_start
1490 # define NEED_FIND_LIMIT
1491 # define DYNAMIC_LOADING
1493 # define DATASTART ((ptr_t) 0x10000000)
1494 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1500 # define MACH_TYPE "RS6000"
1505 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1508 # define ALIGNMENT 8
1509 # define CPP_WORDSZ 64
1510 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1512 # define ALIGNMENT 4
1513 # define CPP_WORDSZ 32
1514 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1517 # define USE_MMAP_ANON
1518 /* From AIX linker man page:
1519 _text Specifies the first location of the program.
1520 _etext Specifies the first location after the program.
1521 _data Specifies the first location of the data.
1522 _edata Specifies the first location after the initialized data
1523 _end or end Specifies the first location after all data.
1525 extern int _data[], _end[];
1526 # define DATASTART ((ptr_t)((ulong)_data))
1527 # define DATAEND ((ptr_t)((ulong)_end))
1529 # define USE_GENERIC_PUSH_REGS
1530 # define DYNAMIC_LOADING
1531 /* For really old versions of AIX, this may have to be removed. */
1535 # define MACH_TYPE "HP_PA"
1537 # define CPP_WORDSZ 64
1538 # define ALIGNMENT 8
1540 # define CPP_WORDSZ 32
1541 # define ALIGNMENT 4
1542 # define ALIGN_DOUBLE
1544 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1545 # ifndef LINUX /* For now. */
1546 # define MPROTECT_VDB
1549 # define GENERIC_COMPARE_AND_SWAP
1550 /* No compare-and-swap instruction. Use pthread mutexes */
1551 /* when we absolutely have to. */
1552 # ifdef PARALLEL_MARK
1553 # define USE_MARK_BYTES
1554 /* Minimize compare-and-swap usage. */
1557 # define STACK_GROWS_UP
1559 # define OS_TYPE "HPUX"
1560 extern int __data_start[];
1561 # define DATASTART ((ptr_t)(__data_start))
1563 /* The following appears to work for 7xx systems running HP/UX */
1564 /* 9.xx Furthermore, it might result in much faster */
1565 /* collections than HEURISTIC2, which may involve scanning */
1566 /* segments that directly precede the stack. It is not the */
1567 /* default, since it may not work on older machine/OS */
1568 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1570 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1572 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1573 /* to this. Note that the GC must be initialized before the */
1574 /* first putenv call. */
1575 extern char ** environ;
1576 # define STACKBOTTOM ((ptr_t)environ)
1578 # define DYNAMIC_LOADING
1579 # include <unistd.h>
1580 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1582 # define PREFETCH(x) { \
1583 register long addr = (long)(x); \
1584 (void) _asm ("LDW", 0, 0, addr, 0); \
1589 # define OS_TYPE "LINUX"
1590 # define LINUX_STACKBOTTOM
1591 # define DYNAMIC_LOADING
1592 # define SEARCH_FOR_DATA_START
1594 # define DATAEND (&_end)
1599 # define MACH_TYPE "ALPHA"
1600 # define ALIGNMENT 8
1601 # define CPP_WORDSZ 64
1603 # define USE_GENERIC_PUSH_REGS
1604 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1605 /* fp registers in some cases when the target is a 21264. The assembly */
1606 /* code doesn't handle that yet, and version dependencies make that a */
1607 /* bit tricky. Do the easy thing for now. */
1610 # define OS_TYPE "NETBSD"
1612 # define DATASTART GC_data_start
1613 # define ELFCLASS32 32
1614 # define ELFCLASS64 64
1615 # define ELF_CLASS ELFCLASS64
1616 # define DYNAMIC_LOADING
1619 # define OS_TYPE "OPENBSD"
1621 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1622 # define DATASTART GC_data_start
1623 # define ELFCLASS32 32
1624 # define ELFCLASS64 64
1625 # define ELF_CLASS ELFCLASS64
1626 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1627 # define DATASTART ((ptr_t) 0x140000000)
1631 # define OS_TYPE "FREEBSD"
1632 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1633 # define SIG_SUSPEND SIGTSTP
1634 # define SIG_THR_RESTART SIGCONT
1635 # define FREEBSD_STACKBOTTOM
1637 # define DYNAMIC_LOADING
1639 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1640 extern char etext[];
1641 extern char edata[];
1643 # define NEED_FIND_LIMIT
1644 # define DATASTART ((ptr_t)(&etext))
1645 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1646 # define DATASTART2 ((ptr_t)(&edata))
1647 # define DATAEND2 ((ptr_t)(&end))
1650 # define OS_TYPE "OSF1"
1651 # define DATASTART ((ptr_t) 0x140000000)
1653 # define DATAEND ((ptr_t) &_end)
1654 extern char ** environ;
1655 /* round up from the value of environ to the nearest page boundary */
1656 /* Probably breaks if putenv is called before collector */
1657 /* initialization. */
1658 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1659 /* # define HEURISTIC2 */
1660 /* Normally HEURISTIC2 is too conervative, since */
1661 /* the text segment immediately follows the stack. */
1662 /* Hence we give an upper pound. */
1663 /* This is currently unused, since we disabled HEURISTIC2 */
1664 extern int __start[];
1665 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1666 # ifndef GC_OSF1_THREADS
1667 /* Unresolved signal issues with threads. */
1668 # define MPROTECT_VDB
1670 # define DYNAMIC_LOADING
1673 # define OS_TYPE "LINUX"
1674 # define LINUX_STACKBOTTOM
1676 # define SEARCH_FOR_DATA_START
1677 # define DYNAMIC_LOADING
1679 # define DATASTART ((ptr_t) 0x140000000)
1682 # define DATAEND (_end)
1683 # define MPROTECT_VDB
1684 /* Has only been superficially tested. May not */
1685 /* work on all versions. */
1690 # define MACH_TYPE "IA64"
1691 # define USE_GENERIC_PUSH_REGS
1692 /* We need to get preserved registers in addition to register */
1693 /* windows. That's easiest to do with setjmp. */
1694 # ifdef PARALLEL_MARK
1695 # define USE_MARK_BYTES
1696 /* Compare-and-exchange is too expensive to use for */
1697 /* setting mark bits. */
1701 # define CPP_WORDSZ 32
1702 # define ALIGN_DOUBLE
1703 /* Requires 8 byte alignment for malloc */
1704 # define ALIGNMENT 4
1709 # define CPP_WORDSZ 64
1710 # define ALIGN_DOUBLE
1711 /* Requires 16 byte alignment for malloc */
1712 # define ALIGNMENT 8
1714 # define OS_TYPE "HPUX"
1715 extern int __data_start[];
1716 # define DATASTART ((ptr_t)(__data_start))
1717 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1718 /* to this. Note that the GC must be initialized before the */
1719 /* first putenv call. */
1720 extern char ** environ;
1721 # define STACKBOTTOM ((ptr_t)environ)
1722 # define HPUX_STACKBOTTOM
1723 # define DYNAMIC_LOADING
1724 # include <unistd.h>
1725 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1726 /* The following was empirically determined, and is probably */
1727 /* not very robust. */
1728 /* Note that the backing store base seems to be at a nice */
1729 /* address minus one page. */
1730 # define BACKING_STORE_DISPLACEMENT 0x1000000
1731 # define BACKING_STORE_ALIGNMENT 0x1000
1732 extern ptr_t GC_register_stackbottom;
1733 # define BACKING_STORE_BASE GC_register_stackbottom
1734 /* Known to be wrong for recent HP/UX versions!!! */
1737 # define CPP_WORDSZ 64
1738 # define ALIGN_DOUBLE
1739 /* Requires 16 byte alignment for malloc */
1740 # define ALIGNMENT 8
1741 # define OS_TYPE "LINUX"
1742 /* The following works on NUE and older kernels: */
1743 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1744 /* This does not work on NUE: */
1745 # define LINUX_STACKBOTTOM
1746 /* We also need the base address of the register stack */
1747 /* backing store. This is computed in */
1748 /* GC_linux_register_stack_base based on the following */
1750 # define BACKING_STORE_ALIGNMENT 0x100000
1751 # define BACKING_STORE_DISPLACEMENT 0x80000000
1752 extern ptr_t GC_register_stackbottom;
1753 # define BACKING_STORE_BASE GC_register_stackbottom
1754 # define SEARCH_FOR_DATA_START
1756 # define DYNAMIC_LOADING
1758 /* In the Intel compiler environment, we seem to end up with */
1759 /* statically linked executables and an undefined reference */
1762 # define MPROTECT_VDB
1763 /* Requires Linux 2.3.47 or later. */
1765 # define DATAEND (_end)
1767 # ifndef __INTEL_COMPILER
1768 # define PREFETCH(x) \
1769 __asm__ (" lfetch [%0]": : "r"(x))
1770 # define PREFETCH_FOR_WRITE(x) \
1771 __asm__ (" lfetch.excl [%0]": : "r"(x))
1772 # define CLEAR_DOUBLE(x) \
1773 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1775 # include <ia64intrin.h>
1776 # define PREFETCH(x) \
1777 __lfetch(__lfhint_none, (x))
1778 # define PREFETCH_FOR_WRITE(x) \
1779 __lfetch(__lfhint_nta, (x))
1780 # define CLEAR_DOUBLE(x) \
1781 __stf_spill((void *)(x), 0)
1782 # endif // __INTEL_COMPILER
1786 /* FIXME: This is a very partial guess. There is no port, yet. */
1787 # define OS_TYPE "MSWIN32"
1788 /* STACKBOTTOM and DATASTART are handled specially in */
1790 # define DATAEND /* not needed */
1791 # if defined(_WIN64)
1792 # define CPP_WORDSZ 64
1794 # define CPP_WORDSZ 32 /* Is this possible? */
1796 # define ALIGNMENT 8
1801 # define MACH_TYPE "M88K"
1802 # define ALIGNMENT 4
1803 # define ALIGN_DOUBLE
1806 # define OS_TYPE "CX_UX"
1807 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1810 # define OS_TYPE "DGUX"
1811 extern ptr_t GC_SysVGetDataStart();
1812 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1814 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1818 /* If this still works, and if anyone cares, this should probably */
1819 /* be moved to the S390 category. */
1820 # define MACH_TYPE "S370"
1821 # define ALIGNMENT 4 /* Required by hardware */
1822 # define USE_GENERIC_PUSH_REGS
1824 # define OS_TYPE "UTS4"
1826 extern int _etext[];
1828 extern ptr_t GC_SysVGetDataStart();
1829 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1830 # define DATAEND (_end)
1836 # define MACH_TYPE "S390"
1837 # define USE_GENERIC_PUSH_REGS
1839 # define ALIGNMENT 4
1840 # define CPP_WORDSZ 32
1842 # define ALIGNMENT 8
1843 # define CPP_WORDSZ 64
1846 # define HBLKSIZE 4096
1849 # define OS_TYPE "LINUX"
1850 # define LINUX_STACKBOTTOM
1851 # define DYNAMIC_LOADING
1852 extern int __data_start[];
1853 # define DATASTART ((ptr_t)(__data_start))
1855 # define DATAEND (_end)
1856 # define CACHE_LINE_SIZE 256
1857 # define GETPAGESIZE() 4096
1862 # define ALIGNMENT 4
1863 extern int _etext[];
1864 # define DATASTART ((ptr_t)(_etext))
1869 # define CPP_WORDSZ 32
1870 # define MACH_TYPE "ARM32"
1871 # define ALIGNMENT 4
1873 # define OS_TYPE "NETBSD"
1876 # define DATASTART GC_data_start
1877 # define DYNAMIC_LOADING
1879 extern char etext[];
1880 # define DATASTART ((ptr_t)(etext))
1882 # define USE_GENERIC_PUSH_REGS
1885 # define OS_TYPE "LINUX"
1886 # define LINUX_STACKBOTTOM
1888 # define STACK_GRAN 0x10000000
1889 # define USE_GENERIC_PUSH_REGS
1891 # define DYNAMIC_LOADING
1892 # include <features.h>
1893 # if defined(__GLIBC__) && __GLIBC__ >= 2
1894 # define SEARCH_FOR_DATA_START
1895 # elif defined(PLATFORM_ANDROID)
1896 # define SEARCH_FOR_DATA_START
1898 extern char **__environ;
1899 # define DATASTART ((ptr_t)(&__environ))
1900 /* hideous kludge: __environ is the first */
1901 /* word in crt0.o, and delimits the start */
1902 /* of the data segment, no matter which */
1903 /* ld options were passed through. */
1904 /* We could use _etext instead, but that */
1905 /* would include .rodata, which may */
1906 /* contain large read-only data tables */
1907 /* that we'd rather not scan. */
1910 # define DATAEND (_end)
1913 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1917 # define OS_TYPE "MSWINCE"
1918 # define DATAEND /* not needed */
1921 # define OS_TYPE "DARWIN"
1922 # define DATASTART ((ptr_t) get_etext())
1923 # define DATAEND ((ptr_t) get_end())
1924 # define STACKBOTTOM ((ptr_t) 0x30000000)
1926 # define USE_MMAP_ANON
1930 /* __data_start is usually defined in the target linker script. */
1931 extern int __data_start[];
1932 # define DATASTART (ptr_t)(__data_start)
1933 # define USE_GENERIC_PUSH_REGS
1934 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1935 extern void *__stack_base__;
1936 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1941 # define MACH_TYPE "CRIS"
1942 # define CPP_WORDSZ 32
1943 # define ALIGNMENT 1
1944 # define OS_TYPE "LINUX"
1945 # define DYNAMIC_LOADING
1946 # define LINUX_STACKBOTTOM
1947 # define USE_GENERIC_PUSH_REGS
1948 # define SEARCH_FOR_DATA_START
1950 # define DATAEND (_end)
1954 # define MACH_TYPE "SH"
1955 # define ALIGNMENT 4
1957 # define OS_TYPE "MSWINCE"
1958 # define DATAEND /* not needed */
1961 # define OS_TYPE "LINUX"
1962 # define LINUX_STACKBOTTOM
1963 # define USE_GENERIC_PUSH_REGS
1964 # define DYNAMIC_LOADING
1965 # define SEARCH_FOR_DATA_START
1967 # define DATAEND (_end)
1970 # define OS_TYPE "NETBSD"
1972 # define DATASTART GC_data_start
1973 # define USE_GENERIC_PUSH_REGS
1974 # define DYNAMIC_LOADING
1979 # define MACH_TYPE "SH4"
1980 # define OS_TYPE "MSWINCE"
1981 # define ALIGNMENT 4
1982 # define DATAEND /* not needed */
1986 # define CPP_WORDSZ 32
1987 # define MACH_TYPE "M32R"
1988 # define ALIGNMENT 4
1990 # define OS_TYPE "LINUX"
1991 # define LINUX_STACKBOTTOM
1993 # define STACK_GRAN 0x10000000
1994 # define USE_GENERIC_PUSH_REGS
1995 # define DYNAMIC_LOADING
1996 # define SEARCH_FOR_DATA_START
1998 # define DATAEND (_end)
2003 # define MACH_TYPE "X86_64"
2004 # define ALIGNMENT 8
2005 # define CPP_WORDSZ 64
2007 # define HBLKSIZE 4096
2009 # define CACHE_LINE_SIZE 64
2010 # define USE_GENERIC_PUSH_REGS
2012 # define OS_TYPE "LINUX"
2013 # define LINUX_STACKBOTTOM
2015 # define FALLBACK_TO_MMAP
2017 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
2018 # define MPROTECT_VDB
2020 /* We seem to get random errors in incremental mode, */
2021 /* possibly because Linux threads is itself a malloc client */
2022 /* and can't deal with the signals. */
2025 # define DYNAMIC_LOADING
2026 # ifdef UNDEFINED /* includes ro data */
2027 extern int _etext[];
2028 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
2030 # include <features.h>
2031 # define SEARCH_FOR_DATA_START
2033 # define DATAEND (_end)
2036 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2038 # if defined(__GNUC__) && __GNUC >= 3
2039 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2040 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2044 # define OS_TYPE "DARWIN"
2045 # define DARWIN_DONT_PARSE_STACK
2046 # define DYNAMIC_LOADING
2047 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
2048 These aren't used when dyld support is enabled (it is by default) */
2049 # define DATASTART ((ptr_t) get_etext())
2050 # define DATAEND ((ptr_t) get_end())
2051 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
2055 # define USE_MMAP_ANON
2056 # ifdef GC_DARWIN_THREADS
2057 # define MPROTECT_VDB
2059 # include <unistd.h>
2060 # define GETPAGESIZE() getpagesize()
2061 /* There seems to be some issues with trylock hanging on darwin. This
2062 should be looked into some more */
2065 # define OS_TYPE "FREEBSD"
2066 # ifndef GC_FREEBSD_THREADS
2067 # define MPROTECT_VDB
2069 # define SIG_SUSPEND SIGTSTP
2070 # define SIG_THR_RESTART SIGCONT
2071 # define NEED_FIND_LIMIT
2072 # define FREEBSD_STACKBOTTOM
2074 # define DYNAMIC_LOADING
2076 extern char etext[];
2077 extern char * GC_FreeBSDGetDataStart();
2078 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2081 # define OS_TYPE "NETBSD"
2083 # define DYNAMIC_LOADING
2086 extern char etext[];
2087 # define SEARCH_FOR_DATA_START
2091 #if defined(LINUX) && defined(USE_MMAP)
2092 /* The kernel may do a somewhat better job merging mappings etc. */
2093 /* with anonymous mappings. */
2094 # define USE_MMAP_ANON
2097 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2098 /* Rld appears to allocate some memory with its own allocator, and */
2099 /* some through malloc, which might be redirected. To make this */
2100 /* work with collectable memory, we have to scan memory allocated */
2101 /* by rld's internal malloc. */
2102 # define USE_PROC_FOR_LIBRARIES
2105 # ifndef STACK_GROWS_UP
2106 # define STACK_GROWS_DOWN
2110 # define CPP_WORDSZ 32
2119 # define DATAEND (end)
2122 # if defined(SVR4) && !defined(GETPAGESIZE)
2123 # include <unistd.h>
2124 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2127 # ifndef GETPAGESIZE
2128 # if defined(SUNOS5) || defined(IRIX5)
2129 # include <unistd.h>
2131 # define GETPAGESIZE() getpagesize()
2134 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2135 /* OS has SVR4 generic features. Probably others also qualify. */
2139 # if defined(SUNOS5) || defined(DRSNX)
2140 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2143 /* OS has SUNOS5 style signal handlers. */
2151 # if defined(FREEBSD) && (__FreeBSD__ >= 4)
2155 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2156 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2157 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2158 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2159 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2162 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2167 # undef DYNAMIC_LOADING
2172 # undef MPROTECT_VDB
2177 /* Postponed for now. */
2179 # undef MPROTECT_VDB
2182 # ifdef SMALL_CONFIG
2183 /* Presumably not worth the space it takes. */
2185 # undef MPROTECT_VDB
2189 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2192 # ifdef PARALLEL_MARK
2193 # undef MPROTECT_VDB /* For now. */
2196 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2197 # define DEFAULT_VDB
2201 # define PREFETCH(x)
2202 # define NO_PREFETCH
2205 # ifndef PREFETCH_FOR_WRITE
2206 # define PREFETCH_FOR_WRITE(x)
2207 # define NO_PREFETCH_FOR_WRITE
2210 # ifndef CACHE_LINE_SIZE
2211 # define CACHE_LINE_SIZE 32 /* Wild guess */
2215 # define REGISTER_LIBRARIES_EARLY
2216 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2217 /* lock. This isn't safe after the world has stopped. So we must */
2218 /* call GC_register_dynamic_libraries before stopping the world. */
2219 /* For performance reasons, this may be beneficial on other */
2220 /* platforms as well, though it should be avoided in win32. */
2223 # if defined(SEARCH_FOR_DATA_START)
2224 extern ptr_t GC_data_start;
2225 # define DATASTART GC_data_start
2228 # ifndef CLEAR_DOUBLE
2229 # define CLEAR_DOUBLE(x) \
2230 ((word*)x)[0] = 0; \
2232 # endif /* CLEAR_DOUBLE */
2234 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2235 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2236 # define GC_SOLARIS_THREADS
2239 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2240 --> inconsistent configuration
2242 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
2243 --> inconsistent configuration
2245 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2246 --> inconsistent configuration
2248 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2249 --> inconsistent configuration
2251 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2252 --> inconsistent configuration
2254 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2255 --> inconsistent configuration
2258 # if defined(PCR) || defined(SRC_M3) || \
2259 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2260 defined(GC_PTHREADS) || defined(SN_TARGET_PS3)
2264 # if defined(HP_PA) || defined(M88K) \
2265 || defined(POWERPC) && !defined(DARWIN) \
2266 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2267 || (defined(I386) && defined(__LCC__))
2268 /* Use setjmp based hack to mark from callee-save registers. */
2269 /* The define should move to the individual platform */
2271 # define USE_GENERIC_PUSH_REGS
2274 # if defined(MSWINCE)
2279 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2280 /* include assembly code to do it well. */
2283 /* Can we save call chain in objects for debugging? */
2284 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2285 /* frame) to reasonable values for the platform. */
2286 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2287 /* at build time, though we feel free to adjust it slightly. */
2288 /* Define NEED_CALLINFO if we either save the call stack or */
2289 /* GC_ADD_CALLER is defined. */
2290 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2293 # define CAN_SAVE_CALL_ARGS
2295 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
2296 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2297 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2298 # define CAN_SAVE_CALL_ARGS
2301 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2302 && defined(GC_CAN_SAVE_CALL_STACKS)
2303 # define SAVE_CALL_CHAIN
2305 # ifdef SAVE_CALL_CHAIN
2306 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2307 # define NARGS SAVE_CALL_NARGS
2309 # define NARGS 0 /* Number of arguments to save for each call. */
2312 # ifdef SAVE_CALL_CHAIN
2313 # ifndef SAVE_CALL_COUNT
2314 # define NFRAMES 6 /* Number of frames to save. Even for */
2315 /* alignment reasons. */
2317 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2319 # define NEED_CALLINFO
2320 # endif /* SAVE_CALL_CHAIN */
2321 # ifdef GC_ADD_CALLER
2324 # define NEED_CALLINFO
2327 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2328 # define DBG_HDRS_ALL
2331 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2332 # define POINTER_SHIFT 0
2335 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2336 # define POINTER_MASK ((GC_word)(-1))
2339 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2340 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2343 # if defined(FIXUP_POINTER)
2344 # define NEED_FIXUP_POINTER 1
2346 # define NEED_FIXUP_POINTER 0
2347 # define FIXUP_POINTER(p)
2351 /* This relies on some type definitions from gc_priv.h, from */
2352 /* where it's normally included. */
2354 /* How to get heap memory from the OS: */
2355 /* Note that sbrk()-like allocation is preferred, since it */
2356 /* usually makes it possible to merge consecutively allocated */
2357 /* chunks. It also avoids unintented recursion with */
2358 /* -DREDIRECT_MALLOC. */
2359 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2360 /* 0 is taken to mean failure. */
2361 /* In the case os USE_MMAP, the argument must also be a */
2362 /* physical page size. */
2363 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2364 /* though we should perhaps take advantage of the case in which */
2366 struct hblk; /* See gc_priv.h. */
2368 char * real_malloc();
2369 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2373 void * os2_alloc(size_t bytes);
2374 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2378 # if defined(NEXT) || defined(DOS4GW) || \
2379 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2380 (defined(SUNOS5) && !defined(USE_MMAP))
2381 # define GET_MEM(bytes) HBLKPTR((size_t) \
2382 calloc(1, (size_t)bytes + GC_page_size) \
2386 extern ptr_t GC_win32_get_mem();
2387 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2390 # if defined(USE_TEMPORARY_MEMORY)
2391 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2392 Boolean clearMemory);
2393 # define GET_MEM(bytes) HBLKPTR( \
2394 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2397 # define GET_MEM(bytes) HBLKPTR( \
2398 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2402 extern ptr_t GC_wince_get_mem();
2403 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2405 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2406 extern void *GC_amiga_get_mem(size_t size);
2407 # define GET_MEM(bytes) HBLKPTR((size_t) \
2408 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2411 # if defined(SN_TARGET_PS3)
2412 extern void *ps3_get_mem (size_t size);
2413 # define GET_MEM(bytes) (struct hblk*) ps3_get_mem (bytes)
2415 extern ptr_t GC_unix_get_mem();
2416 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2426 #endif /* GC_PRIVATE_H */
2428 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2429 /* IBMs xlc compiler doesn't appear to follow the convention of */
2430 /* defining __STDC__ to be zero in extended mode. */
2434 # endif /* GCCONFIG_H */