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;
33 # include <stddef.h> /* For size_t etc. */
36 /* Machine dependent parameters. Some tuning parameters can be found */
37 /* near the top of gc_private.h. */
39 /* Machine specific parts contributed by various people. See README file. */
41 /* First a unified test for Linux: */
42 # if defined(linux) || defined(__linux__)
48 /* And one for NetBSD: */
49 # if defined(__NetBSD__)
53 /* And one for OpenBSD: */
54 # if defined(__OpenBSD__)
58 /* And one for FreeBSD: */
59 # if (defined(__FreeBSD__) || defined(__DragonFly__) || \
60 defined(__FreeBSD_kernel__)) && !defined(FREEBSD)
64 /* And one for Darwin: */
65 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
69 /* Determine the machine type: */
70 # if defined(__arm__) || defined(__thumb__)
72 # if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN)
74 # define mach_type_known
77 # if defined(sun) && defined(mc68000)
78 # error SUNOS4 no longer supported
80 # if defined(hp9000s300)
81 # error M68K based HP machines no longer supported.
83 # if defined(OPENBSD) && defined(m68k)
85 # define mach_type_known
87 # if defined(OPENBSD) && defined(__sparc__)
89 # define mach_type_known
91 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
93 # define mach_type_known
95 # if defined(NETBSD) && defined(__powerpc__)
97 # define mach_type_known
99 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
101 # define mach_type_known
103 # if defined(NETBSD) && defined(__sh__)
105 # define mach_type_known
114 # define mach_type_known
116 # if defined(__NetBSD__) && defined(__vax__)
118 # define mach_type_known
120 # if defined(mips) || defined(__mips) || defined(_mips)
122 # if defined(nec_ews) || defined(_nec_ews)
125 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
126 # if defined(ultrix) || defined(__ultrix)
129 # define IRIX5 /* or IRIX 6.X */
132 # if defined(__NetBSD__) && defined(__MIPSEL__)
135 # define mach_type_known
137 # if defined(DGUX) && (defined(i386) || defined(__i386__))
142 # define mach_type_known
144 # if defined(sequent) && (defined(i386) || defined(__i386__))
147 # define mach_type_known
149 # if defined(sun) && (defined(i386) || defined(__i386__))
152 # define mach_type_known
154 # if defined(sun) && defined(__amd64)
157 # define mach_type_known
159 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
162 # define mach_type_known
165 # error IBM PC/RT no longer supported.
167 # if defined(sun) && (defined(sparc) || defined(__sparc))
169 /* Test for SunOS 5.x */
172 # define mach_type_known
174 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
175 && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) \
176 && !defined(__DragonFly__)
179 # define mach_type_known
184 # define mach_type_known
186 # if defined(__NetBSD__) && defined(__sparc__)
188 # define mach_type_known
190 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
191 /* The above test may need refinement */
193 # if defined(_SCO_ELF)
198 # define mach_type_known
200 # if defined(_AUX_SOURCE)
201 # error A/UX no longer supported
203 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
204 || defined(hppa) || defined(__hppa__)
206 # if !defined(LINUX) && !defined(HPUX)
209 # define mach_type_known
211 # if defined(__ia64) && (defined(_HPUX_SOURCE) || defined(__HP_aCC))
216 # define mach_type_known
218 # if defined(__BEOS__) && defined(_X86_)
221 # define mach_type_known
223 # if defined(LINUX) && (defined(i386) || defined(__i386__))
225 # define mach_type_known
227 # if defined(LINUX) && defined(__x86_64__)
229 # define mach_type_known
231 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
233 # define mach_type_known
235 # if defined(LINUX) && defined(__arm__)
237 # define mach_type_known
239 # if defined(LINUX) && defined(__cris__)
243 # define mach_type_known
245 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
246 defined(powerpc64) || defined(__powerpc64__))
248 # define mach_type_known
250 # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
252 # define mach_type_known
254 # if defined(LINUX) && defined(__mc68000__)
256 # define mach_type_known
258 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
260 # define mach_type_known
262 # if defined(LINUX) && defined(__arm__)
264 # define mach_type_known
266 # if defined(LINUX) && defined(__sh__)
268 # define mach_type_known
270 # if defined(LINUX) && defined(__m32r__)
272 # define mach_type_known
274 # if defined(__alpha) || defined(__alpha__)
276 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
277 # define OSF1 /* a.k.a Digital Unix */
279 # define mach_type_known
281 # if defined(_AMIGA) && !defined(AMIGA)
286 # define mach_type_known
288 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
291 # define mach_type_known
293 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
296 # define mach_type_known
299 # if defined(__ppc__) || defined(__ppc64__)
301 # define mach_type_known
302 # elif defined(__x86_64__)
304 # define mach_type_known
305 # elif defined(__i386__)
307 # define mach_type_known
308 # elif defined(__arm__)
310 # define mach_type_known
311 # define DARWIN_DONT_PARSE_STACK
314 # if defined(NeXT) && defined(mc68000)
317 # define mach_type_known
319 # if defined(NeXT) && (defined(i386) || defined(__i386__))
322 # define mach_type_known
324 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
327 # define mach_type_known
329 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
331 # define mach_type_known
333 # if defined(FREEBSD) && defined(__x86_64__)
335 # define mach_type_known
337 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
339 # define mach_type_known
341 # if defined(__NetBSD__) && defined(__x86_64__)
343 # define mach_type_known
345 # if defined(FREEBSD) && defined(__sparc__)
347 # define mach_type_known
349 # if defined(bsdi) && (defined(i386) || defined(__i386__))
352 # define mach_type_known
354 # if !defined(mach_type_known) && defined(__386BSD__)
357 # define mach_type_known
359 # if defined(_CX_UX) && defined(_M88K)
362 # define mach_type_known
364 # if defined(DGUX) && defined(m88k)
367 # define mach_type_known
369 # if defined(_WIN32_WCE)
370 /* SH3, SH4, MIPS already defined for corresponding architectures */
371 # if defined(SH3) || defined(SH4)
381 # define mach_type_known
383 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
384 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
385 # if defined(__LP64__) || defined(_WIN64)
390 # define MSWIN32 /* or Win64 */
391 # define mach_type_known
393 # if defined(_MSC_VER) && defined(_M_IA64)
395 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
396 /* variants as a different platform. */
399 # if defined(__DJGPP__)
402 # define DJGPP /* MSDOS running the DJGPP port of GCC */
404 # define mach_type_known
406 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
409 # define mach_type_known
411 # if defined(__MINGW32__) && !defined(mach_type_known)
414 # define mach_type_known
416 # if defined(__BORLANDC__)
419 # define mach_type_known
421 # if defined(_UTS) && !defined(mach_type_known)
424 # define mach_type_known
427 # error PicoJava no longer supported
428 /* The implementation had problems, and I haven't heard of users */
429 /* in ages. If you want it resurrected, let me know. */
431 # if defined(__embedded__) && defined(PPC)
434 # define mach_type_known
437 # if defined(__WATCOMC__) && defined(__386__)
439 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
440 # if defined(__OS2__)
443 # if defined(__WINDOWS_386__) || defined(__NT__)
450 # define mach_type_known
452 # if defined(__s390__) && defined(LINUX)
454 # define mach_type_known
456 # if defined(__GNU__)
457 # if defined(__i386__)
458 /* The Debian Hurd running on generic PC */
461 # define mach_type_known
464 # if defined(__TANDEM)
465 /* Nonstop S-series */
466 /* FIXME: Should recognize Integrity series? */
469 # define mach_type_known
472 /* Feel free to add more clauses here */
474 /* Or manually define the machine type here. A machine type is */
475 /* characterized by the architecture. Some */
476 /* machine types are further subdivided by OS. */
477 /* Macros such as LINUX, FREEBSD, etc. distinguish them. */
478 /* SYSV on an M68K actually means A/UX. */
479 /* The distinction in these cases is usually the stack starting address */
480 # ifndef mach_type_known
481 # error "The collector has not been ported to this machine/OS combination."
483 /* Mapping is: M68K ==> Motorola 680X0 */
484 /* (NEXT, and SYSV (A/UX), */
485 /* MACOS and AMIGA variants) */
486 /* I386 ==> Intel 386 */
487 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
488 /* FREEBSD, THREE86BSD, MSWIN32, */
489 /* BSDI,SOLARIS, NEXT, other variants) */
490 /* NS32K ==> Encore Multimax */
491 /* MIPS ==> R2000 through R14K */
492 /* (many variants) */
493 /* VAX ==> DEC VAX */
494 /* (BSD, ULTRIX variants) */
495 /* HP_PA ==> HP9000/700 & /800 */
497 /* SPARC ==> SPARC v7/v8/v9 */
498 /* (SOLARIS, LINUX, DRSNX variants) */
499 /* ALPHA ==> DEC Alpha */
500 /* (OSF1 and LINUX variants) */
501 /* M88K ==> Motorola 88XX0 */
502 /* (CX_UX and DGUX) */
503 /* S370 ==> 370-like machine */
504 /* running Amdahl UTS4 */
505 /* S390 ==> 390-like machine */
507 /* ARM32 ==> Intel StrongARM */
508 /* IA64 ==> Intel IPF */
510 /* (LINUX and HPUX) */
511 /* SH ==> Hitachi SuperH */
512 /* (LINUX & MSWINCE) */
513 /* X86_64 ==> AMD x86-64 */
514 /* POWERPC ==> IBM/Apple PowerPC */
515 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
516 /* LINUX, NETBSD, AIX, NOSYS */
518 /* Handles 32 and 64-bit variants. */
519 /* CRIS ==> Axis Etrax */
520 /* M32R ==> Renesas M32R */
524 * For each architecture and OS, the following need to be defined:
526 * CPP_WORDSZ is a simple integer constant representing the word size.
527 * in bits. We assume byte addressability, where a byte has 8 bits.
528 * We also assume CPP_WORDSZ is either 32 or 64.
529 * (We care about the length of pointers, not hardware
530 * bus widths. Thus a 64 bit processor with a C compiler that uses
531 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
533 * MACH_TYPE is a string representation of the machine type.
534 * OS_TYPE is analogous for the OS.
536 * ALIGNMENT is the largest N, such that
537 * all pointer are guaranteed to be aligned on N byte boundaries.
538 * defining it to be 1 will always work, but perform poorly.
540 * DATASTART is the beginning of the data segment.
541 * On some platforms SEARCH_FOR_DATA_START is defined.
542 * SEARCH_FOR_DATASTART will cause GC_data_start to
543 * be set to an address determined by accessing data backwards from _end
544 * until an unmapped page is found. DATASTART will be defined to be
546 * On UNIX-like systems, the collector will scan the area between DATASTART
547 * and DATAEND for root pointers.
549 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
550 * RTH suggests gaining access to linker script synth'd values with
551 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
552 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
553 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
554 * without any special options.
556 * STACKBOTTOM is the cool end of the stack, which is usually the
557 * highest address in the stack.
558 * Under PCR or OS/2, we have other ways of finding thread stacks.
559 * For each machine, the following should:
560 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
561 * 2) define exactly one of
562 * STACKBOTTOM (should be defined to be an expression)
566 * If STACKBOTTOM is defined, then it's value will be used directly as the
567 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
568 * with a method appropriate for most Linux systems. Currently we look
569 * first for __libc_stack_end (currently only id USE_LIBC_PRIVATES is
570 * defined), and if that fails read it from /proc. (If USE_LIBC_PRIVATES
571 * is not defined and NO_PROC_STAT is defined, we revert to HEURISTIC2.)
572 * If either of the last two macros are defined, then STACKBOTTOM is computed
573 * during collector startup using one of the following two heuristics:
574 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
575 * the next multiple of STACK_GRAN.
576 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
577 * in small steps (decrement if STACK_GROWS_UP), and read the value
578 * at each location. Remember the value when the first
579 * Segmentation violation or Bus error is signaled. Round that
580 * to the nearest plausible page boundary, and use that instead
583 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
584 * the value of environ is a pointer that can serve as STACKBOTTOM.
585 * I expect that HEURISTIC2 can be replaced by this approach, which
586 * interferes far less with debugging. However it has the disadvantage
587 * that it's confused by a putenv call before the collector is initialized.
588 * This could be dealt with by intercepting putenv ...
590 * If no expression for STACKBOTTOM can be found, and neither of the above
591 * heuristics are usable, the collector can still be used with all of the above
592 * undefined, provided one of the following is done:
593 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
594 * without reference to STACKBOTTOM. This is appropriate for use in
595 * conjunction with thread packages, since there will be multiple stacks.
596 * (Allocating thread stacks in the heap, and treating them as ordinary
597 * heap data objects is also possible as a last resort. However, this is
598 * likely to introduce significant amounts of excess storage retention
599 * unless the dead parts of the thread stacks are periodically cleared.)
600 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
601 * If the author of the client code controls the main program, this is
602 * easily accomplished by introducing a new main program, setting
603 * GC_stackbottom to the address of a local variable, and then calling
604 * the original main program. The new main program would read something
605 * like (provided real_main() is not inlined by the compiler):
607 * # include "gc_private.h"
609 * main(argc, argv, envp)
611 * char **argv, **envp;
615 * GC_stackbottom = (ptr_t)(&dummy);
616 * return(real_main(argc, argv, envp));
620 * Each architecture may also define the style of virtual dirty bit
621 * implementation to be used:
622 * MPROTECT_VDB: Write protect the heap and catch faults.
623 * GWW_VDB: Use win32 GetWriteWatch primitive.
624 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
626 * The first and second one may be combined, in which case a runtime
627 * selection will be made, based on GetWriteWatch availability.
629 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
630 * defined GC_register_dynamic_libraries() for the architecture.
632 * An architecture may define PREFETCH(x) to preload the cache with *x.
633 * This defaults to a no-op.
635 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
637 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
638 * clear the two words at GC_malloc-aligned address x. By default,
639 * word stores of 0 are used instead.
641 * HEAP_START may be defined as the initial address hint for mmap-based
645 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
646 * to push the relevant registers onto the stack.
648 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
649 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
650 && !defined(__INTEL_COMPILER) && !defined(__PATHCC__)
651 # define HAVE_BUILTIN_UNWIND_INIT
654 # define STACK_GRAN 0x1000000
656 # define MACH_TYPE "M68K"
659 # define OS_TYPE "OPENBSD"
662 # define DATASTART GC_data_start
663 # define DYNAMIC_LOADING
666 # define DATASTART ((ptr_t)(etext))
670 # define OS_TYPE "NETBSD"
673 # define DATASTART GC_data_start
674 # define DYNAMIC_LOADING
677 # define DATASTART ((ptr_t)(etext))
681 # define OS_TYPE "LINUX"
682 # define LINUX_STACKBOTTOM
683 # define MPROTECT_VDB
685 # define DYNAMIC_LOADING
686 # include <features.h>
687 # if defined(__GLIBC__)&& __GLIBC__>=2
688 # define SEARCH_FOR_DATA_START
690 extern char **__environ;
691 # define DATASTART ((ptr_t)(&__environ))
692 /* hideous kludge: __environ is the first */
693 /* word in crt0.o, and delimits the start */
694 /* of the data segment, no matter which */
695 /* ld options were passed through. */
696 /* We could use _etext instead, but that */
697 /* would include .rodata, which may */
698 /* contain large read-only data tables */
699 /* that we'd rather not scan. */
700 # endif /* !GLIBC2 */
702 # define DATAEND (ptr_t)(_end)
705 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
709 # define OS_TYPE "AMIGA"
710 /* STACKBOTTOM and DATASTART handled specially */
712 # define DATAEND /* not needed */
713 # define GETPAGESIZE() 4096
719 # define OS_TYPE "MACOS"
720 /* see os_dep.c for details of global data segments. */
721 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
722 # define DATAEND /* not needed */
723 # define GETPAGESIZE() 4096
726 # define OS_TYPE "NEXT"
727 # define DATASTART ((ptr_t) get_etext())
728 # define STACKBOTTOM ((ptr_t) 0x4000000)
729 # define DATAEND /* not needed */
733 # if defined(POWERPC)
734 # define MACH_TYPE "POWERPC"
736 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
740 # define OS_TYPE "MACOS"
741 /* see os_dep.c for details of global data segments. */
742 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
743 # define DATAEND /* not needed */
746 # if defined(__powerpc64__)
748 # define CPP_WORDSZ 64
750 # define HBLKSIZE 4096
755 # define OS_TYPE "LINUX"
756 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
757 /* executable on a 64 bit kernel. */
758 # define LINUX_STACKBOTTOM
759 # define DYNAMIC_LOADING
760 # define SEARCH_FOR_DATA_START
762 # define DATAEND (ptr_t)(_end)
765 # define OS_TYPE "DARWIN"
766 # define DYNAMIC_LOADING
767 # if defined(__ppc64__)
769 # define CPP_WORDSZ 64
770 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
771 # define CACHE_LINE_SIZE 64
773 # define HBLKSIZE 4096
777 # define STACKBOTTOM ((ptr_t) 0xc0000000)
779 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
780 These aren't used when dyld support is enabled (it is by default) */
781 # define DATASTART ((ptr_t) get_etext())
782 # define DATAEND ((ptr_t) get_end())
784 # define USE_MMAP_ANON
785 # ifdef GC_DARWIN_THREADS
786 # define MPROTECT_VDB
789 # define GETPAGESIZE() getpagesize()
790 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
791 /* The performance impact of prefetches is untested */
792 # define PREFETCH(x) \
793 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
794 # define PREFETCH_FOR_WRITE(x) \
795 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
797 /* There seems to be some issues with trylock hanging on darwin. This
798 should be looked into some more */
799 # define NO_PTHREAD_TRYLOCK
803 # define OS_TYPE "FREEBSD"
804 # ifndef GC_FREEBSD_THREADS
805 # define MPROTECT_VDB
807 # define SIG_SUSPEND SIGUSR1
808 # define SIG_THR_RESTART SIGUSR2
809 # define FREEBSD_STACKBOTTOM
811 # define DYNAMIC_LOADING
814 ptr_t GC_FreeBSDGetDataStart(size_t max_page_size, ptr_t etext_addr);
815 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
819 # define OS_TYPE "NETBSD"
822 # define DATASTART GC_data_start
823 # define DYNAMIC_LOADING
826 # define OS_TYPE "AIX"
827 # undef ALIGNMENT /* in case it's defined */
830 /* DOB: some AIX installs stupidly define IA64 in */
831 /* /usr/include/sys/systemcfg.h */
835 # define CPP_WORDSZ 64
836 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
839 # define CPP_WORDSZ 32
840 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
843 # define USE_MMAP_ANON
844 /* From AIX linker man page:
845 _text Specifies the first location of the program.
846 _etext Specifies the first location after the program.
847 _data Specifies the first location of the data.
848 _edata Specifies the first location after the initialized data
849 _end or end Specifies the first location after all data.
851 extern int _data[], _end[];
852 # define DATASTART ((ptr_t)((ulong)_data))
853 # define DATAEND ((ptr_t)((ulong)_end))
855 # define DYNAMIC_LOADING
856 /* For really old versions of AIX, this may have to be removed. */
861 # define OS_TYPE "NOSYS"
862 extern void __end[], __dso_handle[];
863 # define DATASTART (__dso_handle) /* OK, that's ugly. */
864 # define DATAEND (ptr_t)(__end)
865 /* Stack starts at 0xE0000000 for the simulator. */
867 # define STACK_GRAN 0x10000000
873 # define MACH_TYPE "VAX"
874 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
876 # define DATASTART ((ptr_t)(etext))
878 # define OS_TYPE "BSD"
880 /* HEURISTIC2 may be OK, but it's hard to test. */
883 # define OS_TYPE "ULTRIX"
884 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
889 # define MACH_TYPE "SPARC"
890 # if defined(__arch64__) || defined(__sparcv9)
892 # define CPP_WORDSZ 64
893 # define ELF_CLASS ELFCLASS64
895 # define ALIGNMENT 4 /* Required by hardware */
896 # define CPP_WORDSZ 32
898 /* Don't define USE_ASM_PUSH_REGS. We do use an asm helper, but */
899 /* not to push the registers on the mark stack. */
901 # define OS_TYPE "SOLARIS"
904 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
905 # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
906 # define DATAEND (ptr_t)(_end)
907 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
909 /* Otherwise we now use calloc. Mmap may result in the */
910 /* heap interleaved with thread stacks, which can result in */
911 /* excessive blacklisting. Sbrk is unusable since it */
912 /* doesn't interact correctly with the system malloc. */
915 # define HEAP_START (ptr_t)0x40000000
917 # define HEAP_START DATAEND
920 /* HEURISTIC1 reportedly no longer works under 2.7. */
921 /* HEURISTIC2 probably works, but this appears to be preferable. */
922 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
923 /* installations that's undefined. We work around this with a */
925 # include <sys/vmparam.h>
927 /* This should work everywhere, but doesn't. */
928 # define STACKBOTTOM ((ptr_t) USRSTACK)
933 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
934 /* getpagesize() appeared to be missing from at least one */
935 /* Solaris 5.4 installation. Weird. */
936 # define DYNAMIC_LOADING
939 # define OS_TYPE "DRSNX"
940 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
942 # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
943 # define MPROTECT_VDB
944 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
945 # define DYNAMIC_LOADING
948 # define OS_TYPE "LINUX"
950 # define DYNAMIC_LOADING
952 Linux Sparc/a.out not supported
956 # define DATAEND (ptr_t)(_end)
958 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
960 # define DATASTART GC_SysVGetDataStart(0x100000, (ptr_t)_etext)
962 # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
964 # define LINUX_STACKBOTTOM
967 # define OS_TYPE "OPENBSD"
968 # define STACKBOTTOM ((ptr_t) 0xf8000000)
970 # define DATASTART ((ptr_t)(etext))
973 # define OS_TYPE "NETBSD"
976 # define DATASTART GC_data_start
977 # define DYNAMIC_LOADING
980 # define DATASTART ((ptr_t)(etext))
984 # define OS_TYPE "FREEBSD"
985 # define SIG_SUSPEND SIGUSR1
986 # define SIG_THR_RESTART SIGUSR2
987 # define FREEBSD_STACKBOTTOM
989 # define DYNAMIC_LOADING
994 # define NEED_FIND_LIMIT
995 # define DATASTART ((ptr_t)(&etext))
996 # define DATAEND (GC_find_limit (DATASTART, TRUE))
997 # define DATASTART2 ((ptr_t)(&edata))
998 # define DATAEND2 ((ptr_t)(&end))
1003 # define MACH_TYPE "I386"
1004 # if defined(__LP64__) || defined(_WIN64)
1005 # error This should be handled as X86_64
1007 # define CPP_WORDSZ 32
1008 # define ALIGNMENT 4
1009 /* Appears to hold for all "32 bit" compilers */
1010 /* except Borland. The -a4 option fixes */
1012 /* Ivan Demakov: For Watcom the option is -zp4. */
1015 # define OS_TYPE "SEQUENT"
1017 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1018 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1021 # define OS_TYPE "BEOS"
1023 # define GETPAGESIZE() B_PAGE_SIZE
1025 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1028 # define OS_TYPE "SOLARIS"
1029 extern int _etext[], _end[];
1030 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
1031 # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
1032 # define DATAEND (ptr_t)(_end)
1033 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1034 /* but reportedly breaks under 2.8. It appears that the stack */
1035 /* base is a property of the executable, so this should not break */
1036 /* old executables. */
1037 /* HEURISTIC2 probably works, but this appears to be preferable. */
1038 # include <sys/vm.h>
1039 # define STACKBOTTOM ((ptr_t) USRSTACK)
1040 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1041 /* It appears to be fixed in 2.8 and 2.9. */
1042 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1045 # define DYNAMIC_LOADING
1046 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1048 /* Otherwise we now use calloc. Mmap may result in the */
1049 /* heap interleaved with thread stacks, which can result in */
1050 /* excessive blacklisting. Sbrk is unusable since it */
1051 /* doesn't interact correctly with the system malloc. */
1054 # define HEAP_START (ptr_t)0x40000000
1056 # define HEAP_START DATAEND
1060 # define OS_TYPE "SCO"
1062 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1064 +((word)etext & 0xfff))
1065 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1068 # define OS_TYPE "SCO_ELF"
1070 # define DATASTART ((ptr_t)(etext))
1071 # define STACKBOTTOM ((ptr_t) 0x08048000)
1072 # define DYNAMIC_LOADING
1073 # define ELF_CLASS ELFCLASS32
1076 # define OS_TYPE "DGUX"
1077 extern int _etext, _end;
1078 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
1079 # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)(&_etext))
1080 # define DATAEND (ptr_t)(&_end)
1081 # define STACK_GROWS_DOWN
1083 # include <unistd.h>
1084 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1085 # define DYNAMIC_LOADING
1088 # endif /* USE_MMAP */
1089 # define MAP_FAILED (void *) ((word)-1)
1091 # define HEAP_START (ptr_t)0x40000000
1092 # else /* USE_MMAP */
1093 # define HEAP_START DATAEND
1094 # endif /* USE_MMAP */
1098 # define OS_TYPE "LINUX"
1099 # define LINUX_STACKBOTTOM
1103 # define STACK_GRAN 0x10000000
1104 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1105 /* different kernel configurations. In particular, systems */
1106 /* with 2GB physical memory will usually move the user */
1107 /* address space limit, and hence initial SP to 0x80000000. */
1109 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1110 # define MPROTECT_VDB
1112 /* We seem to get random errors in incremental mode, */
1113 /* possibly because Linux threads is itself a malloc client */
1114 /* and can't deal with the signals. */
1116 # define HEAP_START (ptr_t)0x1000
1117 /* This encourages mmap to give us low addresses, */
1118 /* thus allowing the heap to grow to ~3GB */
1120 # define DYNAMIC_LOADING
1121 # ifdef UNDEFINED /* includes ro data */
1122 extern int _etext[];
1123 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1125 # include <features.h>
1126 # if defined(__GLIBC__) && __GLIBC__ >= 2
1127 # define SEARCH_FOR_DATA_START
1129 extern char **__environ;
1130 # define DATASTART ((ptr_t)(&__environ))
1131 /* hideous kludge: __environ is the first */
1132 /* word in crt0.o, and delimits the start */
1133 /* of the data segment, no matter which */
1134 /* ld options were passed through. */
1135 /* We could use _etext instead, but that */
1136 /* would include .rodata, which may */
1137 /* contain large read-only data tables */
1138 /* that we'd rather not scan. */
1141 # define DATAEND (ptr_t)(_end)
1144 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1146 # ifdef USE_I686_PREFETCH
1147 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1148 /* for the next rtelease. */
1149 # define PREFETCH(x) \
1150 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1151 /* Empirically prefetcht0 is much more effective at reducing */
1152 /* cache miss stalls for the targeted load instructions. But it */
1153 /* seems to interfere enough with other cache traffic that the net */
1154 /* result is worse than prefetchnta. */
1156 /* Using prefetches for write seems to have a slight negative */
1157 /* impact on performance, at least for a PIII/500. */
1158 # define PREFETCH_FOR_WRITE(x) \
1159 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1162 # ifdef USE_3DNOW_PREFETCH
1163 # define PREFETCH(x) \
1164 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1165 # define PREFETCH_FOR_WRITE(x) \
1166 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1170 # define OS_TYPE "CYGWIN32"
1171 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1172 # define DATAEND ((ptr_t)GC_DATAEND)
1174 # define STACK_GRAN 0x10000
1177 # define NEED_FIND_LIMIT
1178 # define USE_MMAP_ANON
1182 # define OS_TYPE "OS2"
1183 /* STACKBOTTOM and DATASTART are handled specially in */
1184 /* os_dep.c. OS2 actually has the right */
1186 # define DATAEND /* not needed */
1189 # define OS_TYPE "MSWIN32"
1190 /* STACKBOTTOM and DATASTART are handled specially in */
1192 # define MPROTECT_VDB
1194 # define DATAEND /* not needed */
1197 # define OS_TYPE "MSWINCE"
1198 # define DATAEND /* not needed */
1201 # define OS_TYPE "DJGPP"
1202 # include "stubinfo.h"
1205 extern int __djgpp_stack_limit;
1206 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1207 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1209 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1210 /* This may not be right. */
1213 # define OS_TYPE "OPENBSD"
1216 # define OS_TYPE "FREEBSD"
1217 # ifndef GC_FREEBSD_THREADS
1218 # define MPROTECT_VDB
1221 # define SIG_SUSPEND (32+6)
1222 # define SIG_THR_RESTART (32+5)
1224 # define DATAEND (ptr_t)(_end)
1226 # define SIG_SUSPEND SIGUSR1
1227 # define SIG_THR_RESTART SIGUSR2
1229 # define FREEBSD_STACKBOTTOM
1231 # define DYNAMIC_LOADING
1233 extern char etext[];
1234 extern char * GC_FreeBSDGetDataStart(size_t, ptr_t);
1235 # define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
1238 # define OS_TYPE "NETBSD"
1240 # define DYNAMIC_LOADING
1244 # define OS_TYPE "THREE86BSD"
1247 # define OS_TYPE "BSDI"
1249 # if defined(OPENBSD) || defined(NETBSD) \
1250 || defined(THREE86BSD) || defined(BSDI)
1252 extern char etext[];
1253 # define DATASTART ((ptr_t)(etext))
1256 # define OS_TYPE "NEXT"
1257 # define DATASTART ((ptr_t) get_etext())
1258 # define STACKBOTTOM ((ptr_t)0xc0000000)
1259 # define DATAEND /* not needed */
1262 # define OS_TYPE "DOS4GW"
1263 extern long __nullarea;
1265 extern char *_STACKTOP;
1266 /* Depending on calling conventions Watcom C either precedes
1267 or does not precedes with underscore names of C-variables.
1268 Make sure startup code variables always have the same names. */
1269 #pragma aux __nullarea "*";
1270 #pragma aux _end "*";
1271 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1272 /* confused? me too. */
1273 # define DATASTART ((ptr_t) &__nullarea)
1274 # define DATAEND ((ptr_t) &_end)
1277 # define OS_TYPE "HURD"
1278 # define STACK_GROWS_DOWN
1280 # define SIG_SUSPEND SIGUSR1
1281 # define SIG_THR_RESTART SIGUSR2
1282 # define SEARCH_FOR_DATA_START
1284 # define DATAEND ((ptr_t) (_end))
1285 /* # define MPROTECT_VDB Not quite working yet? */
1286 # define DYNAMIC_LOADING
1289 # define OS_TYPE "DARWIN"
1290 # define DARWIN_DONT_PARSE_STACK
1291 # define DYNAMIC_LOADING
1292 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
1293 These aren't used when dyld support is enabled (it is by default) */
1294 # define DATASTART ((ptr_t) get_etext())
1295 # define DATAEND ((ptr_t) get_end())
1296 # define STACKBOTTOM ((ptr_t) 0xc0000000)
1298 # define USE_MMAP_ANON
1299 # ifdef GC_DARWIN_THREADS
1300 # define MPROTECT_VDB
1302 # include <unistd.h>
1303 # define GETPAGESIZE() getpagesize()
1304 /* There seems to be some issues with trylock hanging on darwin. This
1305 should be looked into some more */
1306 # define NO_PTHREAD_TRYLOCK
1307 # endif /* DARWIN */
1311 # define MACH_TYPE "NS32K"
1312 # define ALIGNMENT 4
1313 extern char **environ;
1314 # define DATASTART ((ptr_t)(&environ))
1315 /* hideous kludge: environ is the first */
1316 /* word in crt0.o, and delimits the start */
1317 /* of the data segment, no matter which */
1318 /* ld options were passed through. */
1319 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1323 # define MACH_TYPE "MIPS"
1325 # define OS_TYPE "LINUX"
1326 # define DYNAMIC_LOADING
1328 # define DATAEND (ptr_t)(_end)
1329 extern int __data_start[];
1330 # define DATASTART ((ptr_t)(__data_start))
1331 # define CPP_WORDSZ _MIPS_SZPTR
1332 # define ALIGNMENT (_MIPS_SZPTR/8)
1333 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1334 # define LINUX_STACKBOTTOM
1336 # define STACKBOTTOM ((ptr_t)0x7fff8000)
1341 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1342 extern int _fdata[], _end[];
1343 # define DATASTART ((ptr_t)_fdata)
1344 # define DATAEND ((ptr_t)_end)
1345 # define CPP_WORDSZ _MIPS_SZPTR
1346 # define ALIGNMENT (_MIPS_SZPTR/8)
1348 extern int etext[], edata[], end[];
1349 extern int _DYNAMIC_LINKING[], _gp[];
1350 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1351 + ((word)etext & 0xffff)))
1352 # define DATAEND (ptr_t)(edata)
1353 # define DATASTART2 (_DYNAMIC_LINKING \
1354 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1356 # define DATAEND2 (ptr_t)(end)
1357 # define ALIGNMENT 4
1359 # define OS_TYPE "EWS4800"
1363 # define DATASTART (ptr_t)0x10000000
1364 /* Could probably be slightly higher since */
1365 /* startup code allocates lots of stuff. */
1366 # define OS_TYPE "ULTRIX"
1367 # define ALIGNMENT 4
1371 extern int _fdata[];
1372 # define DATASTART ((ptr_t)(_fdata))
1374 # define HEAP_START (ptr_t)0x30000000
1376 # define HEAP_START DATASTART
1378 /* Lowest plausible heap address. */
1379 /* In the MMAP case, we map there. */
1380 /* In either case it is used to identify */
1381 /* heap sections so they're not */
1382 /* considered as roots. */
1383 # define OS_TYPE "IRIX5"
1384 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1385 /* of recent breakage. */
1387 # define CPP_WORDSZ _MIPS_SZPTR
1388 # define ALIGNMENT (_MIPS_SZPTR/8)
1390 # define ALIGNMENT 4
1392 # define DYNAMIC_LOADING
1395 # define OS_TYPE "MSWINCE"
1396 # define ALIGNMENT 4
1397 # define DATAEND /* not needed */
1399 # if defined(NETBSD)
1400 # define OS_TYPE "NETBSD"
1401 # define ALIGNMENT 4
1405 # define DATASTART GC_data_start
1406 # define NEED_FIND_LIMIT
1407 # define DYNAMIC_LOADING
1409 # define DATASTART ((ptr_t) 0x10000000)
1410 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1413 # if defined(NONSTOP)
1414 # define CPP_WORDSZ 32
1415 # define OS_TYPE "NONSTOP"
1416 # define ALIGNMENT 4
1417 # define DATASTART ((ptr_t) 0x08000000)
1418 extern char **environ;
1419 # define DATAEND ((ptr_t)(environ - 0x10))
1420 # define STACKBOTTOM ((ptr_t) 0x4fffffff)
1425 # define MACH_TYPE "HP_PA"
1427 # define CPP_WORDSZ 64
1428 # define ALIGNMENT 8
1430 # define CPP_WORDSZ 32
1431 # define ALIGNMENT 4
1433 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1434 # ifndef LINUX /* For now. */
1435 # define MPROTECT_VDB
1438 # ifdef PARALLEL_MARK
1439 # define USE_MARK_BYTES
1440 /* Minimize compare-and-swap usage. */
1443 # define STACK_GROWS_UP
1445 # define OS_TYPE "HPUX"
1446 extern int __data_start[];
1447 # define DATASTART ((ptr_t)(__data_start))
1449 /* The following appears to work for 7xx systems running HP/UX */
1450 /* 9.xx Furthermore, it might result in much faster */
1451 /* collections than HEURISTIC2, which may involve scanning */
1452 /* segments that directly precede the stack. It is not the */
1453 /* default, since it may not work on older machine/OS */
1454 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1456 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1458 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1459 /* to this. Note that the GC must be initialized before the */
1460 /* first putenv call. */
1461 extern char ** environ;
1462 # define STACKBOTTOM ((ptr_t)environ)
1464 # define DYNAMIC_LOADING
1465 # include <unistd.h>
1466 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1468 # define PREFETCH(x) { \
1469 register long addr = (long)(x); \
1470 (void) _asm ("LDW", 0, 0, addr, 0); \
1475 # define OS_TYPE "LINUX"
1476 # define LINUX_STACKBOTTOM
1477 # define DYNAMIC_LOADING
1478 # define SEARCH_FOR_DATA_START
1480 # define DATAEND (ptr_t)(&_end)
1485 # define MACH_TYPE "ALPHA"
1486 # define ALIGNMENT 8
1487 # define CPP_WORDSZ 64
1489 # define OS_TYPE "NETBSD"
1491 # define DATASTART GC_data_start
1492 # define ELFCLASS32 32
1493 # define ELFCLASS64 64
1494 # define ELF_CLASS ELFCLASS64
1495 # define DYNAMIC_LOADING
1498 # define OS_TYPE "OPENBSD"
1500 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1501 # define DATASTART GC_data_start
1502 # define ELFCLASS32 32
1503 # define ELFCLASS64 64
1504 # define ELF_CLASS ELFCLASS64
1505 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1506 # define DATASTART ((ptr_t) 0x140000000)
1510 # define OS_TYPE "FREEBSD"
1511 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1512 # define SIG_SUSPEND SIGUSR1
1513 # define SIG_THR_RESTART SIGUSR2
1514 # define FREEBSD_STACKBOTTOM
1516 # define DYNAMIC_LOADING
1518 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1519 extern char etext[];
1520 extern char edata[];
1522 # define NEED_FIND_LIMIT
1523 # define DATASTART ((ptr_t)(&etext))
1524 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1525 # define DATASTART2 ((ptr_t)(&edata))
1526 # define DATAEND2 ((ptr_t)(&end))
1529 # define OS_TYPE "OSF1"
1530 # define DATASTART ((ptr_t) 0x140000000)
1532 # define DATAEND ((ptr_t) &_end)
1533 extern char ** environ;
1534 /* round up from the value of environ to the nearest page boundary */
1535 /* Probably breaks if putenv is called before collector */
1536 /* initialization. */
1537 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1538 /* # define HEURISTIC2 */
1539 /* Normally HEURISTIC2 is too conservative, since */
1540 /* the text segment immediately follows the stack. */
1541 /* Hence we give an upper pound. */
1542 /* This is currently unused, since we disabled HEURISTIC2 */
1543 extern int __start[];
1544 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1545 # ifndef GC_OSF1_THREADS
1546 /* Unresolved signal issues with threads. */
1547 # define MPROTECT_VDB
1549 # define DYNAMIC_LOADING
1552 # define OS_TYPE "LINUX"
1553 # define LINUX_STACKBOTTOM
1555 # define SEARCH_FOR_DATA_START
1556 # define DYNAMIC_LOADING
1558 # define DATASTART ((ptr_t) 0x140000000)
1561 # define DATAEND (ptr_t)(_end)
1562 # define MPROTECT_VDB
1563 /* Has only been superficially tested. May not */
1564 /* work on all versions. */
1569 # define MACH_TYPE "IA64"
1572 # define CPP_WORDSZ 32
1573 /* Requires 8 byte alignment for malloc */
1574 # define ALIGNMENT 4
1579 # define CPP_WORDSZ 64
1580 /* Requires 16 byte alignment for malloc */
1581 # define ALIGNMENT 8
1583 # define OS_TYPE "HPUX"
1584 extern int __data_start[];
1585 # define DATASTART ((ptr_t)(__data_start))
1586 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1587 /* to this. Note that the GC must be initialized before the */
1588 /* first putenv call. */
1589 extern char ** environ;
1590 # define STACKBOTTOM ((ptr_t)environ)
1591 # define HPUX_STACKBOTTOM
1592 # define DYNAMIC_LOADING
1593 # include <unistd.h>
1594 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1595 /* The following was empirically determined, and is probably */
1596 /* not very robust. */
1597 /* Note that the backing store base seems to be at a nice */
1598 /* address minus one page. */
1599 # define BACKING_STORE_DISPLACEMENT 0x1000000
1600 # define BACKING_STORE_ALIGNMENT 0x1000
1601 extern ptr_t GC_register_stackbottom;
1602 # define BACKING_STORE_BASE GC_register_stackbottom
1603 /* Known to be wrong for recent HP/UX versions!!! */
1606 # define CPP_WORDSZ 64
1607 # define ALIGNMENT 8
1608 # define OS_TYPE "LINUX"
1609 /* The following works on NUE and older kernels: */
1610 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1611 /* This does not work on NUE: */
1612 # define LINUX_STACKBOTTOM
1613 /* We also need the base address of the register stack */
1614 /* backing store. This is computed in */
1615 /* GC_linux_register_stack_base based on the following */
1617 # define BACKING_STORE_ALIGNMENT 0x100000
1618 # define BACKING_STORE_DISPLACEMENT 0x80000000
1619 extern ptr_t GC_register_stackbottom;
1620 # define BACKING_STORE_BASE GC_register_stackbottom
1621 # define SEARCH_FOR_DATA_START
1623 # define DYNAMIC_LOADING
1625 /* In the Intel compiler environment, we seem to end up with */
1626 /* statically linked executables and an undefined reference */
1629 # define MPROTECT_VDB
1630 /* Requires Linux 2.3.47 or later. */
1632 # define DATAEND (ptr_t)(_end)
1634 # ifndef __INTEL_COMPILER
1635 # define PREFETCH(x) \
1636 __asm__ (" lfetch [%0]": : "r"(x))
1637 # define PREFETCH_FOR_WRITE(x) \
1638 __asm__ (" lfetch.excl [%0]": : "r"(x))
1639 # define CLEAR_DOUBLE(x) \
1640 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1642 # include <ia64intrin.h>
1643 # define PREFETCH(x) \
1644 __lfetch(__lfhint_none, (x))
1645 # define PREFETCH_FOR_WRITE(x) \
1646 __lfetch(__lfhint_nta, (x))
1647 # define CLEAR_DOUBLE(x) \
1648 __stf_spill((void *)(x), 0)
1649 # endif // __INTEL_COMPILER
1653 /* FIXME: This is a very partial guess. There is no port, yet. */
1654 # define OS_TYPE "MSWIN32"
1655 /* STACKBOTTOM and DATASTART are handled specially in */
1657 # define DATAEND /* not needed */
1658 # if defined(_WIN64)
1659 # define CPP_WORDSZ 64
1661 # define CPP_WORDSZ 32 /* Is this possible? */
1663 # define ALIGNMENT 8
1668 # define MACH_TYPE "M88K"
1669 # define ALIGNMENT 4
1672 # define OS_TYPE "CX_UX"
1673 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1676 # define OS_TYPE "DGUX"
1677 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
1678 # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
1680 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1684 /* If this still works, and if anyone cares, this should probably */
1685 /* be moved to the S390 category. */
1686 # define MACH_TYPE "S370"
1687 # define ALIGNMENT 4 /* Required by hardware */
1689 # define OS_TYPE "UTS4"
1691 extern int _etext[];
1693 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
1694 # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
1695 # define DATAEND (ptr_t)(_end)
1701 # define MACH_TYPE "S390"
1703 # define ALIGNMENT 4
1704 # define CPP_WORDSZ 32
1706 # define ALIGNMENT 8
1707 # define CPP_WORDSZ 64
1709 # define HBLKSIZE 4096
1713 # define OS_TYPE "LINUX"
1714 # define LINUX_STACKBOTTOM
1715 # define DYNAMIC_LOADING
1716 extern int __data_start[];
1717 # define DATASTART ((ptr_t)(__data_start))
1719 # define DATAEND (ptr_t)(_end)
1720 # define CACHE_LINE_SIZE 256
1721 # define GETPAGESIZE() 4096
1726 # define CPP_WORDSZ 32
1727 # define MACH_TYPE "ARM32"
1728 # define ALIGNMENT 4
1730 # define OS_TYPE "NETBSD"
1733 # define DATASTART GC_data_start
1734 # define DYNAMIC_LOADING
1736 extern char etext[];
1737 # define DATASTART ((ptr_t)(etext))
1741 # define OS_TYPE "LINUX"
1742 # define LINUX_STACKBOTTOM
1744 # define STACK_GRAN 0x10000000
1746 # define DYNAMIC_LOADING
1747 # include <features.h>
1748 # if defined(__GLIBC__) && __GLIBC__ >= 2 \
1749 || defined(PLATFORM_ANDROID)
1750 # define SEARCH_FOR_DATA_START
1752 extern char **__environ;
1753 # define DATASTART ((ptr_t)(&__environ))
1754 /* hideous kludge: __environ is the first */
1755 /* word in crt0.o, and delimits the start */
1756 /* of the data segment, no matter which */
1757 /* ld options were passed through. */
1758 /* We could use _etext instead, but that */
1759 /* would include .rodata, which may */
1760 /* contain large read-only data tables */
1761 /* that we'd rather not scan. */
1764 # define DATAEND (ptr_t)(_end)
1767 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1771 # define OS_TYPE "MSWINCE"
1772 # define DATAEND /* not needed */
1776 # define OS_TYPE "DARWIN"
1777 # define DATASTART ((ptr_t) get_etext())
1778 # define DATAEND ((ptr_t) get_end())
1779 /* #define STACKBOTTOM ((ptr_t) 0x30000000) */ /* FIXME: Is this needed? */
1782 # define USE_MMAP_ANON
1785 /* __data_start is usually defined in the target linker script. */
1786 extern int __data_start[];
1787 # define DATASTART (ptr_t)(__data_start)
1788 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1789 extern void *__stack_base__;
1790 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1795 # define MACH_TYPE "CRIS"
1796 # define CPP_WORDSZ 32
1797 # define ALIGNMENT 1
1798 # define OS_TYPE "LINUX"
1799 # define DYNAMIC_LOADING
1800 # define LINUX_STACKBOTTOM
1801 # define SEARCH_FOR_DATA_START
1803 # define DATAEND (ptr_t)(_end)
1807 # define MACH_TYPE "SH"
1808 # define ALIGNMENT 4
1810 # define OS_TYPE "MSWINCE"
1811 # define DATAEND /* not needed */
1814 # define OS_TYPE "LINUX"
1815 # define LINUX_STACKBOTTOM
1816 # define DYNAMIC_LOADING
1817 # define SEARCH_FOR_DATA_START
1819 # define DATAEND (ptr_t)(_end)
1822 # define OS_TYPE "NETBSD"
1824 # define DATASTART GC_data_start
1825 # define DYNAMIC_LOADING
1830 # define MACH_TYPE "SH4"
1831 # define OS_TYPE "MSWINCE"
1832 # define ALIGNMENT 4
1833 # define DATAEND /* not needed */
1837 # define CPP_WORDSZ 32
1838 # define MACH_TYPE "M32R"
1839 # define ALIGNMENT 4
1841 # define OS_TYPE "LINUX"
1842 # define LINUX_STACKBOTTOM
1844 # define STACK_GRAN 0x10000000
1845 # define DYNAMIC_LOADING
1846 # define SEARCH_FOR_DATA_START
1848 # define DATAEND (ptr_t)(_end)
1853 # define MACH_TYPE "X86_64"
1854 # define ALIGNMENT 8
1855 # define CPP_WORDSZ 64
1857 # define HBLKSIZE 4096
1859 # define CACHE_LINE_SIZE 64
1861 # define OS_TYPE "LINUX"
1862 # define LINUX_STACKBOTTOM
1863 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1864 # define MPROTECT_VDB
1866 /* We seem to get random errors in incremental mode, */
1867 /* possibly because Linux threads is itself a malloc client */
1868 /* and can't deal with the signals. */
1871 # define DYNAMIC_LOADING
1872 # ifdef UNDEFINED /* includes ro data */
1873 extern int _etext[];
1874 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1876 # include <features.h>
1877 # define SEARCH_FOR_DATA_START
1879 # define DATAEND (ptr_t)(_end)
1882 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1884 # if defined(__GNUC__) && __GNUC__ >= 3
1885 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
1886 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
1890 # define OS_TYPE "DARWIN"
1891 # define DARWIN_DONT_PARSE_STACK
1892 # define DYNAMIC_LOADING
1893 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
1894 These aren't used when dyld support is enabled (it is by default) */
1895 # define DATASTART ((ptr_t) get_etext())
1896 # define DATAEND ((ptr_t) get_end())
1897 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
1899 # define USE_MMAP_ANON
1900 # ifdef GC_DARWIN_THREADS
1901 # define MPROTECT_VDB
1903 # include <unistd.h>
1904 # define GETPAGESIZE() getpagesize()
1905 /* There seems to be some issues with trylock hanging on darwin. This
1906 should be looked into some more */
1907 # define NO_PTHREAD_TRYLOCK
1910 # define OS_TYPE "FREEBSD"
1911 # ifndef GC_FREEBSD_THREADS
1912 # define MPROTECT_VDB
1915 # define SIG_SUSPEND (32+6)
1916 # define SIG_THR_RESTART (32+5)
1918 # define DATAEND (ptr_t)(_end)
1920 # define SIG_SUSPEND SIGUSR1
1921 # define SIG_THR_RESTART SIGUSR2
1923 # define FREEBSD_STACKBOTTOM
1925 # define DYNAMIC_LOADING
1927 extern char etext[];
1928 ptr_t GC_FreeBSDGetDataStart(size_t max_page_size, ptr_t etext_addr);
1929 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1932 # define OS_TYPE "NETBSD"
1934 # define DYNAMIC_LOADING
1937 extern char etext[];
1938 # define SEARCH_FOR_DATA_START
1941 # define OS_TYPE "SOLARIS"
1942 # define ELF_CLASS ELFCLASS64
1943 extern int _etext[], _end[];
1944 extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
1945 # define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
1946 # define DATAEND (ptr_t)(_end)
1947 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1948 /* but reportedly breaks under 2.8. It appears that the stack */
1949 /* base is a property of the executable, so this should not break */
1950 /* old executables. */
1951 /* HEURISTIC2 probably works, but this appears to be preferable. */
1952 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
1953 /* installations that's undefined. We work around this with a */
1955 # include <sys/vmparam.h>
1957 /* This should work everywhere, but doesn't. */
1958 # define STACKBOTTOM ((ptr_t) USRSTACK)
1962 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1963 /* It appears to be fixed in 2.8 and 2.9. */
1964 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1967 # define DYNAMIC_LOADING
1968 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1970 /* Otherwise we now use calloc. Mmap may result in the */
1971 /* heap interleaved with thread stacks, which can result in */
1972 /* excessive blacklisting. Sbrk is unusable since it */
1973 /* doesn't interact correctly with the system malloc. */
1976 # define HEAP_START (ptr_t)0x40000000
1978 # define HEAP_START DATAEND
1982 # define OS_TYPE "MSWIN32"
1983 /* STACKBOTTOM and DATASTART are handled specially in */
1985 # define MPROTECT_VDB
1987 # define DATAEND /* not needed */
1991 #if defined(LINUX_STACKBOTTOM) && defined(NO_PROC_STAT) \
1992 && !defined(USE_LIBC_PRIVATES)
1993 /* This combination will fail, since we have no way to get */
1994 /* the stack base. Use HEURISTIC2 instead. */
1995 # undef LINUX_STACKBOTTOM
1997 /* This may still fail on some architectures like IA64. */
2001 #if defined(LINUX) && defined(USE_MMAP)
2002 /* The kernel may do a somewhat better job merging mappings etc. */
2003 /* with anonymous mappings. */
2004 # define USE_MMAP_ANON
2007 #if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC)
2008 /* Nptl allocates thread stacks with mmap, which is fine. But it */
2009 /* keeps a cache of thread stacks. Thread stacks contain the */
2010 /* thread control blocks. These in turn contain a pointer to */
2011 /* (sizeof (void *) from the beginning of) the dtv for thread-local */
2012 /* storage, which is calloc allocated. If we don't scan the cached */
2013 /* thread stacks, we appear to lose the dtv. This tends to */
2014 /* result in something that looks like a bogus dtv count, which */
2015 /* tends to result in a memset call on a block that is way too */
2016 /* large. Sometimes we're lucky and the process just dies ... */
2017 /* There seems to be a similar issue with some other memory */
2018 /* allocated by the dynamic loader. */
2019 /* This should be avoidable by either: */
2020 /* - Defining USE_PROC_FOR_LIBRARIES here. */
2021 /* That performs very poorly, precisely because we end up */
2022 /* scanning cached stacks. */
2023 /* - Have calloc look at its callers. */
2024 /* In spite of the fact that it is gross and disgusting. */
2025 /* In fact neither seems to suffice, probably in part because */
2026 /* even with USE_PROC_FOR_LIBRARIES, we don't scan parts of stack */
2027 /* segments that appear to be out of bounds. Thus we actually */
2028 /* do both, which seems to yield the best results. */
2030 # define USE_PROC_FOR_LIBRARIES
2033 # ifndef STACK_GROWS_UP
2034 # define STACK_GROWS_DOWN
2038 # define CPP_WORDSZ 32
2047 # define DATAEND (ptr_t)(end)
2050 # if defined(SVR4) && !defined(GETPAGESIZE)
2051 # include <unistd.h>
2052 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2055 # ifndef GETPAGESIZE
2056 # if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \
2057 || defined(NETBSD) || defined(FREEBSD) || defined(HPUX)
2058 # include <unistd.h>
2060 # define GETPAGESIZE() getpagesize()
2063 # if defined(SOLARIS) || defined(DRSNX) || defined(UTS4)
2064 /* OS has SVR4 generic features. */
2065 /* Probably others also qualify. */
2069 # if defined(SOLARIS) || defined(DRSNX)
2070 /* OS has SOLARIS style semi-undocumented interface */
2071 /* to dynamic loader. */
2073 /* OS has SOLARIS style signal handlers. */
2081 # if defined(FREEBSD) && \
2082 (defined(__DragonFly__) || __FreeBSD__ >= 4 || (__FreeBSD_kernel__ >= 4))
2086 # ifdef GC_NETBSD_THREADS
2087 # define SIGRTMIN 33
2088 # define SIGRTMAX 63
2091 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2092 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2093 || defined(DGUX) || defined(BSD) \
2094 || defined(AIX) || defined(DARWIN) || defined(OSF1) \
2096 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2099 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2104 # undef DYNAMIC_LOADING
2109 # undef MPROTECT_VDB
2113 # ifdef SMALL_CONFIG
2114 /* Presumably not worth the space it takes. */
2116 # undef MPROTECT_VDB
2120 /* FIXME: Remove this undef if possible. */
2121 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2124 # if defined(PARALLEL_MARK)
2125 /* FIXME: Remove this undef if possible. */
2126 # undef MPROTECT_VDB /* For now. */
2129 # if defined(MPROTECT_VDB) && defined(GC_PREFER_MPROTECT_VDB)
2130 /* Choose MPROTECT_VDB manually (if multiple strategies available). */
2133 /* #undef GWW_VDB - handled in os_dep.c */
2136 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) \
2137 && !defined(GWW_VDB)
2138 # define DEFAULT_VDB
2142 # define PREFETCH(x)
2143 # define NO_PREFETCH
2146 # ifndef PREFETCH_FOR_WRITE
2147 # define PREFETCH_FOR_WRITE(x)
2148 # define NO_PREFETCH_FOR_WRITE
2151 # ifndef CACHE_LINE_SIZE
2152 # define CACHE_LINE_SIZE 32 /* Wild guess */
2156 # ifndef NO_DEBUGGING
2157 # define STATIC /* ignore to aid profiling and possibly debugging */
2159 # define STATIC static
2163 # if defined(LINUX) || defined(HURD) || defined(__GLIBC__)
2164 # define REGISTER_LIBRARIES_EARLY
2165 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2166 /* lock. This isn't safe after the world has stopped. So we must */
2167 /* call GC_register_dynamic_libraries before stopping the world. */
2168 /* For performance reasons, this may be beneficial on other */
2169 /* platforms as well, though it should be avoided in win32. */
2172 # if defined(SEARCH_FOR_DATA_START)
2173 extern ptr_t GC_data_start;
2174 # define DATASTART GC_data_start
2177 # ifndef CLEAR_DOUBLE
2178 # define CLEAR_DOUBLE(x) \
2179 ((word*)x)[0] = 0; \
2181 # endif /* CLEAR_DOUBLE */
2183 # if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \
2184 && !defined(INCLUDE_LINUX_THREAD_DESCR)
2185 /* Will not work, since libc and the dynamic loader use thread */
2186 /* locals, sometimes as the only reference. */
2187 # define INCLUDE_LINUX_THREAD_DESCR
2190 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2191 --> inconsistent configuration
2193 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
2194 --> inconsistent configuration
2196 # if defined(GC_NETBSD_THREADS) && !defined(NETBSD)
2197 --> inconsistent configuration
2199 # if defined(GC_FREEBSD_THREADS) && !defined(FREEBSD)
2200 --> inconsistent configuration
2202 # if defined(GC_SOLARIS_THREADS) && !defined(SOLARIS)
2203 --> inconsistent configuration
2205 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2206 --> inconsistent configuration
2208 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2209 --> inconsistent configuration
2211 # if defined(GC_GNU_THREADS) && !defined(HURD)
2212 --> inconsistent configuration
2214 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2215 --> inconsistent configuration
2218 # if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS)
2222 # if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES)
2223 # if defined(THREADS) && defined(PARALLEL_MARK)
2224 # define USE_MARK_BYTES
2226 # define USE_MARK_BITS
2230 # if defined(MSWINCE)
2235 # if defined(_WIN64) && !defined(__GNUC__)
2236 # define STRTOULL _strtoui64
2237 # elif defined(_LLP64) || defined(__LLP64__) || defined(_WIN64)
2238 # define STRTOULL strtoull
2240 /* strtoul() fits since sizeof(long) >= sizeof(word). */
2241 # define STRTOULL strtoul
2246 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2247 /* include assembly code to do it well. */
2250 /* Can we save call chain in objects for debugging? */
2251 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2252 /* frame) to reasonable values for the platform. */
2253 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2254 /* at build time, though we feel free to adjust it slightly. */
2255 /* Define NEED_CALLINFO if we either save the call stack or */
2256 /* GC_ADD_CALLER is defined. */
2257 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2260 # define CAN_SAVE_CALL_ARGS
2262 #if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__))
2263 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2264 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2265 # define CAN_SAVE_CALL_ARGS
2268 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2269 && defined(GC_CAN_SAVE_CALL_STACKS)
2270 # define SAVE_CALL_CHAIN
2272 # ifdef SAVE_CALL_CHAIN
2273 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2274 # define NARGS SAVE_CALL_NARGS
2276 # define NARGS 0 /* Number of arguments to save for each call. */
2279 # ifdef SAVE_CALL_CHAIN
2280 # ifndef SAVE_CALL_COUNT
2281 # define NFRAMES 6 /* Number of frames to save. Even for */
2282 /* alignment reasons. */
2284 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2286 # define NEED_CALLINFO
2287 # endif /* SAVE_CALL_CHAIN */
2288 # ifdef GC_ADD_CALLER
2291 # define NEED_CALLINFO
2294 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2295 # define DBG_HDRS_ALL
2298 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2299 # define POINTER_SHIFT 0
2302 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2303 # define POINTER_MASK ((GC_word)(-1))
2306 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2307 # define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT)
2310 # if defined(FIXUP_POINTER)
2311 # define NEED_FIXUP_POINTER 1
2313 # define NEED_FIXUP_POINTER 0
2314 # define FIXUP_POINTER(p)
2317 # if !defined(MARK_BIT_PER_GRANULE) && !defined(MARK_BIT_PER_OBJ)
2318 # define MARK_BIT_PER_GRANULE /* Usually faster */
2321 /* Some static sanity tests. */
2322 # if defined(MARK_BIT_PER_GRANULE) && defined(MARK_BIT_PER_OBJ)
2323 # error Define only one of MARK_BIT_PER_GRANULE and MARK_BIT_PER_OBJ.
2326 # if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN)
2327 # error "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
2329 # if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN)
2330 # error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
2333 # if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX)
2334 # error "REDIRECT_MALLOC with THREADS works at most on Linux."
2338 /* This relies on some type definitions from gc_priv.h, from */
2339 /* where it's normally included. */
2341 /* How to get heap memory from the OS: */
2342 /* Note that sbrk()-like allocation is preferred, since it */
2343 /* usually makes it possible to merge consecutively allocated */
2344 /* chunks. It also avoids unintended recursion with */
2345 /* -DREDIRECT_MALLOC. */
2346 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2347 /* 0 is taken to mean failure. */
2348 /* In the case os USE_MMAP, the argument must also be a */
2349 /* physical page size. */
2350 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2351 /* though we should perhaps take advantage of the case in which */
2353 struct hblk; /* See gc_priv.h. */
2355 char * real_malloc(size_t bytes);
2356 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2359 void * os2_alloc(size_t bytes);
2360 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2363 # elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) || \
2364 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2365 (defined(SOLARIS) && !defined(USE_MMAP))
2366 # define GET_MEM(bytes) HBLKPTR((size_t) calloc(1, (size_t)bytes + GC_page_size) \
2368 # elif defined(MSWIN32)
2369 ptr_t GC_win32_get_mem(GC_word bytes);
2370 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2371 # elif defined(MACOS)
2372 # if defined(USE_TEMPORARY_MEMORY)
2373 extern Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory);
2374 # define GET_MEM(bytes) HBLKPTR( \
2375 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2378 # define GET_MEM(bytes) HBLKPTR( \
2379 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2381 # elif defined(MSWINCE)
2382 ptr_t GC_wince_get_mem(GC_word bytes);
2383 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2384 # elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2385 extern void *GC_amiga_get_mem(size_t size);
2386 # define GET_MEM(bytes) HBLKPTR((size_t) \
2387 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2390 ptr_t GC_unix_get_mem(GC_word bytes);
2391 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2394 #endif /* GC_PRIVATE_H */
2396 # endif /* GCCONFIG_H */