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_kernel__) ) && !defined(FREEBSD)
62 /* Determine the machine type: */
63 # if defined(__arm__) || defined(__thumb__)
65 # if !defined(LINUX) && !defined(NETBSD)
67 # define mach_type_known
70 # if defined(sun) && defined(mc68000)
73 # define mach_type_known
75 # if defined(hp9000s300)
78 # define mach_type_known
80 # if defined(OPENBSD) && defined(m68k)
82 # define mach_type_known
84 # if defined(OPENBSD) && defined(__sparc__)
86 # define mach_type_known
88 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
90 # define mach_type_known
92 # if defined(NETBSD) && defined(__powerpc__)
94 # define mach_type_known
96 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
98 # define mach_type_known
100 # if defined(NETBSD) && defined(__sh__)
102 # define mach_type_known
111 # define mach_type_known
113 # if defined(__NetBSD__) && defined(__vax__)
115 # define mach_type_known
117 # if defined(mips) || defined(__mips) || defined(_mips)
119 # if defined(nec_ews) || defined(_nec_ews)
122 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
123 # if defined(ultrix) || defined(__ultrix)
126 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
127 || defined(__SYSTYPE_SVR4__)
128 # define IRIX5 /* or IRIX 6.X */
130 # define RISCOS /* or IRIX 4.X */
134 # if defined(__NetBSD__) && defined(__MIPSEL__)
137 # define mach_type_known
139 # if defined(DGUX) && (defined(i386) || defined(__i386__))
144 # define mach_type_known
146 # if defined(sequent) && (defined(i386) || defined(__i386__))
149 # define mach_type_known
151 # if defined(sun) && (defined(i386) || defined(__i386__))
154 # define mach_type_known
156 # if defined(sun) && defined(__amd64)
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
305 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
307 # if defined(__ppc__) || defined(__ppc64__)
309 # define mach_type_known
310 # elif defined(__x86_64__)
312 # define mach_type_known
313 # elif defined(__i386__)
315 # define mach_type_known
318 # if defined(NeXT) && defined(mc68000)
321 # define mach_type_known
323 # if defined(NeXT) && (defined(i386) || defined(__i386__))
326 # define mach_type_known
328 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
331 # define mach_type_known
333 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
335 # define mach_type_known
337 # if defined(FREEBSD) && defined(__x86_64__)
339 # define mach_type_known
341 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
343 # define mach_type_known
345 # if defined(__NetBSD__) && defined(__x86_64__)
347 # define mach_type_known
349 # if defined(FREEBSD) && defined(__sparc__)
351 # define mach_type_known
353 # if defined(bsdi) && (defined(i386) || defined(__i386__))
356 # define mach_type_known
358 # if !defined(mach_type_known) && defined(__386BSD__)
361 # define mach_type_known
363 # if defined(_CX_UX) && defined(_M88K)
366 # define mach_type_known
368 # if defined(DGUX) && defined(m88k)
371 # define mach_type_known
373 # if defined(_WIN32_WCE)
374 /* SH3, SH4, MIPS already defined for corresponding architectures */
375 # if defined(SH3) || defined(SH4)
385 # define mach_type_known
387 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
388 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
390 # define MSWIN32 /* or Win32s */
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 differnt 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__)
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
428 # define mach_type_known
430 # if defined(__embedded__) && defined(PPC)
433 # define mach_type_known
436 # if defined(__WATCOMC__) && defined(__386__)
438 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
439 # if defined(__OS2__)
442 # if defined(__WINDOWS_386__) || defined(__NT__)
449 # define mach_type_known
451 # if defined(__s390__) && defined(LINUX)
453 # define mach_type_known
455 # if defined(__GNU__)
456 # if defined(__i386__)
457 /* The Debian Hurd running on generic PC */
460 # define mach_type_known
464 /* Feel free to add more clauses here */
466 /* Or manually define the machine type here. A machine type is */
467 /* characterized by the architecture. Some */
468 /* machine types are further subdivided by OS. */
469 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
470 /* Note that SGI IRIX is treated identically to RISCOS. */
471 /* SYSV on an M68K actually means A/UX. */
472 /* The distinction in these cases is usually the stack starting address */
473 # ifndef mach_type_known
474 --> unknown machine type
476 /* Mapping is: M68K ==> Motorola 680X0 */
477 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
478 /* MACOS and AMIGA variants) */
479 /* I386 ==> Intel 386 */
480 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
481 /* FREEBSD, THREE86BSD, MSWIN32, */
482 /* BSDI,SUNOS5, NEXT, other variants) */
483 /* NS32K ==> Encore Multimax */
484 /* MIPS ==> R2000 or R3000 */
485 /* (RISCOS, ULTRIX variants) */
486 /* VAX ==> DEC VAX */
487 /* (BSD, ULTRIX variants) */
488 /* RS6000 ==> IBM RS/6000 AIX3.X */
489 /* RT ==> IBM PC/RT */
490 /* HP_PA ==> HP9000/700 & /800 */
492 /* SPARC ==> SPARC v7/v8/v9 */
493 /* (SUNOS4, SUNOS5, LINUX, */
494 /* DRSNX variants) */
495 /* ALPHA ==> DEC Alpha */
496 /* (OSF1 and LINUX variants) */
497 /* M88K ==> Motorola 88XX0 */
498 /* (CX_UX and DGUX) */
499 /* S370 ==> 370-like machine */
500 /* running Amdahl UTS4 */
501 /* S390 ==> 390-like machine */
503 /* ARM32 ==> Intel StrongARM */
504 /* IA64 ==> Intel IPF */
506 /* (LINUX and HPUX) */
507 /* SH ==> Hitachi SuperH */
508 /* (LINUX & MSWINCE) */
509 /* X86_64 ==> AMD x86-64 */
510 /* POWERPC ==> IBM/Apple PowerPC */
511 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
512 /* LINUX, NETBSD, NOSYS variants) */
513 /* Handles 32 and 64-bit variants. */
514 /* AIX should be handled here, but */
515 /* that's called an RS6000. */
516 /* CRIS ==> Axis Etrax */
517 /* M32R ==> Renesas M32R */
521 * For each architecture and OS, the following need to be defined:
523 * CPP_WORDSZ is a simple integer constant representing the word size.
524 * in bits. We assume byte addressibility, where a byte has 8 bits.
525 * We also assume CPP_WORDSZ is either 32 or 64.
526 * (We care about the length of pointers, not hardware
527 * bus widths. Thus a 64 bit processor with a C compiler that uses
528 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
530 * MACH_TYPE is a string representation of the machine type.
531 * OS_TYPE is analogous for the OS.
533 * ALIGNMENT is the largest N, such that
534 * all pointer are guaranteed to be aligned on N byte boundaries.
535 * defining it to be 1 will always work, but perform poorly.
537 * DATASTART is the beginning of the data segment.
538 * On some platforms SEARCH_FOR_DATA_START is defined.
539 * SEARCH_FOR_DATASTART will cause GC_data_start to
540 * be set to an address determined by accessing data backwards from _end
541 * until an unmapped page is found. DATASTART will be defined to be
543 * On UNIX-like systems, the collector will scan the area between DATASTART
544 * and DATAEND for root pointers.
546 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
547 * RTH suggests gaining access to linker script synth'd values with
548 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
549 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
550 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
551 * without any special options.
553 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
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, and if that fails read it from /proc.
570 * If either of the last two macros are defined, then STACKBOTTOM is computed
571 * during collector startup using one of the following two heuristics:
572 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
573 * the next multiple of STACK_GRAN.
574 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
575 * in small steps (decrement if STACK_GROWS_UP), and read the value
576 * at each location. Remember the value when the first
577 * Segmentation violation or Bus error is signalled. Round that
578 * to the nearest plausible page boundary, and use that instead
581 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
582 * the value of environ is a pointer that can serve as STACKBOTTOM.
583 * I expect that HEURISTIC2 can be replaced by this approach, which
584 * interferes far less with debugging. However it has the disadvantage
585 * that it's confused by a putenv call before the collector is initialized.
586 * This could be dealt with by intercepting putenv ...
588 * If no expression for STACKBOTTOM can be found, and neither of the above
589 * heuristics are usable, the collector can still be used with all of the above
590 * undefined, provided one of the following is done:
591 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
592 * without reference to STACKBOTTOM. This is appropriate for use in
593 * conjunction with thread packages, since there will be multiple stacks.
594 * (Allocating thread stacks in the heap, and treating them as ordinary
595 * heap data objects is also possible as a last resort. However, this is
596 * likely to introduce significant amounts of excess storage retention
597 * unless the dead parts of the thread stacks are periodically cleared.)
598 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
599 * If the author of the client code controls the main program, this is
600 * easily accomplished by introducing a new main program, setting
601 * GC_stackbottom to the address of a local variable, and then calling
602 * the original main program. The new main program would read something
605 * # include "gc_private.h"
607 * main(argc, argv, envp)
609 * char **argv, **envp;
613 * GC_stackbottom = (ptr_t)(&dummy);
614 * return(real_main(argc, argv, envp));
618 * Each architecture may also define the style of virtual dirty bit
619 * implementation to be used:
620 * MPROTECT_VDB: Write protect the heap and catch faults.
621 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
623 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
624 * defined GC_register_dynamic_libraries() for the architecture.
626 * An architecture may define PREFETCH(x) to preload the cache with *x.
627 * This defaults to a no-op.
629 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
631 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
632 * clear the two words at GC_malloc-aligned address x. By default,
633 * word stores of 0 are used instead.
635 * HEAP_START may be defined as the initial address hint for mmap-based
639 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
640 * to push the relevant registers onto the stack. This generally makes
641 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
643 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
644 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
645 && !defined(__INTEL_COMPILER) \
646 && !defined(__PATHCC__)
647 # define HAVE_BUILTIN_UNWIND_INIT
650 # define STACK_GRAN 0x1000000
652 # define MACH_TYPE "M68K"
655 # define OS_TYPE "OPENBSD"
658 # define DATASTART GC_data_start
659 # define DYNAMIC_LOADING
662 # define DATASTART ((ptr_t)(etext))
664 # define USE_GENERIC_PUSH_REGS
667 # define OS_TYPE "NETBSD"
670 # define DATASTART GC_data_start
671 # define DYNAMIC_LOADING
674 # define DATASTART ((ptr_t)(etext))
676 # define USE_GENERIC_PUSH_REGS
679 # define OS_TYPE "LINUX"
680 # define LINUX_STACKBOTTOM
681 # define USE_GENERIC_PUSH_REGS
682 /* We never got around to the assembly version. */
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 (_end)
705 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
709 # define OS_TYPE "SUNOS4"
711 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
712 # define HEURISTIC1 /* differs */
713 # define DYNAMIC_LOADING
716 # define OS_TYPE "HP"
718 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
719 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
720 /* empirically determined. seems to work. */
722 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
725 # define OS_TYPE "SYSV"
727 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
729 +((word)etext & 0x1fff))
730 /* This only works for shared-text binaries with magic number 0413.
731 The other sorts of SysV binaries put the data at the end of the text,
732 in which case the default of etext would work. Unfortunately,
733 handling both would require having the magic-number available.
736 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
737 /* The stack starts at the top of memory, but */
738 /* 0x0 cannot be used as setjump_test complains */
739 /* that the stack direction is incorrect. Two */
740 /* bytes down from 0x0 should be safe enough. */
742 # include <sys/mmu.h>
743 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
746 # define OS_TYPE "AMIGA"
747 /* STACKBOTTOM and DATASTART handled specially */
749 # define DATAEND /* not needed */
750 # define GETPAGESIZE() 4096
756 # define OS_TYPE "MACOS"
757 /* see os_dep.c for details of global data segments. */
758 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
759 # define DATAEND /* not needed */
760 # define GETPAGESIZE() 4096
763 # define OS_TYPE "NEXT"
764 # define DATASTART ((ptr_t) get_etext())
765 # define STACKBOTTOM ((ptr_t) 0x4000000)
766 # define DATAEND /* not needed */
770 # if defined(POWERPC)
771 # define MACH_TYPE "POWERPC"
773 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
777 # define OS_TYPE "MACOS"
778 /* see os_dep.c for details of global data segments. */
779 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
780 # define DATAEND /* not needed */
783 # if defined(__powerpc64__)
785 # define CPP_WORDSZ 64
787 # define HBLKSIZE 4096
792 # define OS_TYPE "LINUX"
793 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
794 /* executable on a 64 bit kernel. */
795 # define LINUX_STACKBOTTOM
796 # define DYNAMIC_LOADING
797 # define SEARCH_FOR_DATA_START
799 # define DATAEND (_end)
802 # define OS_TYPE "DARWIN"
803 # define DYNAMIC_LOADING
804 # if defined(__ppc64__)
806 # define CPP_WORDSZ 64
807 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
808 # define CACHE_LINE_SIZE 64
810 # define HBLKSIZE 4096
814 # define STACKBOTTOM ((ptr_t) 0xc0000000)
816 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
817 These aren't used when dyld support is enabled (it is by default) */
818 # define DATASTART ((ptr_t) get_etext())
819 # define DATAEND ((ptr_t) get_end())
821 # define USE_MMAP_ANON
822 # define USE_ASM_PUSH_REGS
823 # ifdef GC_DARWIN_THREADS
824 # define MPROTECT_VDB
827 # define GETPAGESIZE() getpagesize()
828 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
829 /* The performance impact of prefetches is untested */
830 # define PREFETCH(x) \
831 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
832 # define PREFETCH_FOR_WRITE(x) \
833 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
835 /* There seems to be some issues with trylock hanging on darwin. This
836 should be looked into some more */
837 # define NO_PTHREAD_TRYLOCK
841 # define OS_TYPE "FREEBSD"
842 # ifndef GC_FREEBSD_THREADS
843 # define MPROTECT_VDB
845 # define SIG_SUSPEND SIGUSR1
846 # define SIG_THR_RESTART SIGUSR2
847 # define FREEBSD_STACKBOTTOM
849 # define DYNAMIC_LOADING
852 extern char * GC_FreeBSDGetDataStart();
853 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
857 # define OS_TYPE "NETBSD"
860 # define DATASTART GC_data_start
861 # define DYNAMIC_LOADING
865 # define OS_TYPE "NOSYS"
866 extern void __end[], __dso_handle[];
867 # define DATASTART (__dso_handle) /* OK, that's ugly. */
868 # define DATAEND (__end)
869 /* Stack starts at 0xE0000000 for the simulator. */
871 # define STACK_GRAN 0x10000000
877 # define MACH_TYPE "VAX"
878 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
880 # define DATASTART ((ptr_t)(etext))
882 # define OS_TYPE "BSD"
884 /* HEURISTIC2 may be OK, but it's hard to test. */
887 # define OS_TYPE "ULTRIX"
888 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
893 # define MACH_TYPE "RT"
895 # define DATASTART ((ptr_t) 0x10000000)
896 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
900 # define MACH_TYPE "SPARC"
901 # if defined(__arch64__) || defined(__sparcv9)
903 # define CPP_WORDSZ 64
904 # define ELF_CLASS ELFCLASS64
906 # define ALIGNMENT 4 /* Required by hardware */
907 # define CPP_WORDSZ 32
909 # define ALIGN_DOUBLE
911 # define OS_TYPE "SUNOS5"
914 extern ptr_t GC_SysVGetDataStart();
915 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
916 # define DATAEND (_end)
917 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
919 /* Otherwise we now use calloc. Mmap may result in the */
920 /* heap interleaved with thread stacks, which can result in */
921 /* excessive blacklisting. Sbrk is unusable since it */
922 /* doesn't interact correctly with the system malloc. */
925 # define HEAP_START (ptr_t)0x40000000
927 # define HEAP_START DATAEND
930 /* HEURISTIC1 reportedly no longer works under 2.7. */
931 /* HEURISTIC2 probably works, but this appears to be preferable. */
932 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
933 /* installations that's undefined. We work around this with a */
935 # include <sys/vmparam.h>
937 /* This should work everywhere, but doesn't. */
938 # define STACKBOTTOM USRSTACK
943 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
944 /* getpagesize() appeared to be missing from at least one */
945 /* Solaris 5.4 installation. Weird. */
946 # define DYNAMIC_LOADING
949 # define OS_TYPE "SUNOS4"
950 /* [If you have a weak stomach, don't read this.] */
951 /* We would like to use: */
952 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
953 /* This fails occasionally, due to an ancient, but very */
954 /* persistent ld bug. etext is set 32 bytes too high. */
955 /* We instead read the text segment size from the a.out */
956 /* header, which happens to be mapped into our address space */
957 /* at the start of the text segment. The detective work here */
958 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
959 /* Serpette of INRIA. */
960 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
961 # define TEXTSTART 0x2000
962 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
963 # define MPROTECT_VDB
965 # define DYNAMIC_LOADING
968 # define OS_TYPE "DRSNX"
969 extern ptr_t GC_SysVGetDataStart();
971 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
972 # define MPROTECT_VDB
973 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
974 # define DYNAMIC_LOADING
977 # define OS_TYPE "LINUX"
979 # define DYNAMIC_LOADING
981 Linux Sparc/a.out not supported
985 # define DATAEND (_end)
987 extern ptr_t GC_SysVGetDataStart();
989 # define DATASTART GC_SysVGetDataStart(0x100000, _etext)
991 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
993 # define LINUX_STACKBOTTOM
996 # define OS_TYPE "OPENBSD"
997 # define STACKBOTTOM ((ptr_t) 0xf8000000)
999 # define DATASTART ((ptr_t)(etext))
1002 # define OS_TYPE "NETBSD"
1005 # define DATASTART GC_data_start
1006 # define DYNAMIC_LOADING
1008 extern char etext[];
1009 # define DATASTART ((ptr_t)(etext))
1013 # define OS_TYPE "FREEBSD"
1014 # define SIG_SUSPEND SIGUSR1
1015 # define SIG_THR_RESTART SIGUSR2
1016 # define FREEBSD_STACKBOTTOM
1018 # define DYNAMIC_LOADING
1020 extern char etext[];
1021 extern char edata[];
1023 # define NEED_FIND_LIMIT
1024 # define DATASTART ((ptr_t)(&etext))
1025 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1026 # define DATASTART2 ((ptr_t)(&edata))
1027 # define DATAEND2 ((ptr_t)(&end))
1032 # define MACH_TYPE "I386"
1033 # if defined(__LP64__) || defined(_WIN64)
1034 # define CPP_WORDSZ 64
1035 # define ALIGNMENT 8
1037 # define CPP_WORDSZ 32
1038 # define ALIGNMENT 4
1039 /* Appears to hold for all "32 bit" compilers */
1040 /* except Borland. The -a4 option fixes */
1042 /* Ivan Demakov: For Watcom the option is -zp4. */
1044 # ifndef SMALL_CONFIG
1045 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1046 /* improvement on Pentiums. */
1048 # ifdef HAVE_BUILTIN_UNWIND_INIT
1049 # define USE_GENERIC_PUSH_REGS
1052 # define OS_TYPE "SEQUENT"
1054 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1055 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1058 # define OS_TYPE "BEOS"
1060 # define GETPAGESIZE() B_PAGE_SIZE
1062 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1065 # define OS_TYPE "SUNOS5"
1066 extern int _etext[], _end[];
1067 extern ptr_t GC_SysVGetDataStart();
1068 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1069 # define DATAEND (_end)
1070 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1071 /* but reportedly breaks under 2.8. It appears that the stack */
1072 /* base is a property of the executable, so this should not break */
1073 /* old executables. */
1074 /* HEURISTIC2 probably works, but this appears to be preferable. */
1075 # include <sys/vm.h>
1076 # define STACKBOTTOM USRSTACK
1077 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1078 /* It appears to be fixed in 2.8 and 2.9. */
1079 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1082 # define DYNAMIC_LOADING
1083 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1085 /* Otherwise we now use calloc. Mmap may result in the */
1086 /* heap interleaved with thread stacks, which can result in */
1087 /* excessive blacklisting. Sbrk is unusable since it */
1088 /* doesn't interact correctly with the system malloc. */
1091 # define HEAP_START (ptr_t)0x40000000
1093 # define HEAP_START DATAEND
1097 # define OS_TYPE "SCO"
1099 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1101 +((word)etext & 0xfff))
1102 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1105 # define OS_TYPE "SCO_ELF"
1107 # define DATASTART ((ptr_t)(etext))
1108 # define STACKBOTTOM ((ptr_t) 0x08048000)
1109 # define DYNAMIC_LOADING
1110 # define ELF_CLASS ELFCLASS32
1113 # define OS_TYPE "DGUX"
1114 extern int _etext, _end;
1115 extern ptr_t GC_SysVGetDataStart();
1116 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1117 # define DATAEND (&_end)
1118 # define STACK_GROWS_DOWN
1120 # include <unistd.h>
1121 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1122 # define DYNAMIC_LOADING
1125 # endif /* USE_MMAP */
1126 # define MAP_FAILED (void *) -1
1128 # define HEAP_START (ptr_t)0x40000000
1129 # else /* USE_MMAP */
1130 # define HEAP_START DATAEND
1131 # endif /* USE_MMAP */
1136 /* The Intel compiler doesn't like inline assembly */
1137 # define USE_GENERIC_PUSH_REGS
1139 # define OS_TYPE "LINUX"
1140 # define LINUX_STACKBOTTOM
1144 # define STACK_GRAN 0x10000000
1145 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1146 /* different kernel configurations. In particular, systems */
1147 /* with 2GB physical memory will usually move the user */
1148 /* address space limit, and hence initial SP to 0x80000000. */
1150 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1151 # define MPROTECT_VDB
1153 /* We seem to get random errors in incremental mode, */
1154 /* possibly because Linux threads is itself a malloc client */
1155 /* and can't deal with the signals. */
1157 # define HEAP_START (ptr_t)0x1000
1158 /* This encourages mmap to give us low addresses, */
1159 /* thus allowing the heap to grow to ~3GB */
1161 # define DYNAMIC_LOADING
1162 # ifdef UNDEFINED /* includes ro data */
1163 extern int _etext[];
1164 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1166 # include <features.h>
1167 # if defined(__GLIBC__) && __GLIBC__ >= 2
1168 # define SEARCH_FOR_DATA_START
1170 extern char **__environ;
1171 # define DATASTART ((ptr_t)(&__environ))
1172 /* hideous kludge: __environ is the first */
1173 /* word in crt0.o, and delimits the start */
1174 /* of the data segment, no matter which */
1175 /* ld options were passed through. */
1176 /* We could use _etext instead, but that */
1177 /* would include .rodata, which may */
1178 /* contain large read-only data tables */
1179 /* that we'd rather not scan. */
1182 # define DATAEND (_end)
1185 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1187 # ifdef USE_I686_PREFETCH
1188 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1189 /* for the next rtelease. */
1190 # define PREFETCH(x) \
1191 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1192 /* Empirically prefetcht0 is much more effective at reducing */
1193 /* cache miss stalls for the targetted load instructions. But it */
1194 /* seems to interfere enough with other cache traffic that the net */
1195 /* result is worse than prefetchnta. */
1197 /* Using prefetches for write seems to have a slight negative */
1198 /* impact on performance, at least for a PIII/500. */
1199 # define PREFETCH_FOR_WRITE(x) \
1200 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1203 # ifdef USE_3DNOW_PREFETCH
1204 # define PREFETCH(x) \
1205 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1206 # define PREFETCH_FOR_WRITE(x) \
1207 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1211 # define OS_TYPE "CYGWIN32"
1212 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1213 # define DATAEND ((ptr_t)GC_DATAEND)
1215 # define STACK_GRAN 0x10000
1219 # define OS_TYPE "OS2"
1220 /* STACKBOTTOM and DATASTART are handled specially in */
1221 /* os_dep.c. OS2 actually has the right */
1223 # define DATAEND /* not needed */
1224 # define USE_GENERIC_PUSH_REGS
1227 # define OS_TYPE "MSWIN32"
1228 /* STACKBOTTOM and DATASTART are handled specially in */
1230 # ifndef __WATCOMC__
1231 # define MPROTECT_VDB
1233 # define DATAEND /* not needed */
1236 # define OS_TYPE "MSWINCE"
1237 # define DATAEND /* not needed */
1240 # define OS_TYPE "DJGPP"
1241 # include "stubinfo.h"
1244 extern int __djgpp_stack_limit;
1245 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1246 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1248 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1249 /* This may not be right. */
1252 # define OS_TYPE "OPENBSD"
1255 # define OS_TYPE "FREEBSD"
1256 # ifndef GC_FREEBSD_THREADS
1257 # define MPROTECT_VDB
1260 # define SIG_SUSPEND (32+6)
1261 # define SIG_THR_RESTART (32+5)
1263 # define DATAEND (_end)
1265 # define SIG_SUSPEND SIGUSR1
1266 # define SIG_THR_RESTART SIGUSR2
1268 # define FREEBSD_STACKBOTTOM
1270 # define DYNAMIC_LOADING
1272 extern char etext[];
1273 extern char * GC_FreeBSDGetDataStart();
1274 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1277 # define OS_TYPE "NETBSD"
1279 # define DYNAMIC_LOADING
1283 # define OS_TYPE "THREE86BSD"
1286 # define OS_TYPE "BSDI"
1288 # if defined(OPENBSD) || defined(NETBSD) \
1289 || defined(THREE86BSD) || defined(BSDI)
1291 extern char etext[];
1292 # define DATASTART ((ptr_t)(etext))
1295 # define OS_TYPE "NEXT"
1296 # define DATASTART ((ptr_t) get_etext())
1297 # define STACKBOTTOM ((ptr_t)0xc0000000)
1298 # define DATAEND /* not needed */
1301 # define OS_TYPE "DOS4GW"
1302 extern long __nullarea;
1304 extern char *_STACKTOP;
1305 /* Depending on calling conventions Watcom C either precedes
1306 or does not precedes with undescore names of C-variables.
1307 Make sure startup code variables always have the same names. */
1308 #pragma aux __nullarea "*";
1309 #pragma aux _end "*";
1310 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1311 /* confused? me too. */
1312 # define DATASTART ((ptr_t) &__nullarea)
1313 # define DATAEND ((ptr_t) &_end)
1316 # define OS_TYPE "HURD"
1317 # define STACK_GROWS_DOWN
1319 extern int __data_start[];
1320 # define DATASTART ( (ptr_t) (__data_start))
1322 # define DATAEND ( (ptr_t) (_end))
1323 /* # define MPROTECT_VDB Not quite working yet? */
1324 # define DYNAMIC_LOADING
1327 # define OS_TYPE "DARWIN"
1328 # define DARWIN_DONT_PARSE_STACK
1329 # define DYNAMIC_LOADING
1330 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
1331 These aren't used when dyld support is enabled (it is by default) */
1332 # define DATASTART ((ptr_t) get_etext())
1333 # define DATAEND ((ptr_t) get_end())
1334 # define STACKBOTTOM ((ptr_t) 0xc0000000)
1336 # define USE_MMAP_ANON
1337 # define USE_ASM_PUSH_REGS
1338 # ifdef GC_DARWIN_THREADS
1339 # define MPROTECT_VDB
1341 # include <unistd.h>
1342 # define GETPAGESIZE() getpagesize()
1343 /* There seems to be some issues with trylock hanging on darwin. This
1344 should be looked into some more */
1345 # define NO_PTHREAD_TRYLOCK
1346 # endif /* DARWIN */
1350 # define MACH_TYPE "NS32K"
1351 # define ALIGNMENT 4
1352 extern char **environ;
1353 # define DATASTART ((ptr_t)(&environ))
1354 /* hideous kludge: environ is the first */
1355 /* word in crt0.o, and delimits the start */
1356 /* of the data segment, no matter which */
1357 /* ld options were passed through. */
1358 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1362 # define MACH_TYPE "MIPS"
1364 /* This was developed for a linuxce style platform. Probably */
1365 /* needs to be tweaked for workstation class machines. */
1366 # define OS_TYPE "LINUX"
1367 # define DYNAMIC_LOADING
1369 # define DATAEND (_end)
1370 extern int __data_start[];
1371 # define DATASTART ((ptr_t)(__data_start))
1373 # define CPP_WORDSZ _MIPS_SZPTR
1374 # define ALIGNMENT (_MIPS_SZPTR/8)
1376 # define ALIGNMENT 4
1378 # define USE_GENERIC_PUSH_REGS
1379 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1380 # define LINUX_STACKBOTTOM
1382 # define STACKBOTTOM 0x80000000
1387 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1388 extern int _fdata[], _end[];
1389 # define DATASTART ((ptr_t)_fdata)
1390 # define DATAEND ((ptr_t)_end)
1391 # define CPP_WORDSZ _MIPS_SZPTR
1392 # define ALIGNMENT (_MIPS_SZPTR/8)
1394 extern int etext[], edata[], end[];
1395 extern int _DYNAMIC_LINKING[], _gp[];
1396 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1397 + ((word)etext & 0xffff)))
1398 # define DATAEND (edata)
1399 # define DATASTART2 (_DYNAMIC_LINKING \
1400 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1402 # define DATAEND2 (end)
1403 # define ALIGNMENT 4
1405 # define OS_TYPE "EWS4800"
1406 # define USE_GENERIC_PUSH_REGS 1
1410 # define DATASTART (ptr_t)0x10000000
1411 /* Could probably be slightly higher since */
1412 /* startup code allocates lots of stuff. */
1413 # define OS_TYPE "ULTRIX"
1414 # define ALIGNMENT 4
1418 # define DATASTART (ptr_t)0x10000000
1419 # define OS_TYPE "RISCOS"
1420 # define ALIGNMENT 4 /* Required by hardware */
1424 extern int _fdata[];
1425 # define DATASTART ((ptr_t)(_fdata))
1427 # define HEAP_START (ptr_t)0x30000000
1429 # define HEAP_START DATASTART
1431 /* Lowest plausible heap address. */
1432 /* In the MMAP case, we map there. */
1433 /* In either case it is used to identify */
1434 /* heap sections so they're not */
1435 /* considered as roots. */
1436 # define OS_TYPE "IRIX5"
1437 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1438 /* of recent breakage. */
1440 # define CPP_WORDSZ _MIPS_SZPTR
1441 # define ALIGNMENT (_MIPS_SZPTR/8)
1442 # if CPP_WORDSZ != 64
1443 # define ALIGN_DOUBLE
1446 # define ALIGNMENT 4
1447 # define ALIGN_DOUBLE
1449 # define DYNAMIC_LOADING
1452 # define OS_TYPE "MSWINCE"
1453 # define ALIGNMENT 4
1454 # define DATAEND /* not needed */
1456 # if defined(NETBSD)
1457 # define ALIGNMENT 4
1458 # define OS_TYPE "NETBSD"
1460 # define USE_GENERIC_PUSH_REGS
1463 # define DATASTART GC_data_start
1464 # define NEED_FIND_LIMIT
1465 # define DYNAMIC_LOADING
1467 # define DATASTART ((ptr_t) 0x10000000)
1468 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1474 # define MACH_TYPE "RS6000"
1479 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1482 # define ALIGNMENT 8
1483 # define CPP_WORDSZ 64
1484 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1486 # define ALIGNMENT 4
1487 # define CPP_WORDSZ 32
1488 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1491 # define USE_MMAP_ANON
1492 /* From AIX linker man page:
1493 _text Specifies the first location of the program.
1494 _etext Specifies the first location after the program.
1495 _data Specifies the first location of the data.
1496 _edata Specifies the first location after the initialized data
1497 _end or end Specifies the first location after all data.
1499 extern int _data[], _end[];
1500 # define DATASTART ((ptr_t)((ulong)_data))
1501 # define DATAEND ((ptr_t)((ulong)_end))
1503 # define USE_GENERIC_PUSH_REGS
1504 # define DYNAMIC_LOADING
1505 /* For really old versions of AIX, this may have to be removed. */
1509 # define MACH_TYPE "HP_PA"
1511 # define CPP_WORDSZ 64
1512 # define ALIGNMENT 8
1514 # define CPP_WORDSZ 32
1515 # define ALIGNMENT 4
1516 # define ALIGN_DOUBLE
1518 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1519 # ifndef LINUX /* For now. */
1520 # define MPROTECT_VDB
1523 # define GENERIC_COMPARE_AND_SWAP
1524 /* No compare-and-swap instruction. Use pthread mutexes */
1525 /* when we absolutely have to. */
1526 # ifdef PARALLEL_MARK
1527 # define USE_MARK_BYTES
1528 /* Minimize compare-and-swap usage. */
1531 # define STACK_GROWS_UP
1533 # define OS_TYPE "HPUX"
1534 extern int __data_start[];
1535 # define DATASTART ((ptr_t)(__data_start))
1537 /* The following appears to work for 7xx systems running HP/UX */
1538 /* 9.xx Furthermore, it might result in much faster */
1539 /* collections than HEURISTIC2, which may involve scanning */
1540 /* segments that directly precede the stack. It is not the */
1541 /* default, since it may not work on older machine/OS */
1542 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1544 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1546 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1547 /* to this. Note that the GC must be initialized before the */
1548 /* first putenv call. */
1549 extern char ** environ;
1550 # define STACKBOTTOM ((ptr_t)environ)
1552 # define DYNAMIC_LOADING
1553 # include <unistd.h>
1554 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1556 # define PREFETCH(x) { \
1557 register long addr = (long)(x); \
1558 (void) _asm ("LDW", 0, 0, addr, 0); \
1563 # define OS_TYPE "LINUX"
1564 # define LINUX_STACKBOTTOM
1565 # define DYNAMIC_LOADING
1566 # define SEARCH_FOR_DATA_START
1568 # define DATAEND (&_end)
1573 # define MACH_TYPE "ALPHA"
1574 # define ALIGNMENT 8
1575 # define CPP_WORDSZ 64
1577 # define USE_GENERIC_PUSH_REGS
1578 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1579 /* fp registers in some cases when the target is a 21264. The assembly */
1580 /* code doesn't handle that yet, and version dependencies make that a */
1581 /* bit tricky. Do the easy thing for now. */
1584 # define OS_TYPE "NETBSD"
1586 # define DATASTART GC_data_start
1587 # define ELFCLASS32 32
1588 # define ELFCLASS64 64
1589 # define ELF_CLASS ELFCLASS64
1590 # define DYNAMIC_LOADING
1593 # define OS_TYPE "OPENBSD"
1595 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1596 # define DATASTART GC_data_start
1597 # define ELFCLASS32 32
1598 # define ELFCLASS64 64
1599 # define ELF_CLASS ELFCLASS64
1600 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1601 # define DATASTART ((ptr_t) 0x140000000)
1605 # define OS_TYPE "FREEBSD"
1606 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1607 # define SIG_SUSPEND SIGUSR1
1608 # define SIG_THR_RESTART SIGUSR2
1609 # define FREEBSD_STACKBOTTOM
1611 # define DYNAMIC_LOADING
1613 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1614 extern char etext[];
1615 extern char edata[];
1617 # define NEED_FIND_LIMIT
1618 # define DATASTART ((ptr_t)(&etext))
1619 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1620 # define DATASTART2 ((ptr_t)(&edata))
1621 # define DATAEND2 ((ptr_t)(&end))
1624 # define OS_TYPE "OSF1"
1625 # define DATASTART ((ptr_t) 0x140000000)
1627 # define DATAEND ((ptr_t) &_end)
1628 extern char ** environ;
1629 /* round up from the value of environ to the nearest page boundary */
1630 /* Probably breaks if putenv is called before collector */
1631 /* initialization. */
1632 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1633 /* # define HEURISTIC2 */
1634 /* Normally HEURISTIC2 is too conervative, since */
1635 /* the text segment immediately follows the stack. */
1636 /* Hence we give an upper pound. */
1637 /* This is currently unused, since we disabled HEURISTIC2 */
1638 extern int __start[];
1639 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1640 # ifndef GC_OSF1_THREADS
1641 /* Unresolved signal issues with threads. */
1642 # define MPROTECT_VDB
1644 # define DYNAMIC_LOADING
1647 # define OS_TYPE "LINUX"
1648 # define LINUX_STACKBOTTOM
1650 # define SEARCH_FOR_DATA_START
1651 # define DYNAMIC_LOADING
1653 # define DATASTART ((ptr_t) 0x140000000)
1656 # define DATAEND (_end)
1657 # define MPROTECT_VDB
1658 /* Has only been superficially tested. May not */
1659 /* work on all versions. */
1664 # define MACH_TYPE "IA64"
1665 # define USE_GENERIC_PUSH_REGS
1666 /* We need to get preserved registers in addition to register */
1667 /* windows. That's easiest to do with setjmp. */
1668 # ifdef PARALLEL_MARK
1669 # define USE_MARK_BYTES
1670 /* Compare-and-exchange is too expensive to use for */
1671 /* setting mark bits. */
1675 # define CPP_WORDSZ 32
1676 # define ALIGN_DOUBLE
1677 /* Requires 8 byte alignment for malloc */
1678 # define ALIGNMENT 4
1683 # define CPP_WORDSZ 64
1684 # define ALIGN_DOUBLE
1685 /* Requires 16 byte alignment for malloc */
1686 # define ALIGNMENT 8
1688 # define OS_TYPE "HPUX"
1689 extern int __data_start[];
1690 # define DATASTART ((ptr_t)(__data_start))
1691 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1692 /* to this. Note that the GC must be initialized before the */
1693 /* first putenv call. */
1694 extern char ** environ;
1695 # define STACKBOTTOM ((ptr_t)environ)
1696 # define HPUX_STACKBOTTOM
1697 # define DYNAMIC_LOADING
1698 # include <unistd.h>
1699 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1700 /* The following was empirically determined, and is probably */
1701 /* not very robust. */
1702 /* Note that the backing store base seems to be at a nice */
1703 /* address minus one page. */
1704 # define BACKING_STORE_DISPLACEMENT 0x1000000
1705 # define BACKING_STORE_ALIGNMENT 0x1000
1706 extern ptr_t GC_register_stackbottom;
1707 # define BACKING_STORE_BASE GC_register_stackbottom
1708 /* Known to be wrong for recent HP/UX versions!!! */
1711 # define CPP_WORDSZ 64
1712 # define ALIGN_DOUBLE
1713 /* Requires 16 byte alignment for malloc */
1714 # define ALIGNMENT 8
1715 # define OS_TYPE "LINUX"
1716 /* The following works on NUE and older kernels: */
1717 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1718 /* This does not work on NUE: */
1719 # define LINUX_STACKBOTTOM
1720 /* We also need the base address of the register stack */
1721 /* backing store. This is computed in */
1722 /* GC_linux_register_stack_base based on the following */
1724 # define BACKING_STORE_ALIGNMENT 0x100000
1725 # define BACKING_STORE_DISPLACEMENT 0x80000000
1726 extern ptr_t GC_register_stackbottom;
1727 # define BACKING_STORE_BASE GC_register_stackbottom
1728 # define SEARCH_FOR_DATA_START
1730 # define DYNAMIC_LOADING
1732 /* In the Intel compiler environment, we seem to end up with */
1733 /* statically linked executables and an undefined reference */
1736 # define MPROTECT_VDB
1737 /* Requires Linux 2.3.47 or later. */
1739 # define DATAEND (_end)
1741 # ifndef __INTEL_COMPILER
1742 # define PREFETCH(x) \
1743 __asm__ (" lfetch [%0]": : "r"(x))
1744 # define PREFETCH_FOR_WRITE(x) \
1745 __asm__ (" lfetch.excl [%0]": : "r"(x))
1746 # define CLEAR_DOUBLE(x) \
1747 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1749 # include <ia64intrin.h>
1750 # define PREFETCH(x) \
1751 __lfetch(__lfhint_none, (x))
1752 # define PREFETCH_FOR_WRITE(x) \
1753 __lfetch(__lfhint_nta, (x))
1754 # define CLEAR_DOUBLE(x) \
1755 __stf_spill((void *)(x), 0)
1756 # endif // __INTEL_COMPILER
1760 /* FIXME: This is a very partial guess. There is no port, yet. */
1761 # define OS_TYPE "MSWIN32"
1762 /* STACKBOTTOM and DATASTART are handled specially in */
1764 # define DATAEND /* not needed */
1765 # if defined(_WIN64)
1766 # define CPP_WORDSZ 64
1768 # define CPP_WORDSZ 32 /* Is this possible? */
1770 # define ALIGNMENT 8
1775 # define MACH_TYPE "M88K"
1776 # define ALIGNMENT 4
1777 # define ALIGN_DOUBLE
1780 # define OS_TYPE "CX_UX"
1781 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1784 # define OS_TYPE "DGUX"
1785 extern ptr_t GC_SysVGetDataStart();
1786 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1788 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1792 /* If this still works, and if anyone cares, this should probably */
1793 /* be moved to the S390 category. */
1794 # define MACH_TYPE "S370"
1795 # define ALIGNMENT 4 /* Required by hardware */
1796 # define USE_GENERIC_PUSH_REGS
1798 # define OS_TYPE "UTS4"
1800 extern int _etext[];
1802 extern ptr_t GC_SysVGetDataStart();
1803 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1804 # define DATAEND (_end)
1810 # define MACH_TYPE "S390"
1811 # define USE_GENERIC_PUSH_REGS
1813 # define ALIGNMENT 4
1814 # define CPP_WORDSZ 32
1816 # define ALIGNMENT 8
1817 # define CPP_WORDSZ 64
1820 # define HBLKSIZE 4096
1823 # define OS_TYPE "LINUX"
1824 # define LINUX_STACKBOTTOM
1825 # define DYNAMIC_LOADING
1826 extern int __data_start[];
1827 # define DATASTART ((ptr_t)(__data_start))
1829 # define DATAEND (_end)
1830 # define CACHE_LINE_SIZE 256
1831 # define GETPAGESIZE() 4096
1836 # define ALIGNMENT 4
1837 extern int _etext[];
1838 # define DATASTART ((ptr_t)(_etext))
1843 # define CPP_WORDSZ 32
1844 # define MACH_TYPE "ARM32"
1845 # define ALIGNMENT 4
1847 # define OS_TYPE "NETBSD"
1850 # define DATASTART GC_data_start
1851 # define DYNAMIC_LOADING
1853 extern char etext[];
1854 # define DATASTART ((ptr_t)(etext))
1856 # define USE_GENERIC_PUSH_REGS
1859 # define OS_TYPE "LINUX"
1860 # define LINUX_STACKBOTTOM
1862 # define STACK_GRAN 0x10000000
1863 # define USE_GENERIC_PUSH_REGS
1865 # define DYNAMIC_LOADING
1866 # include <features.h>
1867 # if defined(__GLIBC__) && __GLIBC__ >= 2
1868 # define SEARCH_FOR_DATA_START
1870 extern char **__environ;
1871 # define DATASTART ((ptr_t)(&__environ))
1872 /* hideous kludge: __environ is the first */
1873 /* word in crt0.o, and delimits the start */
1874 /* of the data segment, no matter which */
1875 /* ld options were passed through. */
1876 /* We could use _etext instead, but that */
1877 /* would include .rodata, which may */
1878 /* contain large read-only data tables */
1879 /* that we'd rather not scan. */
1882 # define DATAEND (_end)
1885 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1889 # define OS_TYPE "MSWINCE"
1890 # define DATAEND /* not needed */
1893 /* __data_start is usually defined in the target linker script. */
1894 extern int __data_start[];
1895 # define DATASTART (ptr_t)(__data_start)
1896 # define USE_GENERIC_PUSH_REGS
1897 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1898 extern void *__stack_base__;
1899 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1904 # define MACH_TYPE "CRIS"
1905 # define CPP_WORDSZ 32
1906 # define ALIGNMENT 1
1907 # define OS_TYPE "LINUX"
1908 # define DYNAMIC_LOADING
1909 # define LINUX_STACKBOTTOM
1910 # define USE_GENERIC_PUSH_REGS
1911 # define SEARCH_FOR_DATA_START
1913 # define DATAEND (_end)
1917 # define MACH_TYPE "SH"
1918 # define ALIGNMENT 4
1920 # define OS_TYPE "MSWINCE"
1921 # define DATAEND /* not needed */
1924 # define OS_TYPE "LINUX"
1925 # define LINUX_STACKBOTTOM
1926 # define USE_GENERIC_PUSH_REGS
1927 # define DYNAMIC_LOADING
1928 # define SEARCH_FOR_DATA_START
1930 # define DATAEND (_end)
1933 # define OS_TYPE "NETBSD"
1935 # define DATASTART GC_data_start
1936 # define USE_GENERIC_PUSH_REGS
1937 # define DYNAMIC_LOADING
1942 # define MACH_TYPE "SH4"
1943 # define OS_TYPE "MSWINCE"
1944 # define ALIGNMENT 4
1945 # define DATAEND /* not needed */
1949 # define CPP_WORDSZ 32
1950 # define MACH_TYPE "M32R"
1951 # define ALIGNMENT 4
1953 # define OS_TYPE "LINUX"
1954 # define LINUX_STACKBOTTOM
1956 # define STACK_GRAN 0x10000000
1957 # define USE_GENERIC_PUSH_REGS
1958 # define DYNAMIC_LOADING
1959 # define SEARCH_FOR_DATA_START
1961 # define DATAEND (_end)
1966 # define MACH_TYPE "X86_64"
1967 # define ALIGNMENT 8
1968 # define CPP_WORDSZ 64
1970 # define HBLKSIZE 4096
1972 # define CACHE_LINE_SIZE 64
1973 # define USE_GENERIC_PUSH_REGS
1975 # define OS_TYPE "LINUX"
1976 # define LINUX_STACKBOTTOM
1977 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1978 # define MPROTECT_VDB
1980 /* We seem to get random errors in incremental mode, */
1981 /* possibly because Linux threads is itself a malloc client */
1982 /* and can't deal with the signals. */
1985 # define DYNAMIC_LOADING
1986 # ifdef UNDEFINED /* includes ro data */
1987 extern int _etext[];
1988 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1990 # include <features.h>
1991 # define SEARCH_FOR_DATA_START
1993 # define DATAEND (_end)
1996 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1998 # if defined(__GNUC__) && __GNUC >= 3
1999 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2000 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2004 # define OS_TYPE "DARWIN"
2005 # define DARWIN_DONT_PARSE_STACK
2006 # define DYNAMIC_LOADING
2007 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
2008 These aren't used when dyld support is enabled (it is by default) */
2009 # define DATASTART ((ptr_t) get_etext())
2010 # define DATAEND ((ptr_t) get_end())
2011 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
2013 # define USE_MMAP_ANON
2014 # ifdef GC_DARWIN_THREADS
2015 # define MPROTECT_VDB
2017 # include <unistd.h>
2018 # define GETPAGESIZE() getpagesize()
2019 /* There seems to be some issues with trylock hanging on darwin. This
2020 should be looked into some more */
2021 # define NO_PTHREAD_TRYLOCK
2024 # define OS_TYPE "FREEBSD"
2025 # ifndef GC_FREEBSD_THREADS
2026 # define MPROTECT_VDB
2029 # define SIG_SUSPEND (32+6)
2030 # define SIG_THR_RESTART (32+5)
2032 # define DATAEND (_end)
2034 # define SIG_SUSPEND SIGUSR1
2035 # define SIG_THR_RESTART SIGUSR2
2037 # define FREEBSD_STACKBOTTOM
2039 # define DYNAMIC_LOADING
2041 extern char etext[];
2042 extern char * GC_FreeBSDGetDataStart();
2043 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2046 # define OS_TYPE "NETBSD"
2048 # define DYNAMIC_LOADING
2051 extern char etext[];
2052 # define SEARCH_FOR_DATA_START
2055 # define ELF_CLASS ELFCLASS64
2056 # define OS_TYPE "SUNOS5"
2057 extern int _etext[], _end[];
2058 extern ptr_t GC_SysVGetDataStart();
2059 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
2060 # define DATAEND (_end)
2061 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
2062 /* but reportedly breaks under 2.8. It appears that the stack */
2063 /* base is a property of the executable, so this should not break */
2064 /* old executables. */
2065 /* HEURISTIC2 probably works, but this appears to be preferable. */
2066 /* # include <sys/vm.h> */
2067 /* # define STACKBOTTOM USRSTACK */
2070 # define DYNAMIC_LOADING
2071 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
2073 /* Otherwise we now use calloc. Mmap may result in the */
2074 /* heap interleaved with thread stacks, which can result in */
2075 /* excessive blacklisting. Sbrk is unusable since it */
2076 /* doesn't interact correctly with the system malloc. */
2079 # define HEAP_START (ptr_t)0x40000000
2081 # define HEAP_START DATAEND
2086 #if defined(LINUX) && defined(USE_MMAP)
2087 /* The kernel may do a somewhat better job merging mappings etc. */
2088 /* with anonymous mappings. */
2089 # define USE_MMAP_ANON
2092 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2093 /* Rld appears to allocate some memory with its own allocator, and */
2094 /* some through malloc, which might be redirected. To make this */
2095 /* work with collectable memory, we have to scan memory allocated */
2096 /* by rld's internal malloc. */
2097 # define USE_PROC_FOR_LIBRARIES
2100 # ifndef STACK_GROWS_UP
2101 # define STACK_GROWS_DOWN
2105 # define CPP_WORDSZ 32
2114 # define DATAEND (end)
2117 # if defined(SVR4) && !defined(GETPAGESIZE)
2118 # include <unistd.h>
2119 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2122 # ifndef GETPAGESIZE
2123 # if defined(SUNOS5) || defined(IRIX5)
2124 # include <unistd.h>
2126 # define GETPAGESIZE() getpagesize()
2129 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2130 /* OS has SVR4 generic features. Probably others also qualify. */
2134 # if defined(SUNOS5) || defined(DRSNX)
2135 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2138 /* OS has SUNOS5 style signal handlers. */
2146 # if defined(FREEBSD) && ((__FreeBSD__ >= 4) || (__FreeBSD_kernel__ >= 4))
2150 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2151 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2152 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2153 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2154 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2157 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2162 # undef DYNAMIC_LOADING
2167 # undef MPROTECT_VDB
2172 /* Postponed for now. */
2174 # undef MPROTECT_VDB
2177 # ifdef SMALL_CONFIG
2178 /* Presumably not worth the space it takes. */
2180 # undef MPROTECT_VDB
2184 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2187 # ifdef PARALLEL_MARK
2188 # undef MPROTECT_VDB /* For now. */
2191 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2192 # define DEFAULT_VDB
2196 # define PREFETCH(x)
2197 # define NO_PREFETCH
2200 # ifndef PREFETCH_FOR_WRITE
2201 # define PREFETCH_FOR_WRITE(x)
2202 # define NO_PREFETCH_FOR_WRITE
2205 # ifndef CACHE_LINE_SIZE
2206 # define CACHE_LINE_SIZE 32 /* Wild guess */
2209 # if defined(LINUX) || defined(__GLIBC__)
2210 # define REGISTER_LIBRARIES_EARLY
2211 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2212 /* lock. This isn't safe after the world has stopped. So we must */
2213 /* call GC_register_dynamic_libraries before stopping the world. */
2214 /* For performance reasons, this may be beneficial on other */
2215 /* platforms as well, though it should be avoided in win32. */
2218 # if defined(SEARCH_FOR_DATA_START)
2219 extern ptr_t GC_data_start;
2220 # define DATASTART GC_data_start
2223 # ifndef CLEAR_DOUBLE
2224 # define CLEAR_DOUBLE(x) \
2225 ((word*)x)[0] = 0; \
2227 # endif /* CLEAR_DOUBLE */
2229 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2230 --> inconsistent configuration
2232 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
2233 --> inconsistent configuration
2235 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2236 --> inconsistent configuration
2238 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2239 --> inconsistent configuration
2241 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2242 --> inconsistent configuration
2244 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2245 --> inconsistent configuration
2248 # if defined(PCR) || defined(SRC_M3) || \
2249 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2250 defined(GC_PTHREADS)
2254 # if defined(HP_PA) || defined(M88K) \
2255 || defined(POWERPC) && !defined(DARWIN) \
2256 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2257 || (defined(I386) && defined(__LCC__))
2258 /* Use setjmp based hack to mark from callee-save registers. */
2259 /* The define should move to the individual platform */
2261 # define USE_GENERIC_PUSH_REGS
2264 # if defined(MSWINCE)
2269 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2270 /* include assembly code to do it well. */
2273 /* Can we save call chain in objects for debugging? */
2274 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2275 /* frame) to reasonable values for the platform. */
2276 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2277 /* at build time, though we feel free to adjust it slightly. */
2278 /* Define NEED_CALLINFO if we either save the call stack or */
2279 /* GC_ADD_CALLER is defined. */
2280 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2283 # define CAN_SAVE_CALL_ARGS
2285 #if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__))
2286 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2287 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2288 # define CAN_SAVE_CALL_ARGS
2291 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2292 && defined(GC_CAN_SAVE_CALL_STACKS)
2293 # define SAVE_CALL_CHAIN
2295 # ifdef SAVE_CALL_CHAIN
2296 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2297 # define NARGS SAVE_CALL_NARGS
2299 # define NARGS 0 /* Number of arguments to save for each call. */
2302 # ifdef SAVE_CALL_CHAIN
2303 # ifndef SAVE_CALL_COUNT
2304 # define NFRAMES 6 /* Number of frames to save. Even for */
2305 /* alignment reasons. */
2307 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2309 # define NEED_CALLINFO
2310 # endif /* SAVE_CALL_CHAIN */
2311 # ifdef GC_ADD_CALLER
2314 # define NEED_CALLINFO
2317 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2318 # define DBG_HDRS_ALL
2321 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2322 # define POINTER_SHIFT 0
2325 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2326 # define POINTER_MASK ((GC_word)(-1))
2329 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2330 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2333 # if defined(FIXUP_POINTER)
2334 # define NEED_FIXUP_POINTER 1
2336 # define NEED_FIXUP_POINTER 0
2337 # define FIXUP_POINTER(p)
2341 /* This relies on some type definitions from gc_priv.h, from */
2342 /* where it's normally included. */
2344 /* How to get heap memory from the OS: */
2345 /* Note that sbrk()-like allocation is preferred, since it */
2346 /* usually makes it possible to merge consecutively allocated */
2347 /* chunks. It also avoids unintented recursion with */
2348 /* -DREDIRECT_MALLOC. */
2349 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2350 /* 0 is taken to mean failure. */
2351 /* In the case os USE_MMAP, the argument must also be a */
2352 /* physical page size. */
2353 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2354 /* though we should perhaps take advantage of the case in which */
2356 struct hblk; /* See gc_priv.h. */
2358 char * real_malloc();
2359 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2363 void * os2_alloc(size_t bytes);
2364 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2368 # if defined(NEXT) || defined(DOS4GW) || \
2369 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2370 (defined(SUNOS5) && !defined(USE_MMAP))
2371 # define GET_MEM(bytes) HBLKPTR((size_t) \
2372 calloc(1, (size_t)bytes + GC_page_size) \
2376 extern ptr_t GC_win32_get_mem();
2377 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2380 # if defined(USE_TEMPORARY_MEMORY)
2381 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2382 Boolean clearMemory);
2383 # define GET_MEM(bytes) HBLKPTR( \
2384 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2387 # define GET_MEM(bytes) HBLKPTR( \
2388 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2392 extern ptr_t GC_wince_get_mem();
2393 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2395 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2396 extern void *GC_amiga_get_mem(size_t size);
2397 # define GET_MEM(bytes) HBLKPTR((size_t) \
2398 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2401 extern ptr_t GC_unix_get_mem();
2402 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2411 #endif /* GC_PRIVATE_H */
2413 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2414 /* IBMs xlc compiler doesn't appear to follow the convention of */
2415 /* defining __STDC__ to be zero in extended mode. */
2419 # endif /* GCCONFIG_H */