2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
5 * Copyright (c) 2000-2004 Hewlett-Packard Development Company, L.P.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
18 * This header is private to the gc. It is almost always included from
19 * gc_priv.h. However it is possible to include it by itself if just the
20 * configuration macros are needed. In that
21 * case, a few declarations relying on types declared in gc_priv.h will be
30 /* Fake ptr_t declaration, just to avoid compilation errors. */
31 /* This avoids many instances if "ifndef GC_PRIVATE_H" below. */
32 typedef struct GC_undefined_struct * ptr_t;
35 /* Machine dependent parameters. Some tuning parameters can be found */
36 /* near the top of gc_private.h. */
38 /* Machine specific parts contributed by various people. See README file. */
40 /* First a unified test for Linux: */
41 # if defined(linux) || defined(__linux__)
47 /* And one for NetBSD: */
48 # if defined(__NetBSD__)
52 /* And one for OpenBSD: */
53 # if defined(__OpenBSD__)
57 /* And one for FreeBSD: */
58 # if defined(__FreeBSD__) && !defined(FREEBSD)
62 /* And one for Darwin: */
63 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
67 /* Determine the machine type: */
68 # if defined(__arm__) || defined(__thumb__)
70 # if !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN)
72 # define mach_type_known
75 # if defined(sun) && defined(mc68000)
78 # define mach_type_known
80 # if defined(hp9000s300)
83 # define mach_type_known
85 # if defined(OPENBSD) && defined(m68k)
87 # define mach_type_known
89 # if defined(OPENBSD) && defined(__sparc__)
91 # define mach_type_known
93 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
95 # define mach_type_known
97 # if defined(NETBSD) && defined(__powerpc__)
99 # define mach_type_known
101 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
103 # define mach_type_known
105 # if defined(NETBSD) && defined(__sh__)
107 # define mach_type_known
116 # define mach_type_known
118 # if defined(__NetBSD__) && defined(__vax__)
120 # define mach_type_known
122 # if defined(mips) || defined(__mips) || defined(_mips)
124 # if defined(nec_ews) || defined(_nec_ews)
127 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
128 # if defined(ultrix) || defined(__ultrix)
131 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
132 || defined(__SYSTYPE_SVR4__)
133 # define IRIX5 /* or IRIX 6.X */
135 # define RISCOS /* or IRIX 4.X */
139 # if defined(__NetBSD__) && defined(__MIPSEL__)
142 # define mach_type_known
144 # if defined(DGUX) && (defined(i386) || defined(__i386__))
149 # define mach_type_known
151 # if defined(sequent) && (defined(i386) || defined(__i386__))
154 # define mach_type_known
156 # if defined(sun) && (defined(i386) || defined(__i386__))
159 # define mach_type_known
161 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
164 # define mach_type_known
168 # define mach_type_known
170 # if defined(sun) && (defined(sparc) || defined(__sparc))
172 /* Test for SunOS 5.x */
179 # define mach_type_known
181 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
182 && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
185 # define mach_type_known
189 # define mach_type_known
191 # if defined(__NetBSD__) && defined(__sparc__)
193 # define mach_type_known
195 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
196 /* The above test may need refinement */
198 # if defined(_SCO_ELF)
203 # define mach_type_known
205 # if defined(_AUX_SOURCE)
208 # define mach_type_known
210 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
211 || defined(hppa) || defined(__hppa__)
213 # if !defined(LINUX) && !defined(HPUX)
216 # define mach_type_known
218 # if defined(__ia64) && defined(_HPUX_SOURCE)
223 # define mach_type_known
225 # if defined(__BEOS__) && defined(_X86_)
228 # define mach_type_known
230 # if defined(LINUX) && (defined(i386) || defined(__i386__))
232 # define mach_type_known
234 # if defined(LINUX) && defined(__x86_64__)
236 # define mach_type_known
238 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
240 # define mach_type_known
242 # if defined(LINUX) && defined(__arm__)
244 # define mach_type_known
246 # if defined(LINUX) && defined(__cris__)
250 # define mach_type_known
252 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
253 defined(powerpc64) || defined(__powerpc64__))
255 # define mach_type_known
257 # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
259 # define mach_type_known
261 # if defined(LINUX) && defined(__mc68000__)
263 # define mach_type_known
265 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
267 # define mach_type_known
269 # if defined(LINUX) && defined(__arm__)
271 # define mach_type_known
273 # if defined(LINUX) && defined(__sh__)
275 # define mach_type_known
277 # if defined(LINUX) && defined(__m32r__)
279 # define mach_type_known
281 # if defined(__alpha) || defined(__alpha__)
283 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
284 # define OSF1 /* a.k.a Digital Unix */
286 # define mach_type_known
288 # if defined(_AMIGA) && !defined(AMIGA)
293 # define mach_type_known
295 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
298 # define mach_type_known
300 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
303 # define mach_type_known
306 # if defined(__ppc__) || defined(__ppc64__)
308 # define mach_type_known
309 # elif defined(__i386__)
311 # define mach_type_known
312 # define DARWIN_DONT_PARSE_STACK
313 # define OS_TYPE "DARWIN"
314 # define DYNAMIC_LOADING
315 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
316 These aren't used when dyld support is enabled (it is by default) */
317 # define DATASTART ((ptr_t) get_etext())
318 # define DATAEND ((ptr_t) get_end())
319 # define STACKBOTTOM ((ptr_t) 0xc0000000)
321 # define USE_MMAP_ANON
322 # define USE_ASM_PUSH_REGS
323 /* This is potentially buggy. It needs more testing. See the comments in
324 os_dep.c. It relies on threads to track writes. */
325 # ifdef GC_DARWIN_THREADS
326 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
329 # define GETPAGESIZE() getpagesize()
330 # elif defined(__arm__)
332 # define mach_type_known
333 # define DARWIN_DONT_PARSE_STACK
334 # define GC_DONT_REGISTER_MAIN_STATIC_DATA
337 # if defined(NeXT) && defined(mc68000)
340 # define mach_type_known
342 # if defined(NeXT) && (defined(i386) || defined(__i386__))
345 # define mach_type_known
347 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
350 # define mach_type_known
352 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
354 # define mach_type_known
356 # if defined(FREEBSD) && defined(__x86_64__)
358 # define mach_type_known
360 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
362 # define mach_type_known
364 # if defined(__NetBSD__) && defined(__x86_64__)
366 # define mach_type_known
368 # if defined(FREEBSD) && defined(__sparc__)
370 # define mach_type_known
372 # if defined(bsdi) && (defined(i386) || defined(__i386__))
375 # define mach_type_known
377 # if !defined(mach_type_known) && defined(__386BSD__)
380 # define mach_type_known
382 # if defined(_CX_UX) && defined(_M88K)
385 # define mach_type_known
387 # if defined(DGUX) && defined(m88k)
390 # define mach_type_known
392 # if defined(_WIN32_WCE)
393 /* SH3, SH4, MIPS already defined for corresponding architectures */
394 # if defined(SH3) || defined(SH4)
404 # define mach_type_known
406 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
407 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
408 # if defined(__LP64__) || defined(_WIN64)
\r
413 # define MSWIN32 /* or Win64 */
\r
414 # define mach_type_known
\r
416 # if defined(_MSC_VER) && defined(_M_IA64)
\r
418 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
\r
419 /* variants as a differnt platform. */
\r
422 # if defined(__DJGPP__)
425 # define DJGPP /* MSDOS running the DJGPP port of GCC */
427 # define mach_type_known
429 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
432 # define mach_type_known
434 # if defined(__MINGW32__)
437 # define mach_type_known
439 # if defined(__BORLANDC__)
442 # define mach_type_known
444 # if defined(_UTS) && !defined(mach_type_known)
447 # define mach_type_known
451 # define mach_type_known
453 # if defined(__embedded__) && defined(PPC)
456 # define mach_type_known
459 # if defined(__WATCOMC__) && defined(__386__)
461 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
462 # if defined(__OS2__)
465 # if defined(__WINDOWS_386__) || defined(__NT__)
472 # define mach_type_known
474 # if defined(__s390__) && defined(LINUX)
476 # define mach_type_known
478 # if defined(__GNU__)
479 # if defined(__i386__)
480 /* The Debian Hurd running on generic PC */
483 # define mach_type_known
487 /* Feel free to add more clauses here */
489 /* Or manually define the machine type here. A machine type is */
490 /* characterized by the architecture. Some */
491 /* machine types are further subdivided by OS. */
492 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
493 /* Note that SGI IRIX is treated identically to RISCOS. */
494 /* SYSV on an M68K actually means A/UX. */
495 /* The distinction in these cases is usually the stack starting address */
496 # ifndef mach_type_known
497 --> unknown machine type
499 /* Mapping is: M68K ==> Motorola 680X0 */
500 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
501 /* MACOS and AMIGA variants) */
502 /* I386 ==> Intel 386 */
503 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
504 /* FREEBSD, THREE86BSD, MSWIN32, */
505 /* BSDI,SUNOS5, NEXT, other variants) */
506 /* NS32K ==> Encore Multimax */
507 /* MIPS ==> R2000 or R3000 */
508 /* (RISCOS, ULTRIX variants) */
509 /* VAX ==> DEC VAX */
510 /* (BSD, ULTRIX variants) */
511 /* RS6000 ==> IBM RS/6000 AIX3.X */
512 /* RT ==> IBM PC/RT */
513 /* HP_PA ==> HP9000/700 & /800 */
515 /* SPARC ==> SPARC v7/v8/v9 */
516 /* (SUNOS4, SUNOS5, LINUX, */
517 /* DRSNX variants) */
518 /* ALPHA ==> DEC Alpha */
519 /* (OSF1 and LINUX variants) */
520 /* M88K ==> Motorola 88XX0 */
521 /* (CX_UX and DGUX) */
522 /* S370 ==> 370-like machine */
523 /* running Amdahl UTS4 */
524 /* S390 ==> 390-like machine */
526 /* ARM32 ==> Intel StrongARM */
527 /* IA64 ==> Intel IPF */
529 /* (LINUX and HPUX) */
530 /* SH ==> Hitachi SuperH */
531 /* (LINUX & MSWINCE) */
532 /* X86_64 ==> AMD x86-64 */
533 /* POWERPC ==> IBM/Apple PowerPC */
534 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
535 /* LINUX, NETBSD, NOSYS variants) */
536 /* Handles 32 and 64-bit variants. */
537 /* AIX should be handled here, but */
538 /* that's called an RS6000. */
539 /* CRIS ==> Axis Etrax */
540 /* M32R ==> Renesas M32R */
544 * For each architecture and OS, the following need to be defined:
546 * CPP_WORDSZ is a simple integer constant representing the word size.
547 * in bits. We assume byte addressibility, where a byte has 8 bits.
548 * We also assume CPP_WORDSZ is either 32 or 64.
549 * (We care about the length of pointers, not hardware
550 * bus widths. Thus a 64 bit processor with a C compiler that uses
551 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
553 * MACH_TYPE is a string representation of the machine type.
554 * OS_TYPE is analogous for the OS.
556 * ALIGNMENT is the largest N, such that
557 * all pointer are guaranteed to be aligned on N byte boundaries.
558 * defining it to be 1 will always work, but perform poorly.
560 * DATASTART is the beginning of the data segment.
561 * On some platforms SEARCH_FOR_DATA_START is defined.
562 * SEARCH_FOR_DATASTART will cause GC_data_start to
563 * be set to an address determined by accessing data backwards from _end
564 * until an unmapped page is found. DATASTART will be defined to be
566 * On UNIX-like systems, the collector will scan the area between DATASTART
567 * and DATAEND for root pointers.
569 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
570 * RTH suggests gaining access to linker script synth'd values with
571 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
572 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
573 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
574 * without any special options.
576 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
579 * STACKBOTTOM is the cool end of the stack, which is usually the
580 * highest address in the stack.
581 * Under PCR or OS/2, we have other ways of finding thread stacks.
582 * For each machine, the following should:
583 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
584 * 2) define exactly one of
585 * STACKBOTTOM (should be defined to be an expression)
589 * If STACKBOTTOM is defined, then it's value will be used directly as the
590 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
591 * with a method appropriate for most Linux systems. Currently we look
592 * first for __libc_stack_end, and if that fails read it from /proc.
593 * If either of the last two macros are defined, then STACKBOTTOM is computed
594 * during collector startup using one of the following two heuristics:
595 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
596 * the next multiple of STACK_GRAN.
597 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
598 * in small steps (decrement if STACK_GROWS_UP), and read the value
599 * at each location. Remember the value when the first
600 * Segmentation violation or Bus error is signalled. Round that
601 * to the nearest plausible page boundary, and use that instead
604 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
605 * the value of environ is a pointer that can serve as STACKBOTTOM.
606 * I expect that HEURISTIC2 can be replaced by this approach, which
607 * interferes far less with debugging. However it has the disadvantage
608 * that it's confused by a putenv call before the collector is initialized.
609 * This could be dealt with by intercepting putenv ...
611 * If no expression for STACKBOTTOM can be found, and neither of the above
612 * heuristics are usable, the collector can still be used with all of the above
613 * undefined, provided one of the following is done:
614 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
615 * without reference to STACKBOTTOM. This is appropriate for use in
616 * conjunction with thread packages, since there will be multiple stacks.
617 * (Allocating thread stacks in the heap, and treating them as ordinary
618 * heap data objects is also possible as a last resort. However, this is
619 * likely to introduce significant amounts of excess storage retention
620 * unless the dead parts of the thread stacks are periodically cleared.)
621 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
622 * If the author of the client code controls the main program, this is
623 * easily accomplished by introducing a new main program, setting
624 * GC_stackbottom to the address of a local variable, and then calling
625 * the original main program. The new main program would read something
628 * # include "gc_private.h"
630 * main(argc, argv, envp)
632 * char **argv, **envp;
636 * GC_stackbottom = (ptr_t)(&dummy);
637 * return(real_main(argc, argv, envp));
641 * Each architecture may also define the style of virtual dirty bit
642 * implementation to be used:
643 * MPROTECT_VDB: Write protect the heap and catch faults.
644 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
646 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
647 * defined GC_register_dynamic_libraries() for the architecture.
649 * An architecture may define PREFETCH(x) to preload the cache with *x.
650 * This defaults to a no-op.
652 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
654 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
655 * clear the two words at GC_malloc-aligned address x. By default,
656 * word stores of 0 are used instead.
658 * HEAP_START may be defined as the initial address hint for mmap-based
662 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
663 * to push the relevant registers onto the stack. This generally makes
664 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
666 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
667 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
668 && !defined(__INTEL_COMPILER) \
669 && !defined(__PATHCC__)
670 # define HAVE_BUILTIN_UNWIND_INIT
673 # define STACK_GRAN 0x1000000
675 # define MACH_TYPE "M68K"
678 # define OS_TYPE "OPENBSD"
681 # define DATASTART GC_data_start
682 # define DYNAMIC_LOADING
685 # define DATASTART ((ptr_t)(etext))
687 # define USE_GENERIC_PUSH_REGS
690 # define OS_TYPE "NETBSD"
693 # define DATASTART GC_data_start
694 # define DYNAMIC_LOADING
697 # define DATASTART ((ptr_t)(etext))
699 # define USE_GENERIC_PUSH_REGS
702 # define OS_TYPE "LINUX"
703 # define STACKBOTTOM ((ptr_t)0xf0000000)
704 # define USE_GENERIC_PUSH_REGS
705 /* We never got around to the assembly version. */
706 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
708 # define DYNAMIC_LOADING
709 # include <features.h>
710 # if defined(__GLIBC__)&& __GLIBC__>=2
711 # define SEARCH_FOR_DATA_START
713 extern char **__environ;
714 # define DATASTART ((ptr_t)(&__environ))
715 /* hideous kludge: __environ is the first */
716 /* word in crt0.o, and delimits the start */
717 /* of the data segment, no matter which */
718 /* ld options were passed through. */
719 /* We could use _etext instead, but that */
720 /* would include .rodata, which may */
721 /* contain large read-only data tables */
722 /* that we'd rather not scan. */
723 # endif /* !GLIBC2 */
725 # define DATAEND (_end)
728 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
732 # define OS_TYPE "SUNOS4"
734 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
735 # define HEURISTIC1 /* differs */
736 # define DYNAMIC_LOADING
739 # define OS_TYPE "HP"
741 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
742 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
743 /* empirically determined. seems to work. */
745 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
748 # define OS_TYPE "SYSV"
750 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
752 +((word)etext & 0x1fff))
753 /* This only works for shared-text binaries with magic number 0413.
754 The other sorts of SysV binaries put the data at the end of the text,
755 in which case the default of etext would work. Unfortunately,
756 handling both would require having the magic-number available.
759 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
760 /* The stack starts at the top of memory, but */
761 /* 0x0 cannot be used as setjump_test complains */
762 /* that the stack direction is incorrect. Two */
763 /* bytes down from 0x0 should be safe enough. */
765 # include <sys/mmu.h>
766 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
769 # define OS_TYPE "AMIGA"
770 /* STACKBOTTOM and DATASTART handled specially */
772 # define DATAEND /* not needed */
773 # define GETPAGESIZE() 4096
779 # define OS_TYPE "MACOS"
780 /* see os_dep.c for details of global data segments. */
781 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
782 # define DATAEND /* not needed */
783 # define GETPAGESIZE() 4096
786 # define OS_TYPE "NEXT"
787 # define DATASTART ((ptr_t) get_etext())
788 # define STACKBOTTOM ((ptr_t) 0x4000000)
789 # define DATAEND /* not needed */
793 # if defined(POWERPC)
794 # define MACH_TYPE "POWERPC"
796 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
800 # define OS_TYPE "MACOS"
801 /* see os_dep.c for details of global data segments. */
802 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
803 # define DATAEND /* not needed */
807 # if defined(__powerpc64__)
809 # define CPP_WORDSZ 64
811 # define HBLKSIZE 4096
816 # define OS_TYPE "LINUX"
817 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
818 /* executable on a 64 bit kernel. */
819 # define LINUX_STACKBOTTOM
820 # define DYNAMIC_LOADING
821 # define SEARCH_FOR_DATA_START
823 # define DATAEND (_end)
828 # define CPP_WORDSZ 64
832 # define OS_TYPE "DARWIN"
833 # define DYNAMIC_LOADING
834 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
835 These aren't used when dyld support is enabled (it is by default) */
836 # define DATASTART ((ptr_t) get_etext())
837 # define DATAEND ((ptr_t) get_end())
838 # define STACKBOTTOM ((ptr_t) 0xc0000000)
840 # define USE_MMAP_ANON
841 # define USE_ASM_PUSH_REGS
842 /* This is potentially buggy. It needs more testing. See the comments in
843 os_dep.c. It relies on threads to track writes. */
844 # ifdef GC_DARWIN_THREADS
845 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
848 # define GETPAGESIZE() getpagesize()
849 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
850 /* The performance impact of prefetches is untested */
851 # define PREFETCH(x) \
852 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
853 # define PREFETCH_FOR_WRITE(x) \
854 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
856 /* There seems to be some issues with trylock hanging on darwin. This
857 should be looked into some more */
858 # define NO_PTHREAD_TRYLOCK
862 # define OS_TYPE "FREEBSD"
863 # ifndef GC_FREEBSD_THREADS
864 # define MPROTECT_VDB
866 # define SIG_SUSPEND SIGUSR1
867 # define SIG_THR_RESTART SIGUSR2
868 # define FREEBSD_STACKBOTTOM
870 # define DYNAMIC_LOADING
873 extern char * GC_FreeBSDGetDataStart();
874 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
878 # define OS_TYPE "NETBSD"
881 # define DATASTART GC_data_start
882 # define DYNAMIC_LOADING
884 # ifdef SN_TARGET_PS3
886 # define CPP_WORDSZ 32
889 // extern int _dso_handle[];
890 extern int __bss_start;
892 # define DATAEND (_end)
893 # define DATASTART (__bss_start)
894 # define STACKBOTTOM ((ptr_t) ps3_get_stack_bottom ())
895 # define USE_GENERIC_PUSHREGS
900 # define OS_TYPE "NOSYS"
901 extern void __end[], __dso_handle[];
902 # define DATASTART (__dso_handle) /* OK, that's ugly. */
903 # define DATAEND (__end)
904 /* Stack starts at 0xE0000000 for the simulator. */
906 # define STACK_GRAN 0x10000000
912 # define MACH_TYPE "VAX"
913 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
915 # define DATASTART ((ptr_t)(etext))
917 # define OS_TYPE "BSD"
919 /* HEURISTIC2 may be OK, but it's hard to test. */
922 # define OS_TYPE "ULTRIX"
923 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
928 # define MACH_TYPE "RT"
930 # define DATASTART ((ptr_t) 0x10000000)
931 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
935 # define MACH_TYPE "SPARC"
936 # if defined(__arch64__) || defined(__sparcv9)
938 # define CPP_WORDSZ 64
939 # define ELF_CLASS ELFCLASS64
941 # define ALIGNMENT 4 /* Required by hardware */
942 # define CPP_WORDSZ 32
944 # define ALIGN_DOUBLE
945 # ifdef _FILE_OFFSET_BITS
946 # undef _FILE_OFFSET_BITS /* libelf.h & procfs.h doesn't compile with large file support */
947 # define _FILE_OFFSET_BITS 32
950 # define OS_TYPE "SUNOS5"
953 extern ptr_t GC_SysVGetDataStart();
954 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
955 # define DATAEND (_end)
956 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
958 /* Otherwise we now use calloc. Mmap may result in the */
959 /* heap interleaved with thread stacks, which can result in */
960 /* excessive blacklisting. Sbrk is unusable since it */
961 /* doesn't interact correctly with the system malloc. */
964 # define HEAP_START (ptr_t)0x40000000
966 # define HEAP_START DATAEND
969 /* HEURISTIC1 reportedly no longer works under 2.7. */
970 /* HEURISTIC2 probably works, but this appears to be preferable. */
971 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
972 /* installations that's undefined. We work around this with a */
974 # include <sys/vmparam.h>
976 /* This should work everywhere, but doesn't. */
977 # define STACKBOTTOM USRSTACK
982 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
983 /* getpagesize() appeared to be missing from at least one */
984 /* Solaris 5.4 installation. Weird. */
985 # define DYNAMIC_LOADING
988 # define OS_TYPE "SUNOS4"
989 /* [If you have a weak stomach, don't read this.] */
990 /* We would like to use: */
991 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
992 /* This fails occasionally, due to an ancient, but very */
993 /* persistent ld bug. etext is set 32 bytes too high. */
994 /* We instead read the text segment size from the a.out */
995 /* header, which happens to be mapped into our address space */
996 /* at the start of the text segment. The detective work here */
997 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
998 /* Serpette of INRIA. */
999 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
1000 # define TEXTSTART 0x2000
1001 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
1002 # define MPROTECT_VDB
1004 # define DYNAMIC_LOADING
1007 # define OS_TYPE "DRSNX"
1008 extern ptr_t GC_SysVGetDataStart();
1010 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1011 # define MPROTECT_VDB
1012 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
1013 # define DYNAMIC_LOADING
1016 # define OS_TYPE "LINUX"
1018 # define DYNAMIC_LOADING
1020 Linux Sparc/a.out not supported
1023 # include <features.h>
1024 # if defined(__GLIBC__) && __GLIBC__ >= 2
1025 # define SEARCH_FOR_DATA_START
1027 extern char **__environ;
1028 # define DATASTART ((ptr_t)(&__environ))
1029 /* hideous kludge: __environ is the first */
1030 /* word in crt0.o, and delimits the start */
1031 /* of the data segment, no matter which */
1032 /* ld options were passed through. */
1033 /* We could use _etext instead, but that */
1034 /* would include .rodata, which may */
1035 /* contain large read-only data tables */
1036 /* that we'd rather not scan. */
1039 # define DATAEND (_end)
1040 # define LINUX_STACKBOTTOM
1043 # define OS_TYPE "OPENBSD"
1044 # define STACKBOTTOM ((ptr_t) 0xf8000000)
1046 # define DATASTART ((ptr_t)(etext))
1049 # define OS_TYPE "NETBSD"
1052 # define DATASTART GC_data_start
1053 # define DYNAMIC_LOADING
1055 extern char etext[];
1056 # define DATASTART ((ptr_t)(etext))
1060 # define OS_TYPE "FREEBSD"
1061 # define SIG_SUSPEND SIGUSR1
1062 # define SIG_THR_RESTART SIGUSR2
1063 # define FREEBSD_STACKBOTTOM
1065 # define DYNAMIC_LOADING
1067 extern char etext[];
1068 extern char edata[];
1070 # define NEED_FIND_LIMIT
1071 # define DATASTART ((ptr_t)(&etext))
1072 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1073 # define DATASTART2 ((ptr_t)(&edata))
1074 # define DATAEND2 ((ptr_t)(&end))
1079 # define MACH_TYPE "I386"
1080 # if defined(__LP64__) || defined(_WIN64)
1081 # define CPP_WORDSZ 64
1082 # define ALIGNMENT 8
1084 # define CPP_WORDSZ 32
1085 # define ALIGNMENT 4
1086 /* Appears to hold for all "32 bit" compilers */
1087 /* except Borland. The -a4 option fixes */
1089 /* Ivan Demakov: For Watcom the option is -zp4. */
1091 # ifndef SMALL_CONFIG
1092 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1093 /* improvement on Pentiums. */
1095 # ifdef HAVE_BUILTIN_UNWIND_INIT
1096 # define USE_GENERIC_PUSH_REGS
1099 # define OS_TYPE "SEQUENT"
1101 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1102 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1105 # define OS_TYPE "BEOS"
1107 # define GETPAGESIZE() B_PAGE_SIZE
1109 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1112 # define OS_TYPE "SUNOS5"
1113 extern int _etext[], _end[];
1114 extern ptr_t GC_SysVGetDataStart();
1115 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1116 # define DATAEND (_end)
1117 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1118 /* but reportedly breaks under 2.8. It appears that the stack */
1119 /* base is a property of the executable, so this should not break */
1120 /* old executables. */
1121 /* HEURISTIC2 probably works, but this appears to be preferable. */
1122 # include <sys/vm.h>
1123 # define STACKBOTTOM USRSTACK
1124 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1125 /* It appears to be fixed in 2.8 and 2.9. */
1126 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1127 /* Reading of dirty bits doesn't seem to work even in solaris 10 */
1128 /*# define PROC_VDB */
1130 # define DYNAMIC_LOADING
1131 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1133 /* Otherwise we now use calloc. Mmap may result in the */
1134 /* heap interleaved with thread stacks, which can result in */
1135 /* excessive blacklisting. Sbrk is unusable since it */
1136 /* doesn't interact correctly with the system malloc. */
1139 # define HEAP_START (ptr_t)0x40000000
1141 # define HEAP_START DATAEND
1145 # define OS_TYPE "SCO"
1147 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1149 +((word)etext & 0xfff))
1150 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1153 # define OS_TYPE "SCO_ELF"
1155 # define DATASTART ((ptr_t)(etext))
1156 # define STACKBOTTOM ((ptr_t) 0x08048000)
1157 # define DYNAMIC_LOADING
1158 # define ELF_CLASS ELFCLASS32
1161 # define OS_TYPE "DGUX"
1162 extern int _etext, _end;
1163 extern ptr_t GC_SysVGetDataStart();
1164 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1165 # define DATAEND (&_end)
1166 # define STACK_GROWS_DOWN
1168 # include <unistd.h>
1169 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1170 # define DYNAMIC_LOADING
1173 # endif /* USE_MMAP */
1174 # define MAP_FAILED (void *) -1
1176 # define HEAP_START (ptr_t)0x40000000
1177 # else /* USE_MMAP */
1178 # define HEAP_START DATAEND
1179 # endif /* USE_MMAP */
1184 /* The Intel compiler doesn't like inline assembly */
1185 # define USE_GENERIC_PUSH_REGS
1187 # define OS_TYPE "LINUX"
1188 # define LINUX_STACKBOTTOM
1192 # define STACK_GRAN 0x10000000
1193 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1194 /* different kernel configurations. In particular, systems */
1195 /* with 2GB physical memory will usually move the user */
1196 /* address space limit, and hence initial SP to 0x80000000. */
1198 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1199 # define MPROTECT_VDB
1201 /* We seem to get random errors in incremental mode, */
1202 /* possibly because Linux threads is itself a malloc client */
1203 /* and can't deal with the signals. */
1205 # define HEAP_START (ptr_t)0x1000
1206 /* This encourages mmap to give us low addresses, */
1207 /* thus allowing the heap to grow to ~3GB */
1209 # define DYNAMIC_LOADING
1210 # ifdef UNDEFINED /* includes ro data */
1211 extern int _etext[];
1212 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1214 # include <features.h>
1215 # if defined(__GLIBC__) && __GLIBC__ >= 2
1216 # define SEARCH_FOR_DATA_START
1218 extern char **__environ;
1219 # define DATASTART ((ptr_t)(&__environ))
1220 /* hideous kludge: __environ is the first */
1221 /* word in crt0.o, and delimits the start */
1222 /* of the data segment, no matter which */
1223 /* ld options were passed through. */
1224 /* We could use _etext instead, but that */
1225 /* would include .rodata, which may */
1226 /* contain large read-only data tables */
1227 /* that we'd rather not scan. */
1230 # define DATAEND (_end)
1233 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1235 # ifdef USE_I686_PREFETCH
1236 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1237 /* for the next rtelease. */
1238 # define PREFETCH(x) \
1239 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1240 /* Empirically prefetcht0 is much more effective at reducing */
1241 /* cache miss stalls for the targetted load instructions. But it */
1242 /* seems to interfere enough with other cache traffic that the net */
1243 /* result is worse than prefetchnta. */
1245 /* Using prefetches for write seems to have a slight negative */
1246 /* impact on performance, at least for a PIII/500. */
1247 # define PREFETCH_FOR_WRITE(x) \
1248 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1251 # ifdef USE_3DNOW_PREFETCH
1252 # define PREFETCH(x) \
1253 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1254 # define PREFETCH_FOR_WRITE(x) \
1255 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1259 # define OS_TYPE "CYGWIN32"
1260 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1261 # define DATAEND ((ptr_t)GC_DATAEND)
1263 # define STACK_GRAN 0x10000
1267 # define OS_TYPE "OS2"
1268 /* STACKBOTTOM and DATASTART are handled specially in */
1269 /* os_dep.c. OS2 actually has the right */
1271 # define DATAEND /* not needed */
1272 # define USE_GENERIC_PUSH_REGS
1275 # define OS_TYPE "MSWIN32"
1276 /* STACKBOTTOM and DATASTART are handled specially in */
1278 # ifndef __WATCOMC__
1279 # define MPROTECT_VDB
1281 # define DATAEND /* not needed */
1284 # define OS_TYPE "MSWINCE"
1285 # define DATAEND /* not needed */
1288 # define OS_TYPE "DJGPP"
1289 # include "stubinfo.h"
1292 extern int __djgpp_stack_limit;
1293 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1294 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1296 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1297 /* This may not be right. */
1300 # define OS_TYPE "OPENBSD"
1303 # define OS_TYPE "FREEBSD"
1304 # ifndef GC_FREEBSD_THREADS
1305 # define MPROTECT_VDB
1307 # define SIG_SUSPEND SIGTSTP
1308 # define SIG_THR_RESTART SIGCONT
1309 # define FREEBSD_STACKBOTTOM
1311 # define DYNAMIC_LOADING
1313 extern char etext[];
1314 extern char * GC_FreeBSDGetDataStart();
1315 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1318 # define OS_TYPE "NETBSD"
1320 # define DYNAMIC_LOADING
1324 # define OS_TYPE "THREE86BSD"
1327 # define OS_TYPE "BSDI"
1329 # if defined(OPENBSD) || defined(NETBSD) \
1330 || defined(THREE86BSD) || defined(BSDI)
1332 extern char etext[];
1333 # define DATASTART ((ptr_t)(etext))
1336 # define OS_TYPE "NEXT"
1337 # define DATASTART ((ptr_t) get_etext())
1338 # define STACKBOTTOM ((ptr_t)0xc0000000)
1339 # define DATAEND /* not needed */
1342 # define OS_TYPE "DOS4GW"
1343 extern long __nullarea;
1345 extern char *_STACKTOP;
1346 /* Depending on calling conventions Watcom C either precedes
1347 or does not precedes with undescore names of C-variables.
1348 Make sure startup code variables always have the same names. */
1349 #pragma aux __nullarea "*";
1350 #pragma aux _end "*";
1351 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1352 /* confused? me too. */
1353 # define DATASTART ((ptr_t) &__nullarea)
1354 # define DATAEND ((ptr_t) &_end)
1357 # define OS_TYPE "HURD"
1358 # define STACK_GROWS_DOWN
1360 extern int __data_start[];
1361 # define DATASTART ( (ptr_t) (__data_start))
1363 # define DATAEND ( (ptr_t) (_end))
1364 /* # define MPROTECT_VDB Not quite working yet? */
1365 # define DYNAMIC_LOADING
1370 # define MACH_TYPE "NS32K"
1371 # define ALIGNMENT 4
1372 extern char **environ;
1373 # define DATASTART ((ptr_t)(&environ))
1374 /* hideous kludge: environ is the first */
1375 /* word in crt0.o, and delimits the start */
1376 /* of the data segment, no matter which */
1377 /* ld options were passed through. */
1378 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1382 # define MACH_TYPE "MIPS"
1384 /* This was developed for a linuxce style platform. Probably */
1385 /* needs to be tweaked for workstation class machines. */
1386 # define OS_TYPE "LINUX"
1387 # define DYNAMIC_LOADING
1389 # define DATAEND (_end)
1390 extern int __data_start[];
1391 # define DATASTART ((ptr_t)(__data_start))
1392 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1393 # define ALIGNMENT 8
1394 # define CPP_WORDSZ 64
1396 # define ALIGNMENT 4
1398 # define USE_GENERIC_PUSH_REGS
1399 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1400 # define LINUX_STACKBOTTOM
1402 # define STACKBOTTOM 0x80000000
1407 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1408 extern int _fdata[], _end[];
1409 # define DATASTART ((ptr_t)_fdata)
1410 # define DATAEND ((ptr_t)_end)
1411 # define CPP_WORDSZ _MIPS_SZPTR
1412 # define ALIGNMENT (_MIPS_SZPTR/8)
1414 extern int etext[], edata[], end[];
1415 extern int _DYNAMIC_LINKING[], _gp[];
1416 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1417 + ((word)etext & 0xffff)))
1418 # define DATAEND (edata)
1419 # define DATASTART2 (_DYNAMIC_LINKING \
1420 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1422 # define DATAEND2 (end)
1423 # define ALIGNMENT 4
1425 # define OS_TYPE "EWS4800"
1426 # define USE_GENERIC_PUSH_REGS 1
1430 # define DATASTART (ptr_t)0x10000000
1431 /* Could probably be slightly higher since */
1432 /* startup code allocates lots of stuff. */
1433 # define OS_TYPE "ULTRIX"
1434 # define ALIGNMENT 4
1438 # define DATASTART (ptr_t)0x10000000
1439 # define OS_TYPE "RISCOS"
1440 # define ALIGNMENT 4 /* Required by hardware */
1444 extern int _fdata[];
1445 # define DATASTART ((ptr_t)(_fdata))
1447 # define HEAP_START (ptr_t)0x30000000
1449 # define HEAP_START DATASTART
1451 /* Lowest plausible heap address. */
1452 /* In the MMAP case, we map there. */
1453 /* In either case it is used to identify */
1454 /* heap sections so they're not */
1455 /* considered as roots. */
1456 # define OS_TYPE "IRIX5"
1457 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1458 /* of recent breakage. */
1460 # define CPP_WORDSZ _MIPS_SZPTR
1461 # define ALIGNMENT (_MIPS_SZPTR/8)
1462 # if CPP_WORDSZ != 64
1463 # define ALIGN_DOUBLE
1466 # define ALIGNMENT 4
1467 # define ALIGN_DOUBLE
1469 # define DYNAMIC_LOADING
1472 # define OS_TYPE "MSWINCE"
1473 # define ALIGNMENT 4
1474 # define DATAEND /* not needed */
1476 # if defined(NETBSD)
1477 # define ALIGNMENT 4
1478 # define OS_TYPE "NETBSD"
1480 # define USE_GENERIC_PUSH_REGS
1483 # define DATASTART GC_data_start
1484 # define NEED_FIND_LIMIT
1485 # define DYNAMIC_LOADING
1487 # define DATASTART ((ptr_t) 0x10000000)
1488 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1494 # define MACH_TYPE "RS6000"
1499 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1502 # define ALIGNMENT 8
1503 # define CPP_WORDSZ 64
1504 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1506 # define ALIGNMENT 4
1507 # define CPP_WORDSZ 32
1508 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1511 # define USE_MMAP_ANON
1512 /* From AIX linker man page:
1513 _text Specifies the first location of the program.
1514 _etext Specifies the first location after the program.
1515 _data Specifies the first location of the data.
1516 _edata Specifies the first location after the initialized data
1517 _end or end Specifies the first location after all data.
1519 extern int _data[], _end[];
1520 # define DATASTART ((ptr_t)((ulong)_data))
1521 # define DATAEND ((ptr_t)((ulong)_end))
1523 # define USE_GENERIC_PUSH_REGS
1524 # define DYNAMIC_LOADING
1525 /* For really old versions of AIX, this may have to be removed. */
1529 # define MACH_TYPE "HP_PA"
1531 # define CPP_WORDSZ 64
1532 # define ALIGNMENT 8
1534 # define CPP_WORDSZ 32
1535 # define ALIGNMENT 4
1536 # define ALIGN_DOUBLE
1538 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1539 # ifndef LINUX /* For now. */
1540 # define MPROTECT_VDB
1543 # define GENERIC_COMPARE_AND_SWAP
1544 /* No compare-and-swap instruction. Use pthread mutexes */
1545 /* when we absolutely have to. */
1546 # ifdef PARALLEL_MARK
1547 # define USE_MARK_BYTES
1548 /* Minimize compare-and-swap usage. */
1551 # define STACK_GROWS_UP
1553 # define OS_TYPE "HPUX"
1554 extern int __data_start[];
1555 # define DATASTART ((ptr_t)(__data_start))
1557 /* The following appears to work for 7xx systems running HP/UX */
1558 /* 9.xx Furthermore, it might result in much faster */
1559 /* collections than HEURISTIC2, which may involve scanning */
1560 /* segments that directly precede the stack. It is not the */
1561 /* default, since it may not work on older machine/OS */
1562 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1564 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1566 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1567 /* to this. Note that the GC must be initialized before the */
1568 /* first putenv call. */
1569 extern char ** environ;
1570 # define STACKBOTTOM ((ptr_t)environ)
1572 # define DYNAMIC_LOADING
1573 # include <unistd.h>
1574 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1576 # define PREFETCH(x) { \
1577 register long addr = (long)(x); \
1578 (void) _asm ("LDW", 0, 0, addr, 0); \
1583 # define OS_TYPE "LINUX"
1584 # define LINUX_STACKBOTTOM
1585 # define DYNAMIC_LOADING
1586 # define SEARCH_FOR_DATA_START
1588 # define DATAEND (&_end)
1593 # define MACH_TYPE "ALPHA"
1594 # define ALIGNMENT 8
1595 # define CPP_WORDSZ 64
1597 # define USE_GENERIC_PUSH_REGS
1598 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1599 /* fp registers in some cases when the target is a 21264. The assembly */
1600 /* code doesn't handle that yet, and version dependencies make that a */
1601 /* bit tricky. Do the easy thing for now. */
1604 # define OS_TYPE "NETBSD"
1606 # define DATASTART GC_data_start
1607 # define ELFCLASS32 32
1608 # define ELFCLASS64 64
1609 # define ELF_CLASS ELFCLASS64
1610 # define DYNAMIC_LOADING
1613 # define OS_TYPE "OPENBSD"
1615 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1616 # define DATASTART GC_data_start
1617 # define ELFCLASS32 32
1618 # define ELFCLASS64 64
1619 # define ELF_CLASS ELFCLASS64
1620 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1621 # define DATASTART ((ptr_t) 0x140000000)
1625 # define OS_TYPE "FREEBSD"
1626 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1627 # define SIG_SUSPEND SIGTSTP
1628 # define SIG_THR_RESTART SIGCONT
1629 # define FREEBSD_STACKBOTTOM
1631 # define DYNAMIC_LOADING
1633 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1634 extern char etext[];
1635 extern char edata[];
1637 # define NEED_FIND_LIMIT
1638 # define DATASTART ((ptr_t)(&etext))
1639 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1640 # define DATASTART2 ((ptr_t)(&edata))
1641 # define DATAEND2 ((ptr_t)(&end))
1644 # define OS_TYPE "OSF1"
1645 # define DATASTART ((ptr_t) 0x140000000)
1647 # define DATAEND ((ptr_t) &_end)
1648 extern char ** environ;
1649 /* round up from the value of environ to the nearest page boundary */
1650 /* Probably breaks if putenv is called before collector */
1651 /* initialization. */
1652 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1653 /* # define HEURISTIC2 */
1654 /* Normally HEURISTIC2 is too conervative, since */
1655 /* the text segment immediately follows the stack. */
1656 /* Hence we give an upper pound. */
1657 /* This is currently unused, since we disabled HEURISTIC2 */
1658 extern int __start[];
1659 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1660 # ifndef GC_OSF1_THREADS
1661 /* Unresolved signal issues with threads. */
1662 # define MPROTECT_VDB
1664 # define DYNAMIC_LOADING
1667 # define OS_TYPE "LINUX"
1668 # define LINUX_STACKBOTTOM
1670 # define SEARCH_FOR_DATA_START
1671 # define DYNAMIC_LOADING
1673 # define DATASTART ((ptr_t) 0x140000000)
1676 # define DATAEND (_end)
1677 # define MPROTECT_VDB
1678 /* Has only been superficially tested. May not */
1679 /* work on all versions. */
1684 # define MACH_TYPE "IA64"
1685 # define USE_GENERIC_PUSH_REGS
1686 /* We need to get preserved registers in addition to register */
1687 /* windows. That's easiest to do with setjmp. */
1688 # ifdef PARALLEL_MARK
1689 # define USE_MARK_BYTES
1690 /* Compare-and-exchange is too expensive to use for */
1691 /* setting mark bits. */
1695 # define CPP_WORDSZ 32
1696 # define ALIGN_DOUBLE
1697 /* Requires 8 byte alignment for malloc */
1698 # define ALIGNMENT 4
1703 # define CPP_WORDSZ 64
1704 # define ALIGN_DOUBLE
1705 /* Requires 16 byte alignment for malloc */
1706 # define ALIGNMENT 8
1708 # define OS_TYPE "HPUX"
1709 extern int __data_start[];
1710 # define DATASTART ((ptr_t)(__data_start))
1711 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1712 /* to this. Note that the GC must be initialized before the */
1713 /* first putenv call. */
1714 extern char ** environ;
1715 # define STACKBOTTOM ((ptr_t)environ)
1716 # define HPUX_STACKBOTTOM
1717 # define DYNAMIC_LOADING
1718 # include <unistd.h>
1719 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1720 /* The following was empirically determined, and is probably */
1721 /* not very robust. */
1722 /* Note that the backing store base seems to be at a nice */
1723 /* address minus one page. */
1724 # define BACKING_STORE_DISPLACEMENT 0x1000000
1725 # define BACKING_STORE_ALIGNMENT 0x1000
1726 extern ptr_t GC_register_stackbottom;
1727 # define BACKING_STORE_BASE GC_register_stackbottom
1728 /* Known to be wrong for recent HP/UX versions!!! */
1731 # define CPP_WORDSZ 64
1732 # define ALIGN_DOUBLE
1733 /* Requires 16 byte alignment for malloc */
1734 # define ALIGNMENT 8
1735 # define OS_TYPE "LINUX"
1736 /* The following works on NUE and older kernels: */
1737 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1738 /* This does not work on NUE: */
1739 # define LINUX_STACKBOTTOM
1740 /* We also need the base address of the register stack */
1741 /* backing store. This is computed in */
1742 /* GC_linux_register_stack_base based on the following */
1744 # define BACKING_STORE_ALIGNMENT 0x100000
1745 # define BACKING_STORE_DISPLACEMENT 0x80000000
1746 extern ptr_t GC_register_stackbottom;
1747 # define BACKING_STORE_BASE GC_register_stackbottom
1748 # define SEARCH_FOR_DATA_START
1750 # define DYNAMIC_LOADING
1752 /* In the Intel compiler environment, we seem to end up with */
1753 /* statically linked executables and an undefined reference */
1756 # define MPROTECT_VDB
1757 /* Requires Linux 2.3.47 or later. */
1759 # define DATAEND (_end)
1761 # ifndef __INTEL_COMPILER
1762 # define PREFETCH(x) \
1763 __asm__ (" lfetch [%0]": : "r"(x))
1764 # define PREFETCH_FOR_WRITE(x) \
1765 __asm__ (" lfetch.excl [%0]": : "r"(x))
1766 # define CLEAR_DOUBLE(x) \
1767 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1769 # include <ia64intrin.h>
1770 # define PREFETCH(x) \
1771 __lfetch(__lfhint_none, (x))
1772 # define PREFETCH_FOR_WRITE(x) \
1773 __lfetch(__lfhint_nta, (x))
1774 # define CLEAR_DOUBLE(x) \
1775 __stf_spill((void *)(x), 0)
1776 # endif // __INTEL_COMPILER
1780 /* FIXME: This is a very partial guess. There is no port, yet. */
1781 # define OS_TYPE "MSWIN32"
1782 /* STACKBOTTOM and DATASTART are handled specially in */
1784 # define DATAEND /* not needed */
1785 # if defined(_WIN64)
1786 # define CPP_WORDSZ 64
1788 # define CPP_WORDSZ 32 /* Is this possible? */
1790 # define ALIGNMENT 8
1795 # define MACH_TYPE "M88K"
1796 # define ALIGNMENT 4
1797 # define ALIGN_DOUBLE
1800 # define OS_TYPE "CX_UX"
1801 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1804 # define OS_TYPE "DGUX"
1805 extern ptr_t GC_SysVGetDataStart();
1806 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1808 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1812 /* If this still works, and if anyone cares, this should probably */
1813 /* be moved to the S390 category. */
1814 # define MACH_TYPE "S370"
1815 # define ALIGNMENT 4 /* Required by hardware */
1816 # define USE_GENERIC_PUSH_REGS
1818 # define OS_TYPE "UTS4"
1820 extern int _etext[];
1822 extern ptr_t GC_SysVGetDataStart();
1823 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1824 # define DATAEND (_end)
1830 # define MACH_TYPE "S390"
1831 # define USE_GENERIC_PUSH_REGS
1833 # define ALIGNMENT 4
1834 # define CPP_WORDSZ 32
1836 # define ALIGNMENT 8
1837 # define CPP_WORDSZ 64
1840 # define HBLKSIZE 4096
1843 # define OS_TYPE "LINUX"
1844 # define LINUX_STACKBOTTOM
1845 # define DYNAMIC_LOADING
1846 extern int __data_start[];
1847 # define DATASTART ((ptr_t)(__data_start))
1849 # define DATAEND (_end)
1850 # define CACHE_LINE_SIZE 256
1851 # define GETPAGESIZE() 4096
1856 # define ALIGNMENT 4
1857 extern int _etext[];
1858 # define DATASTART ((ptr_t)(_etext))
1863 # define CPP_WORDSZ 32
1864 # define MACH_TYPE "ARM32"
1865 # define ALIGNMENT 4
1867 # define OS_TYPE "NETBSD"
1870 # define DATASTART GC_data_start
1871 # define DYNAMIC_LOADING
1873 extern char etext[];
1874 # define DATASTART ((ptr_t)(etext))
1876 # define USE_GENERIC_PUSH_REGS
1879 # define OS_TYPE "LINUX"
1880 # define LINUX_STACKBOTTOM
1882 # define STACK_GRAN 0x10000000
1883 # define USE_GENERIC_PUSH_REGS
1885 # define DYNAMIC_LOADING
1886 # include <features.h>
1887 # if defined(__GLIBC__) && __GLIBC__ >= 2
1888 # define SEARCH_FOR_DATA_START
1889 # elif defined(PLATFORM_ANDROID)
1890 # define SEARCH_FOR_DATA_START
1892 extern char **__environ;
1893 # define DATASTART ((ptr_t)(&__environ))
1894 /* hideous kludge: __environ is the first */
1895 /* word in crt0.o, and delimits the start */
1896 /* of the data segment, no matter which */
1897 /* ld options were passed through. */
1898 /* We could use _etext instead, but that */
1899 /* would include .rodata, which may */
1900 /* contain large read-only data tables */
1901 /* that we'd rather not scan. */
1904 # define DATAEND (_end)
1907 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1911 # define OS_TYPE "MSWINCE"
1912 # define DATAEND /* not needed */
1915 # define OS_TYPE "DARWIN"
1916 # define DATASTART ((ptr_t) get_etext())
1917 # define DATAEND ((ptr_t) get_end())
1918 # define STACKBOTTOM ((ptr_t) 0x30000000)
1920 # define USE_MMAP_ANON
1924 /* __data_start is usually defined in the target linker script. */
1925 extern int __data_start[];
1926 # define DATASTART (ptr_t)(__data_start)
1927 # define USE_GENERIC_PUSH_REGS
1928 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1929 extern void *__stack_base__;
1930 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1935 # define MACH_TYPE "CRIS"
1936 # define CPP_WORDSZ 32
1937 # define ALIGNMENT 1
1938 # define OS_TYPE "LINUX"
1939 # define DYNAMIC_LOADING
1940 # define LINUX_STACKBOTTOM
1941 # define USE_GENERIC_PUSH_REGS
1942 # define SEARCH_FOR_DATA_START
1944 # define DATAEND (_end)
1948 # define MACH_TYPE "SH"
1949 # define ALIGNMENT 4
1951 # define OS_TYPE "MSWINCE"
1952 # define DATAEND /* not needed */
1955 # define OS_TYPE "LINUX"
1956 # define LINUX_STACKBOTTOM
1957 # define USE_GENERIC_PUSH_REGS
1958 # define DYNAMIC_LOADING
1959 # define SEARCH_FOR_DATA_START
1961 # define DATAEND (_end)
1964 # define OS_TYPE "NETBSD"
1966 # define DATASTART GC_data_start
1967 # define USE_GENERIC_PUSH_REGS
1968 # define DYNAMIC_LOADING
1973 # define MACH_TYPE "SH4"
1974 # define OS_TYPE "MSWINCE"
1975 # define ALIGNMENT 4
1976 # define DATAEND /* not needed */
1980 # define CPP_WORDSZ 32
1981 # define MACH_TYPE "M32R"
1982 # define ALIGNMENT 4
1984 # define OS_TYPE "LINUX"
1985 # define LINUX_STACKBOTTOM
1987 # define STACK_GRAN 0x10000000
1988 # define USE_GENERIC_PUSH_REGS
1989 # define DYNAMIC_LOADING
1990 # define SEARCH_FOR_DATA_START
1992 # define DATAEND (_end)
1997 # define MACH_TYPE "X86_64"
1998 # define ALIGNMENT 8
1999 # define CPP_WORDSZ 64
2001 # define HBLKSIZE 4096
2003 # define CACHE_LINE_SIZE 64
2004 # define USE_GENERIC_PUSH_REGS
2006 # define OS_TYPE "LINUX"
2007 # define LINUX_STACKBOTTOM
2009 # define FALLBACK_TO_MMAP
2011 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
2012 # define MPROTECT_VDB
2014 /* We seem to get random errors in incremental mode, */
2015 /* possibly because Linux threads is itself a malloc client */
2016 /* and can't deal with the signals. */
2019 # define DYNAMIC_LOADING
2020 # ifdef UNDEFINED /* includes ro data */
2021 extern int _etext[];
2022 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
2024 # include <features.h>
2025 # define SEARCH_FOR_DATA_START
2027 # define DATAEND (_end)
2030 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2032 # if defined(__GNUC__) && __GNUC >= 3
2033 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2034 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2038 # define OS_TYPE "FREEBSD"
2039 # ifndef GC_FREEBSD_THREADS
2040 # define MPROTECT_VDB
2042 # define SIG_SUSPEND SIGTSTP
2043 # define SIG_THR_RESTART SIGCONT
2044 # define NEED_FIND_LIMIT
2045 # define FREEBSD_STACKBOTTOM
2047 # define DYNAMIC_LOADING
2049 extern char etext[];
2050 extern char * GC_FreeBSDGetDataStart();
2051 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2054 # define OS_TYPE "NETBSD"
2056 # define DYNAMIC_LOADING
2059 extern char etext[];
2060 # define SEARCH_FOR_DATA_START
2064 #if defined(LINUX) && defined(USE_MMAP)
2065 /* The kernel may do a somewhat better job merging mappings etc. */
2066 /* with anonymous mappings. */
2067 # define USE_MMAP_ANON
2070 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2071 /* Rld appears to allocate some memory with its own allocator, and */
2072 /* some through malloc, which might be redirected. To make this */
2073 /* work with collectable memory, we have to scan memory allocated */
2074 /* by rld's internal malloc. */
2075 # define USE_PROC_FOR_LIBRARIES
2078 # ifndef STACK_GROWS_UP
2079 # define STACK_GROWS_DOWN
2083 # define CPP_WORDSZ 32
2092 # define DATAEND (end)
2095 # if defined(SVR4) && !defined(GETPAGESIZE)
2096 # include <unistd.h>
2097 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2100 # ifndef GETPAGESIZE
2101 # if defined(SUNOS5) || defined(IRIX5)
2102 # include <unistd.h>
2104 # define GETPAGESIZE() getpagesize()
2107 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2108 /* OS has SVR4 generic features. Probably others also qualify. */
2112 # if defined(SUNOS5) || defined(DRSNX)
2113 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2116 /* OS has SUNOS5 style signal handlers. */
2124 # if defined(FREEBSD) && (__FreeBSD__ >= 4)
2128 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2129 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2130 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2131 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2132 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2135 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2140 # undef DYNAMIC_LOADING
2145 # undef MPROTECT_VDB
2150 /* Postponed for now. */
2152 # undef MPROTECT_VDB
2155 # ifdef SMALL_CONFIG
2156 /* Presumably not worth the space it takes. */
2158 # undef MPROTECT_VDB
2162 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2165 # ifdef PARALLEL_MARK
2166 # undef MPROTECT_VDB /* For now. */
2169 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2170 # define DEFAULT_VDB
2174 # define PREFETCH(x)
2175 # define NO_PREFETCH
2178 # ifndef PREFETCH_FOR_WRITE
2179 # define PREFETCH_FOR_WRITE(x)
2180 # define NO_PREFETCH_FOR_WRITE
2183 # ifndef CACHE_LINE_SIZE
2184 # define CACHE_LINE_SIZE 32 /* Wild guess */
2188 # define REGISTER_LIBRARIES_EARLY
2189 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2190 /* lock. This isn't safe after the world has stopped. So we must */
2191 /* call GC_register_dynamic_libraries before stopping the world. */
2192 /* For performance reasons, this may be beneficial on other */
2193 /* platforms as well, though it should be avoided in win32. */
2196 # if defined(SEARCH_FOR_DATA_START)
2197 extern ptr_t GC_data_start;
2198 # define DATASTART GC_data_start
2201 # ifndef CLEAR_DOUBLE
2202 # define CLEAR_DOUBLE(x) \
2203 ((word*)x)[0] = 0; \
2205 # endif /* CLEAR_DOUBLE */
2207 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2208 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2209 # define GC_SOLARIS_THREADS
2212 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2213 --> inconsistent configuration
2215 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
2216 --> inconsistent configuration
2218 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2219 --> inconsistent configuration
2221 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2222 --> inconsistent configuration
2224 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2225 --> inconsistent configuration
2227 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2228 --> inconsistent configuration
2231 # if defined(PCR) || defined(SRC_M3) || \
2232 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2233 defined(GC_PTHREADS) || defined(SN_TARGET_PS3)
2237 # if defined(HP_PA) || defined(M88K) \
2238 || defined(POWERPC) && !defined(DARWIN) \
2239 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2240 || (defined(I386) && defined(__LCC__))
2241 /* Use setjmp based hack to mark from callee-save registers. */
2242 /* The define should move to the individual platform */
2244 # define USE_GENERIC_PUSH_REGS
2247 # if defined(MSWINCE)
2252 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2253 /* include assembly code to do it well. */
2256 /* Can we save call chain in objects for debugging? */
2257 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2258 /* frame) to reasonable values for the platform. */
2259 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2260 /* at build time, though we feel free to adjust it slightly. */
2261 /* Define NEED_CALLINFO if we either save the call stack or */
2262 /* GC_ADD_CALLER is defined. */
2263 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2266 # define CAN_SAVE_CALL_ARGS
2268 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
2269 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2270 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2271 # define CAN_SAVE_CALL_ARGS
2274 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2275 && defined(GC_CAN_SAVE_CALL_STACKS)
2276 # define SAVE_CALL_CHAIN
2278 # ifdef SAVE_CALL_CHAIN
2279 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2280 # define NARGS SAVE_CALL_NARGS
2282 # define NARGS 0 /* Number of arguments to save for each call. */
2285 # ifdef SAVE_CALL_CHAIN
2286 # ifndef SAVE_CALL_COUNT
2287 # define NFRAMES 6 /* Number of frames to save. Even for */
2288 /* alignment reasons. */
2290 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2292 # define NEED_CALLINFO
2293 # endif /* SAVE_CALL_CHAIN */
2294 # ifdef GC_ADD_CALLER
2297 # define NEED_CALLINFO
2300 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2301 # define DBG_HDRS_ALL
2304 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2305 # define POINTER_SHIFT 0
2308 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2309 # define POINTER_MASK ((GC_word)(-1))
2312 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2313 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2316 # if defined(FIXUP_POINTER)
2317 # define NEED_FIXUP_POINTER 1
2319 # define NEED_FIXUP_POINTER 0
2320 # define FIXUP_POINTER(p)
2324 /* This relies on some type definitions from gc_priv.h, from */
2325 /* where it's normally included. */
2327 /* How to get heap memory from the OS: */
2328 /* Note that sbrk()-like allocation is preferred, since it */
2329 /* usually makes it possible to merge consecutively allocated */
2330 /* chunks. It also avoids unintented recursion with */
2331 /* -DREDIRECT_MALLOC. */
2332 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2333 /* 0 is taken to mean failure. */
2334 /* In the case os USE_MMAP, the argument must also be a */
2335 /* physical page size. */
2336 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2337 /* though we should perhaps take advantage of the case in which */
2339 struct hblk; /* See gc_priv.h. */
2341 char * real_malloc();
2342 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2346 void * os2_alloc(size_t bytes);
2347 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2351 # if defined(NEXT) || defined(DOS4GW) || \
2352 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2353 (defined(SUNOS5) && !defined(USE_MMAP))
2354 # define GET_MEM(bytes) HBLKPTR((size_t) \
2355 calloc(1, (size_t)bytes + GC_page_size) \
2359 extern ptr_t GC_win32_get_mem();
2360 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2363 # if defined(USE_TEMPORARY_MEMORY)
2364 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2365 Boolean clearMemory);
2366 # define GET_MEM(bytes) HBLKPTR( \
2367 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2370 # define GET_MEM(bytes) HBLKPTR( \
2371 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2375 extern ptr_t GC_wince_get_mem();
2376 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2378 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2379 extern void *GC_amiga_get_mem(size_t size);
2380 # define GET_MEM(bytes) HBLKPTR((size_t) \
2381 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2384 # if defined(SN_TARGET_PS3)
2385 extern void *ps3_get_mem (size_t size);
2386 # define GET_MEM(bytes) (struct hblk*) ps3_get_mem (bytes)
2388 extern ptr_t GC_unix_get_mem();
2389 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2399 #endif /* GC_PRIVATE_H */
2401 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2402 /* IBMs xlc compiler doesn't appear to follow the convention of */
2403 /* defining __STDC__ to be zero in extended mode. */
2407 # endif /* GCCONFIG_H */