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 /* There seems to be some issues with trylock hanging on darwin. This
331 should be looked into some more */
332 # define NO_PTHREAD_TRYLOCK
333 # elif defined(__arm__)
335 # define mach_type_known
336 # define DARWIN_DONT_PARSE_STACK
337 # define GC_DONT_REGISTER_MAIN_STATIC_DATA
340 # if defined(NeXT) && defined(mc68000)
343 # define mach_type_known
345 # if defined(NeXT) && (defined(i386) || defined(__i386__))
348 # define mach_type_known
350 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
353 # define mach_type_known
355 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
357 # define mach_type_known
359 # if defined(FREEBSD) && defined(__x86_64__)
361 # define mach_type_known
363 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
365 # define mach_type_known
367 # if defined(__NetBSD__) && defined(__x86_64__)
369 # define mach_type_known
371 # if defined(FREEBSD) && defined(__sparc__)
373 # define mach_type_known
375 # if defined(bsdi) && (defined(i386) || defined(__i386__))
378 # define mach_type_known
380 # if !defined(mach_type_known) && defined(__386BSD__)
383 # define mach_type_known
385 # if defined(_CX_UX) && defined(_M88K)
388 # define mach_type_known
390 # if defined(DGUX) && defined(m88k)
393 # define mach_type_known
395 # if defined(_WIN32_WCE)
396 /* SH3, SH4, MIPS already defined for corresponding architectures */
397 # if defined(SH3) || defined(SH4)
407 # define mach_type_known
409 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
410 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
411 # if defined(__LP64__) || defined(_WIN64)
\r
416 # define MSWIN32 /* or Win64 */
\r
417 # define mach_type_known
\r
419 # if defined(_MSC_VER) && defined(_M_IA64)
\r
421 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
\r
422 /* variants as a differnt platform. */
\r
425 # if defined(__DJGPP__)
428 # define DJGPP /* MSDOS running the DJGPP port of GCC */
430 # define mach_type_known
432 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
435 # define mach_type_known
437 # if defined(__MINGW32__)
440 # define mach_type_known
442 # if defined(__BORLANDC__)
445 # define mach_type_known
447 # if defined(_UTS) && !defined(mach_type_known)
450 # define mach_type_known
454 # define mach_type_known
456 # if defined(__embedded__) && defined(PPC)
459 # define mach_type_known
462 # if defined(__WATCOMC__) && defined(__386__)
464 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
465 # if defined(__OS2__)
468 # if defined(__WINDOWS_386__) || defined(__NT__)
475 # define mach_type_known
477 # if defined(__s390__) && defined(LINUX)
479 # define mach_type_known
481 # if defined(__GNU__)
482 # if defined(__i386__)
483 /* The Debian Hurd running on generic PC */
486 # define mach_type_known
490 /* Feel free to add more clauses here */
492 /* Or manually define the machine type here. A machine type is */
493 /* characterized by the architecture. Some */
494 /* machine types are further subdivided by OS. */
495 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
496 /* Note that SGI IRIX is treated identically to RISCOS. */
497 /* SYSV on an M68K actually means A/UX. */
498 /* The distinction in these cases is usually the stack starting address */
499 # ifndef mach_type_known
500 --> unknown machine type
502 /* Mapping is: M68K ==> Motorola 680X0 */
503 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
504 /* MACOS and AMIGA variants) */
505 /* I386 ==> Intel 386 */
506 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
507 /* FREEBSD, THREE86BSD, MSWIN32, */
508 /* BSDI,SUNOS5, NEXT, other variants) */
509 /* NS32K ==> Encore Multimax */
510 /* MIPS ==> R2000 or R3000 */
511 /* (RISCOS, ULTRIX variants) */
512 /* VAX ==> DEC VAX */
513 /* (BSD, ULTRIX variants) */
514 /* RS6000 ==> IBM RS/6000 AIX3.X */
515 /* RT ==> IBM PC/RT */
516 /* HP_PA ==> HP9000/700 & /800 */
518 /* SPARC ==> SPARC v7/v8/v9 */
519 /* (SUNOS4, SUNOS5, LINUX, */
520 /* DRSNX variants) */
521 /* ALPHA ==> DEC Alpha */
522 /* (OSF1 and LINUX variants) */
523 /* M88K ==> Motorola 88XX0 */
524 /* (CX_UX and DGUX) */
525 /* S370 ==> 370-like machine */
526 /* running Amdahl UTS4 */
527 /* S390 ==> 390-like machine */
529 /* ARM32 ==> Intel StrongARM */
530 /* IA64 ==> Intel IPF */
532 /* (LINUX and HPUX) */
533 /* SH ==> Hitachi SuperH */
534 /* (LINUX & MSWINCE) */
535 /* X86_64 ==> AMD x86-64 */
536 /* POWERPC ==> IBM/Apple PowerPC */
537 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
538 /* LINUX, NETBSD, NOSYS variants) */
539 /* Handles 32 and 64-bit variants. */
540 /* AIX should be handled here, but */
541 /* that's called an RS6000. */
542 /* CRIS ==> Axis Etrax */
543 /* M32R ==> Renesas M32R */
547 * For each architecture and OS, the following need to be defined:
549 * CPP_WORDSZ is a simple integer constant representing the word size.
550 * in bits. We assume byte addressibility, where a byte has 8 bits.
551 * We also assume CPP_WORDSZ is either 32 or 64.
552 * (We care about the length of pointers, not hardware
553 * bus widths. Thus a 64 bit processor with a C compiler that uses
554 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
556 * MACH_TYPE is a string representation of the machine type.
557 * OS_TYPE is analogous for the OS.
559 * ALIGNMENT is the largest N, such that
560 * all pointer are guaranteed to be aligned on N byte boundaries.
561 * defining it to be 1 will always work, but perform poorly.
563 * DATASTART is the beginning of the data segment.
564 * On some platforms SEARCH_FOR_DATA_START is defined.
565 * SEARCH_FOR_DATASTART will cause GC_data_start to
566 * be set to an address determined by accessing data backwards from _end
567 * until an unmapped page is found. DATASTART will be defined to be
569 * On UNIX-like systems, the collector will scan the area between DATASTART
570 * and DATAEND for root pointers.
572 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
573 * RTH suggests gaining access to linker script synth'd values with
574 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
575 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
576 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
577 * without any special options.
579 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
582 * STACKBOTTOM is the cool end of the stack, which is usually the
583 * highest address in the stack.
584 * Under PCR or OS/2, we have other ways of finding thread stacks.
585 * For each machine, the following should:
586 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
587 * 2) define exactly one of
588 * STACKBOTTOM (should be defined to be an expression)
592 * If STACKBOTTOM is defined, then it's value will be used directly as the
593 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
594 * with a method appropriate for most Linux systems. Currently we look
595 * first for __libc_stack_end, and if that fails read it from /proc.
596 * If either of the last two macros are defined, then STACKBOTTOM is computed
597 * during collector startup using one of the following two heuristics:
598 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
599 * the next multiple of STACK_GRAN.
600 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
601 * in small steps (decrement if STACK_GROWS_UP), and read the value
602 * at each location. Remember the value when the first
603 * Segmentation violation or Bus error is signalled. Round that
604 * to the nearest plausible page boundary, and use that instead
607 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
608 * the value of environ is a pointer that can serve as STACKBOTTOM.
609 * I expect that HEURISTIC2 can be replaced by this approach, which
610 * interferes far less with debugging. However it has the disadvantage
611 * that it's confused by a putenv call before the collector is initialized.
612 * This could be dealt with by intercepting putenv ...
614 * If no expression for STACKBOTTOM can be found, and neither of the above
615 * heuristics are usable, the collector can still be used with all of the above
616 * undefined, provided one of the following is done:
617 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
618 * without reference to STACKBOTTOM. This is appropriate for use in
619 * conjunction with thread packages, since there will be multiple stacks.
620 * (Allocating thread stacks in the heap, and treating them as ordinary
621 * heap data objects is also possible as a last resort. However, this is
622 * likely to introduce significant amounts of excess storage retention
623 * unless the dead parts of the thread stacks are periodically cleared.)
624 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
625 * If the author of the client code controls the main program, this is
626 * easily accomplished by introducing a new main program, setting
627 * GC_stackbottom to the address of a local variable, and then calling
628 * the original main program. The new main program would read something
631 * # include "gc_private.h"
633 * main(argc, argv, envp)
635 * char **argv, **envp;
639 * GC_stackbottom = (ptr_t)(&dummy);
640 * return(real_main(argc, argv, envp));
644 * Each architecture may also define the style of virtual dirty bit
645 * implementation to be used:
646 * MPROTECT_VDB: Write protect the heap and catch faults.
647 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
649 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
650 * defined GC_register_dynamic_libraries() for the architecture.
652 * An architecture may define PREFETCH(x) to preload the cache with *x.
653 * This defaults to a no-op.
655 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
657 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
658 * clear the two words at GC_malloc-aligned address x. By default,
659 * word stores of 0 are used instead.
661 * HEAP_START may be defined as the initial address hint for mmap-based
665 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
666 * to push the relevant registers onto the stack. This generally makes
667 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
669 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
670 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
671 && !defined(__INTEL_COMPILER) \
672 && !defined(__PATHCC__)
673 # define HAVE_BUILTIN_UNWIND_INIT
676 # define STACK_GRAN 0x1000000
678 # define MACH_TYPE "M68K"
681 # define OS_TYPE "OPENBSD"
684 # define DATASTART GC_data_start
685 # define DYNAMIC_LOADING
688 # define DATASTART ((ptr_t)(etext))
690 # define USE_GENERIC_PUSH_REGS
693 # define OS_TYPE "NETBSD"
696 # define DATASTART GC_data_start
697 # define DYNAMIC_LOADING
700 # define DATASTART ((ptr_t)(etext))
702 # define USE_GENERIC_PUSH_REGS
705 # define OS_TYPE "LINUX"
706 # define STACKBOTTOM ((ptr_t)0xf0000000)
707 # define USE_GENERIC_PUSH_REGS
708 /* We never got around to the assembly version. */
709 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
711 # define DYNAMIC_LOADING
712 # include <features.h>
713 # if defined(__GLIBC__)&& __GLIBC__>=2
714 # define SEARCH_FOR_DATA_START
716 extern char **__environ;
717 # define DATASTART ((ptr_t)(&__environ))
718 /* hideous kludge: __environ is the first */
719 /* word in crt0.o, and delimits the start */
720 /* of the data segment, no matter which */
721 /* ld options were passed through. */
722 /* We could use _etext instead, but that */
723 /* would include .rodata, which may */
724 /* contain large read-only data tables */
725 /* that we'd rather not scan. */
726 # endif /* !GLIBC2 */
728 # define DATAEND (_end)
731 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
735 # define OS_TYPE "SUNOS4"
737 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
738 # define HEURISTIC1 /* differs */
739 # define DYNAMIC_LOADING
742 # define OS_TYPE "HP"
744 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
745 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
746 /* empirically determined. seems to work. */
748 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
751 # define OS_TYPE "SYSV"
753 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
755 +((word)etext & 0x1fff))
756 /* This only works for shared-text binaries with magic number 0413.
757 The other sorts of SysV binaries put the data at the end of the text,
758 in which case the default of etext would work. Unfortunately,
759 handling both would require having the magic-number available.
762 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
763 /* The stack starts at the top of memory, but */
764 /* 0x0 cannot be used as setjump_test complains */
765 /* that the stack direction is incorrect. Two */
766 /* bytes down from 0x0 should be safe enough. */
768 # include <sys/mmu.h>
769 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
772 # define OS_TYPE "AMIGA"
773 /* STACKBOTTOM and DATASTART handled specially */
775 # define DATAEND /* not needed */
776 # define GETPAGESIZE() 4096
782 # define OS_TYPE "MACOS"
783 /* see os_dep.c for details of global data segments. */
784 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
785 # define DATAEND /* not needed */
786 # define GETPAGESIZE() 4096
789 # define OS_TYPE "NEXT"
790 # define DATASTART ((ptr_t) get_etext())
791 # define STACKBOTTOM ((ptr_t) 0x4000000)
792 # define DATAEND /* not needed */
796 # if defined(POWERPC)
797 # define MACH_TYPE "POWERPC"
799 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
803 # define OS_TYPE "MACOS"
804 /* see os_dep.c for details of global data segments. */
805 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
806 # define DATAEND /* not needed */
810 # if defined(__powerpc64__)
812 # define CPP_WORDSZ 64
814 # define HBLKSIZE 4096
819 # define OS_TYPE "LINUX"
820 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
821 /* executable on a 64 bit kernel. */
822 # define LINUX_STACKBOTTOM
823 # define DYNAMIC_LOADING
824 # define SEARCH_FOR_DATA_START
826 # define DATAEND (_end)
831 # define CPP_WORDSZ 64
835 # define OS_TYPE "DARWIN"
836 # define DYNAMIC_LOADING
837 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
838 These aren't used when dyld support is enabled (it is by default) */
839 # define DATASTART ((ptr_t) get_etext())
840 # define DATAEND ((ptr_t) get_end())
841 # define STACKBOTTOM ((ptr_t) 0xc0000000)
843 # define USE_MMAP_ANON
844 # define USE_ASM_PUSH_REGS
845 /* This is potentially buggy. It needs more testing. See the comments in
846 os_dep.c. It relies on threads to track writes. */
847 # ifdef GC_DARWIN_THREADS
848 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
851 # define GETPAGESIZE() getpagesize()
852 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
853 /* The performance impact of prefetches is untested */
854 # define PREFETCH(x) \
855 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
856 # define PREFETCH_FOR_WRITE(x) \
857 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
859 /* There seems to be some issues with trylock hanging on darwin. This
860 should be looked into some more */
861 # define NO_PTHREAD_TRYLOCK
865 # define OS_TYPE "FREEBSD"
866 # ifndef GC_FREEBSD_THREADS
867 # define MPROTECT_VDB
869 # define SIG_SUSPEND SIGUSR1
870 # define SIG_THR_RESTART SIGUSR2
871 # define FREEBSD_STACKBOTTOM
873 # define DYNAMIC_LOADING
876 extern char * GC_FreeBSDGetDataStart();
877 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
881 # define OS_TYPE "NETBSD"
884 # define DATASTART GC_data_start
885 # define DYNAMIC_LOADING
887 # ifdef SN_TARGET_PS3
\r
889 # define CPP_WORDSZ 32
\r
890 # define ALIGNMENT 4
\r
891 extern int _end [];
\r
892 // extern int _dso_handle[];
\r
893 extern int __bss_start;
\r
895 # define DATAEND (_end)
\r
896 # define DATASTART (__bss_start)
\r
897 # define STACKBOTTOM ((ptr_t) ps3_get_stack_bottom ())
898 # define USE_GENERIC_PUSHREGS
\r
903 # define OS_TYPE "NOSYS"
904 extern void __end[], __dso_handle[];
905 # define DATASTART (__dso_handle) /* OK, that's ugly. */
906 # define DATAEND (__end)
907 /* Stack starts at 0xE0000000 for the simulator. */
909 # define STACK_GRAN 0x10000000
915 # define MACH_TYPE "VAX"
916 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
918 # define DATASTART ((ptr_t)(etext))
920 # define OS_TYPE "BSD"
922 /* HEURISTIC2 may be OK, but it's hard to test. */
925 # define OS_TYPE "ULTRIX"
926 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
931 # define MACH_TYPE "RT"
933 # define DATASTART ((ptr_t) 0x10000000)
934 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
938 # define MACH_TYPE "SPARC"
939 # if defined(__arch64__) || defined(__sparcv9)
941 # define CPP_WORDSZ 64
942 # define ELF_CLASS ELFCLASS64
944 # define ALIGNMENT 4 /* Required by hardware */
945 # define CPP_WORDSZ 32
947 # define ALIGN_DOUBLE
948 # ifdef _FILE_OFFSET_BITS
949 # undef _FILE_OFFSET_BITS /* libelf.h & procfs.h doesn't compile with large file support */
950 # define _FILE_OFFSET_BITS 32
953 # define OS_TYPE "SUNOS5"
956 extern ptr_t GC_SysVGetDataStart();
957 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
958 # define DATAEND (_end)
959 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
961 /* Otherwise we now use calloc. Mmap may result in the */
962 /* heap interleaved with thread stacks, which can result in */
963 /* excessive blacklisting. Sbrk is unusable since it */
964 /* doesn't interact correctly with the system malloc. */
967 # define HEAP_START (ptr_t)0x40000000
969 # define HEAP_START DATAEND
972 /* HEURISTIC1 reportedly no longer works under 2.7. */
973 /* HEURISTIC2 probably works, but this appears to be preferable. */
974 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
975 /* installations that's undefined. We work around this with a */
977 # include <sys/vmparam.h>
979 /* This should work everywhere, but doesn't. */
980 # define STACKBOTTOM USRSTACK
985 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
986 /* getpagesize() appeared to be missing from at least one */
987 /* Solaris 5.4 installation. Weird. */
988 # define DYNAMIC_LOADING
991 # define OS_TYPE "SUNOS4"
992 /* [If you have a weak stomach, don't read this.] */
993 /* We would like to use: */
994 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
995 /* This fails occasionally, due to an ancient, but very */
996 /* persistent ld bug. etext is set 32 bytes too high. */
997 /* We instead read the text segment size from the a.out */
998 /* header, which happens to be mapped into our address space */
999 /* at the start of the text segment. The detective work here */
1000 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
1001 /* Serpette of INRIA. */
1002 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
1003 # define TEXTSTART 0x2000
1004 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
1005 # define MPROTECT_VDB
1007 # define DYNAMIC_LOADING
1010 # define OS_TYPE "DRSNX"
1011 extern ptr_t GC_SysVGetDataStart();
1013 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1014 # define MPROTECT_VDB
1015 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
1016 # define DYNAMIC_LOADING
1019 # define OS_TYPE "LINUX"
1021 # define DYNAMIC_LOADING
1023 Linux Sparc/a.out not supported
1026 # include <features.h>
1027 # if defined(__GLIBC__) && __GLIBC__ >= 2
1028 # define SEARCH_FOR_DATA_START
1030 extern char **__environ;
1031 # define DATASTART ((ptr_t)(&__environ))
1032 /* hideous kludge: __environ is the first */
1033 /* word in crt0.o, and delimits the start */
1034 /* of the data segment, no matter which */
1035 /* ld options were passed through. */
1036 /* We could use _etext instead, but that */
1037 /* would include .rodata, which may */
1038 /* contain large read-only data tables */
1039 /* that we'd rather not scan. */
1042 # define DATAEND (_end)
1043 # define LINUX_STACKBOTTOM
1046 # define OS_TYPE "OPENBSD"
1047 # define STACKBOTTOM ((ptr_t) 0xf8000000)
1049 # define DATASTART ((ptr_t)(etext))
1052 # define OS_TYPE "NETBSD"
1055 # define DATASTART GC_data_start
1056 # define DYNAMIC_LOADING
1058 extern char etext[];
1059 # define DATASTART ((ptr_t)(etext))
1063 # define OS_TYPE "FREEBSD"
1064 # define SIG_SUSPEND SIGUSR1
1065 # define SIG_THR_RESTART SIGUSR2
1066 # define FREEBSD_STACKBOTTOM
1068 # define DYNAMIC_LOADING
1070 extern char etext[];
1071 extern char edata[];
1073 # define NEED_FIND_LIMIT
1074 # define DATASTART ((ptr_t)(&etext))
1075 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1076 # define DATASTART2 ((ptr_t)(&edata))
1077 # define DATAEND2 ((ptr_t)(&end))
1082 # define MACH_TYPE "I386"
1083 # if defined(__LP64__) || defined(_WIN64)
1084 # define CPP_WORDSZ 64
1085 # define ALIGNMENT 8
1087 # define CPP_WORDSZ 32
1088 # define ALIGNMENT 4
1089 /* Appears to hold for all "32 bit" compilers */
1090 /* except Borland. The -a4 option fixes */
1092 /* Ivan Demakov: For Watcom the option is -zp4. */
1094 # ifndef SMALL_CONFIG
1095 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1096 /* improvement on Pentiums. */
1098 # ifdef HAVE_BUILTIN_UNWIND_INIT
1099 # define USE_GENERIC_PUSH_REGS
1102 # define OS_TYPE "SEQUENT"
1104 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1105 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1108 # define OS_TYPE "BEOS"
1110 # define GETPAGESIZE() B_PAGE_SIZE
1112 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1115 # define OS_TYPE "SUNOS5"
1116 extern int _etext[], _end[];
1117 extern ptr_t GC_SysVGetDataStart();
1118 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1119 # define DATAEND (_end)
1120 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1121 /* but reportedly breaks under 2.8. It appears that the stack */
1122 /* base is a property of the executable, so this should not break */
1123 /* old executables. */
1124 /* HEURISTIC2 probably works, but this appears to be preferable. */
1125 # include <sys/vm.h>
1126 # define STACKBOTTOM USRSTACK
1127 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1128 /* It appears to be fixed in 2.8 and 2.9. */
1129 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1130 /* Reading of dirty bits doesn't seem to work even in solaris 10 */
1131 /*# define PROC_VDB */
1133 # define DYNAMIC_LOADING
1134 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1136 /* Otherwise we now use calloc. Mmap may result in the */
1137 /* heap interleaved with thread stacks, which can result in */
1138 /* excessive blacklisting. Sbrk is unusable since it */
1139 /* doesn't interact correctly with the system malloc. */
1142 # define HEAP_START (ptr_t)0x40000000
1144 # define HEAP_START DATAEND
1148 # define OS_TYPE "SCO"
1150 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1152 +((word)etext & 0xfff))
1153 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1156 # define OS_TYPE "SCO_ELF"
1158 # define DATASTART ((ptr_t)(etext))
1159 # define STACKBOTTOM ((ptr_t) 0x08048000)
1160 # define DYNAMIC_LOADING
1161 # define ELF_CLASS ELFCLASS32
1164 # define OS_TYPE "DGUX"
1165 extern int _etext, _end;
1166 extern ptr_t GC_SysVGetDataStart();
1167 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1168 # define DATAEND (&_end)
1169 # define STACK_GROWS_DOWN
1171 # include <unistd.h>
1172 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1173 # define DYNAMIC_LOADING
1176 # endif /* USE_MMAP */
1177 # define MAP_FAILED (void *) -1
1179 # define HEAP_START (ptr_t)0x40000000
1180 # else /* USE_MMAP */
1181 # define HEAP_START DATAEND
1182 # endif /* USE_MMAP */
1187 /* The Intel compiler doesn't like inline assembly */
1188 # define USE_GENERIC_PUSH_REGS
1190 # define OS_TYPE "LINUX"
1191 # define LINUX_STACKBOTTOM
1195 # define STACK_GRAN 0x10000000
1196 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1197 /* different kernel configurations. In particular, systems */
1198 /* with 2GB physical memory will usually move the user */
1199 /* address space limit, and hence initial SP to 0x80000000. */
1201 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1202 # define MPROTECT_VDB
1204 /* We seem to get random errors in incremental mode, */
1205 /* possibly because Linux threads is itself a malloc client */
1206 /* and can't deal with the signals. */
1208 # define HEAP_START (ptr_t)0x1000
1209 /* This encourages mmap to give us low addresses, */
1210 /* thus allowing the heap to grow to ~3GB */
1212 # define DYNAMIC_LOADING
1213 # ifdef UNDEFINED /* includes ro data */
1214 extern int _etext[];
1215 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1217 # include <features.h>
1218 # if defined(__GLIBC__) && __GLIBC__ >= 2
1219 # define SEARCH_FOR_DATA_START
1221 extern char **__environ;
1222 # define DATASTART ((ptr_t)(&__environ))
1223 /* hideous kludge: __environ is the first */
1224 /* word in crt0.o, and delimits the start */
1225 /* of the data segment, no matter which */
1226 /* ld options were passed through. */
1227 /* We could use _etext instead, but that */
1228 /* would include .rodata, which may */
1229 /* contain large read-only data tables */
1230 /* that we'd rather not scan. */
1233 # define DATAEND (_end)
1236 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1238 # ifdef USE_I686_PREFETCH
1239 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1240 /* for the next rtelease. */
1241 # define PREFETCH(x) \
1242 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1243 /* Empirically prefetcht0 is much more effective at reducing */
1244 /* cache miss stalls for the targetted load instructions. But it */
1245 /* seems to interfere enough with other cache traffic that the net */
1246 /* result is worse than prefetchnta. */
1248 /* Using prefetches for write seems to have a slight negative */
1249 /* impact on performance, at least for a PIII/500. */
1250 # define PREFETCH_FOR_WRITE(x) \
1251 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1254 # ifdef USE_3DNOW_PREFETCH
1255 # define PREFETCH(x) \
1256 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1257 # define PREFETCH_FOR_WRITE(x) \
1258 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1262 # define OS_TYPE "CYGWIN32"
1263 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1264 # define DATAEND ((ptr_t)GC_DATAEND)
1266 # define STACK_GRAN 0x10000
1270 # define OS_TYPE "OS2"
1271 /* STACKBOTTOM and DATASTART are handled specially in */
1272 /* os_dep.c. OS2 actually has the right */
1274 # define DATAEND /* not needed */
1275 # define USE_GENERIC_PUSH_REGS
1278 # define OS_TYPE "MSWIN32"
1279 /* STACKBOTTOM and DATASTART are handled specially in */
1281 # ifndef __WATCOMC__
1282 # define MPROTECT_VDB
1284 # define DATAEND /* not needed */
1287 # define OS_TYPE "MSWINCE"
1288 # define DATAEND /* not needed */
1291 # define OS_TYPE "DJGPP"
1292 # include "stubinfo.h"
1295 extern int __djgpp_stack_limit;
1296 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1297 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1299 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1300 /* This may not be right. */
1303 # define OS_TYPE "OPENBSD"
1306 # define OS_TYPE "FREEBSD"
1307 # ifndef GC_FREEBSD_THREADS
1308 # define MPROTECT_VDB
1310 # define SIG_SUSPEND SIGTSTP
1311 # define SIG_THR_RESTART SIGCONT
1312 # define FREEBSD_STACKBOTTOM
1314 # define DYNAMIC_LOADING
1316 extern char etext[];
1317 extern char * GC_FreeBSDGetDataStart();
1318 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1321 # define OS_TYPE "NETBSD"
1323 # define DYNAMIC_LOADING
1327 # define OS_TYPE "THREE86BSD"
1330 # define OS_TYPE "BSDI"
1332 # if defined(OPENBSD) || defined(NETBSD) \
1333 || defined(THREE86BSD) || defined(BSDI)
1335 extern char etext[];
1336 # define DATASTART ((ptr_t)(etext))
1339 # define OS_TYPE "NEXT"
1340 # define DATASTART ((ptr_t) get_etext())
1341 # define STACKBOTTOM ((ptr_t)0xc0000000)
1342 # define DATAEND /* not needed */
1345 # define OS_TYPE "DOS4GW"
1346 extern long __nullarea;
1348 extern char *_STACKTOP;
1349 /* Depending on calling conventions Watcom C either precedes
1350 or does not precedes with undescore names of C-variables.
1351 Make sure startup code variables always have the same names. */
1352 #pragma aux __nullarea "*";
1353 #pragma aux _end "*";
1354 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1355 /* confused? me too. */
1356 # define DATASTART ((ptr_t) &__nullarea)
1357 # define DATAEND ((ptr_t) &_end)
1360 # define OS_TYPE "HURD"
1361 # define STACK_GROWS_DOWN
1363 extern int __data_start[];
1364 # define DATASTART ( (ptr_t) (__data_start))
1366 # define DATAEND ( (ptr_t) (_end))
1367 /* # define MPROTECT_VDB Not quite working yet? */
1368 # define DYNAMIC_LOADING
1373 # define MACH_TYPE "NS32K"
1374 # define ALIGNMENT 4
1375 extern char **environ;
1376 # define DATASTART ((ptr_t)(&environ))
1377 /* hideous kludge: environ is the first */
1378 /* word in crt0.o, and delimits the start */
1379 /* of the data segment, no matter which */
1380 /* ld options were passed through. */
1381 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1385 # define MACH_TYPE "MIPS"
1387 /* This was developed for a linuxce style platform. Probably */
1388 /* needs to be tweaked for workstation class machines. */
1389 # define OS_TYPE "LINUX"
1390 # define DYNAMIC_LOADING
1392 # define DATAEND (_end)
1393 extern int __data_start[];
1394 # define DATASTART ((ptr_t)(__data_start))
1395 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1396 # define ALIGNMENT 8
1397 # define CPP_WORDSZ 64
1399 # define ALIGNMENT 4
1401 # define USE_GENERIC_PUSH_REGS
1402 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1403 # define LINUX_STACKBOTTOM
1405 # define STACKBOTTOM 0x80000000
1410 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1411 extern int _fdata[], _end[];
1412 # define DATASTART ((ptr_t)_fdata)
1413 # define DATAEND ((ptr_t)_end)
1414 # define CPP_WORDSZ _MIPS_SZPTR
1415 # define ALIGNMENT (_MIPS_SZPTR/8)
1417 extern int etext[], edata[], end[];
1418 extern int _DYNAMIC_LINKING[], _gp[];
1419 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1420 + ((word)etext & 0xffff)))
1421 # define DATAEND (edata)
1422 # define DATASTART2 (_DYNAMIC_LINKING \
1423 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1425 # define DATAEND2 (end)
1426 # define ALIGNMENT 4
1428 # define OS_TYPE "EWS4800"
1429 # define USE_GENERIC_PUSH_REGS 1
1433 # define DATASTART (ptr_t)0x10000000
1434 /* Could probably be slightly higher since */
1435 /* startup code allocates lots of stuff. */
1436 # define OS_TYPE "ULTRIX"
1437 # define ALIGNMENT 4
1441 # define DATASTART (ptr_t)0x10000000
1442 # define OS_TYPE "RISCOS"
1443 # define ALIGNMENT 4 /* Required by hardware */
1447 extern int _fdata[];
1448 # define DATASTART ((ptr_t)(_fdata))
1450 # define HEAP_START (ptr_t)0x30000000
1452 # define HEAP_START DATASTART
1454 /* Lowest plausible heap address. */
1455 /* In the MMAP case, we map there. */
1456 /* In either case it is used to identify */
1457 /* heap sections so they're not */
1458 /* considered as roots. */
1459 # define OS_TYPE "IRIX5"
1460 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1461 /* of recent breakage. */
1463 # define CPP_WORDSZ _MIPS_SZPTR
1464 # define ALIGNMENT (_MIPS_SZPTR/8)
1465 # if CPP_WORDSZ != 64
1466 # define ALIGN_DOUBLE
1469 # define ALIGNMENT 4
1470 # define ALIGN_DOUBLE
1472 # define DYNAMIC_LOADING
1475 # define OS_TYPE "MSWINCE"
1476 # define ALIGNMENT 4
1477 # define DATAEND /* not needed */
1479 # if defined(NETBSD)
1480 # define ALIGNMENT 4
1481 # define OS_TYPE "NETBSD"
1483 # define USE_GENERIC_PUSH_REGS
1486 # define DATASTART GC_data_start
1487 # define NEED_FIND_LIMIT
1488 # define DYNAMIC_LOADING
1490 # define DATASTART ((ptr_t) 0x10000000)
1491 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1497 # define MACH_TYPE "RS6000"
1502 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1505 # define ALIGNMENT 8
1506 # define CPP_WORDSZ 64
1507 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1509 # define ALIGNMENT 4
1510 # define CPP_WORDSZ 32
1511 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1514 # define USE_MMAP_ANON
1515 /* From AIX linker man page:
1516 _text Specifies the first location of the program.
1517 _etext Specifies the first location after the program.
1518 _data Specifies the first location of the data.
1519 _edata Specifies the first location after the initialized data
1520 _end or end Specifies the first location after all data.
1522 extern int _data[], _end[];
1523 # define DATASTART ((ptr_t)((ulong)_data))
1524 # define DATAEND ((ptr_t)((ulong)_end))
1526 # define USE_GENERIC_PUSH_REGS
1527 # define DYNAMIC_LOADING
1528 /* For really old versions of AIX, this may have to be removed. */
1532 # define MACH_TYPE "HP_PA"
1534 # define CPP_WORDSZ 64
1535 # define ALIGNMENT 8
1537 # define CPP_WORDSZ 32
1538 # define ALIGNMENT 4
1539 # define ALIGN_DOUBLE
1541 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1542 # ifndef LINUX /* For now. */
1543 # define MPROTECT_VDB
1546 # define GENERIC_COMPARE_AND_SWAP
1547 /* No compare-and-swap instruction. Use pthread mutexes */
1548 /* when we absolutely have to. */
1549 # ifdef PARALLEL_MARK
1550 # define USE_MARK_BYTES
1551 /* Minimize compare-and-swap usage. */
1554 # define STACK_GROWS_UP
1556 # define OS_TYPE "HPUX"
1557 extern int __data_start[];
1558 # define DATASTART ((ptr_t)(__data_start))
1560 /* The following appears to work for 7xx systems running HP/UX */
1561 /* 9.xx Furthermore, it might result in much faster */
1562 /* collections than HEURISTIC2, which may involve scanning */
1563 /* segments that directly precede the stack. It is not the */
1564 /* default, since it may not work on older machine/OS */
1565 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1567 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1569 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1570 /* to this. Note that the GC must be initialized before the */
1571 /* first putenv call. */
1572 extern char ** environ;
1573 # define STACKBOTTOM ((ptr_t)environ)
1575 # define DYNAMIC_LOADING
1576 # include <unistd.h>
1577 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1579 # define PREFETCH(x) { \
1580 register long addr = (long)(x); \
1581 (void) _asm ("LDW", 0, 0, addr, 0); \
1586 # define OS_TYPE "LINUX"
1587 # define LINUX_STACKBOTTOM
1588 # define DYNAMIC_LOADING
1589 # define SEARCH_FOR_DATA_START
1591 # define DATAEND (&_end)
1596 # define MACH_TYPE "ALPHA"
1597 # define ALIGNMENT 8
1598 # define CPP_WORDSZ 64
1600 # define USE_GENERIC_PUSH_REGS
1601 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1602 /* fp registers in some cases when the target is a 21264. The assembly */
1603 /* code doesn't handle that yet, and version dependencies make that a */
1604 /* bit tricky. Do the easy thing for now. */
1607 # define OS_TYPE "NETBSD"
1609 # define DATASTART GC_data_start
1610 # define ELFCLASS32 32
1611 # define ELFCLASS64 64
1612 # define ELF_CLASS ELFCLASS64
1613 # define DYNAMIC_LOADING
1616 # define OS_TYPE "OPENBSD"
1618 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1619 # define DATASTART GC_data_start
1620 # define ELFCLASS32 32
1621 # define ELFCLASS64 64
1622 # define ELF_CLASS ELFCLASS64
1623 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1624 # define DATASTART ((ptr_t) 0x140000000)
1628 # define OS_TYPE "FREEBSD"
1629 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1630 # define SIG_SUSPEND SIGTSTP
1631 # define SIG_THR_RESTART SIGCONT
1632 # define FREEBSD_STACKBOTTOM
1634 # define DYNAMIC_LOADING
1636 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1637 extern char etext[];
1638 extern char edata[];
1640 # define NEED_FIND_LIMIT
1641 # define DATASTART ((ptr_t)(&etext))
1642 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1643 # define DATASTART2 ((ptr_t)(&edata))
1644 # define DATAEND2 ((ptr_t)(&end))
1647 # define OS_TYPE "OSF1"
1648 # define DATASTART ((ptr_t) 0x140000000)
1650 # define DATAEND ((ptr_t) &_end)
1651 extern char ** environ;
1652 /* round up from the value of environ to the nearest page boundary */
1653 /* Probably breaks if putenv is called before collector */
1654 /* initialization. */
1655 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1656 /* # define HEURISTIC2 */
1657 /* Normally HEURISTIC2 is too conervative, since */
1658 /* the text segment immediately follows the stack. */
1659 /* Hence we give an upper pound. */
1660 /* This is currently unused, since we disabled HEURISTIC2 */
1661 extern int __start[];
1662 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1663 # ifndef GC_OSF1_THREADS
1664 /* Unresolved signal issues with threads. */
1665 # define MPROTECT_VDB
1667 # define DYNAMIC_LOADING
1670 # define OS_TYPE "LINUX"
1671 # define LINUX_STACKBOTTOM
1673 # define SEARCH_FOR_DATA_START
1674 # define DYNAMIC_LOADING
1676 # define DATASTART ((ptr_t) 0x140000000)
1679 # define DATAEND (_end)
1680 # define MPROTECT_VDB
1681 /* Has only been superficially tested. May not */
1682 /* work on all versions. */
1687 # define MACH_TYPE "IA64"
1688 # define USE_GENERIC_PUSH_REGS
1689 /* We need to get preserved registers in addition to register */
1690 /* windows. That's easiest to do with setjmp. */
1691 # ifdef PARALLEL_MARK
1692 # define USE_MARK_BYTES
1693 /* Compare-and-exchange is too expensive to use for */
1694 /* setting mark bits. */
1698 # define CPP_WORDSZ 32
1699 # define ALIGN_DOUBLE
1700 /* Requires 8 byte alignment for malloc */
1701 # define ALIGNMENT 4
1706 # define CPP_WORDSZ 64
1707 # define ALIGN_DOUBLE
1708 /* Requires 16 byte alignment for malloc */
1709 # define ALIGNMENT 8
1711 # define OS_TYPE "HPUX"
1712 extern int __data_start[];
1713 # define DATASTART ((ptr_t)(__data_start))
1714 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1715 /* to this. Note that the GC must be initialized before the */
1716 /* first putenv call. */
1717 extern char ** environ;
1718 # define STACKBOTTOM ((ptr_t)environ)
1719 # define HPUX_STACKBOTTOM
1720 # define DYNAMIC_LOADING
1721 # include <unistd.h>
1722 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1723 /* The following was empirically determined, and is probably */
1724 /* not very robust. */
1725 /* Note that the backing store base seems to be at a nice */
1726 /* address minus one page. */
1727 # define BACKING_STORE_DISPLACEMENT 0x1000000
1728 # define BACKING_STORE_ALIGNMENT 0x1000
1729 extern ptr_t GC_register_stackbottom;
1730 # define BACKING_STORE_BASE GC_register_stackbottom
1731 /* Known to be wrong for recent HP/UX versions!!! */
1734 # define CPP_WORDSZ 64
1735 # define ALIGN_DOUBLE
1736 /* Requires 16 byte alignment for malloc */
1737 # define ALIGNMENT 8
1738 # define OS_TYPE "LINUX"
1739 /* The following works on NUE and older kernels: */
1740 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1741 /* This does not work on NUE: */
1742 # define LINUX_STACKBOTTOM
1743 /* We also need the base address of the register stack */
1744 /* backing store. This is computed in */
1745 /* GC_linux_register_stack_base based on the following */
1747 # define BACKING_STORE_ALIGNMENT 0x100000
1748 # define BACKING_STORE_DISPLACEMENT 0x80000000
1749 extern ptr_t GC_register_stackbottom;
1750 # define BACKING_STORE_BASE GC_register_stackbottom
1751 # define SEARCH_FOR_DATA_START
1753 # define DYNAMIC_LOADING
1755 /* In the Intel compiler environment, we seem to end up with */
1756 /* statically linked executables and an undefined reference */
1759 # define MPROTECT_VDB
1760 /* Requires Linux 2.3.47 or later. */
1762 # define DATAEND (_end)
1764 # ifndef __INTEL_COMPILER
1765 # define PREFETCH(x) \
1766 __asm__ (" lfetch [%0]": : "r"(x))
1767 # define PREFETCH_FOR_WRITE(x) \
1768 __asm__ (" lfetch.excl [%0]": : "r"(x))
1769 # define CLEAR_DOUBLE(x) \
1770 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1772 # include <ia64intrin.h>
1773 # define PREFETCH(x) \
1774 __lfetch(__lfhint_none, (x))
1775 # define PREFETCH_FOR_WRITE(x) \
1776 __lfetch(__lfhint_nta, (x))
1777 # define CLEAR_DOUBLE(x) \
1778 __stf_spill((void *)(x), 0)
1779 # endif // __INTEL_COMPILER
1783 /* FIXME: This is a very partial guess. There is no port, yet. */
1784 # define OS_TYPE "MSWIN32"
1785 /* STACKBOTTOM and DATASTART are handled specially in */
1787 # define DATAEND /* not needed */
1788 # if defined(_WIN64)
1789 # define CPP_WORDSZ 64
1791 # define CPP_WORDSZ 32 /* Is this possible? */
1793 # define ALIGNMENT 8
1798 # define MACH_TYPE "M88K"
1799 # define ALIGNMENT 4
1800 # define ALIGN_DOUBLE
1803 # define OS_TYPE "CX_UX"
1804 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1807 # define OS_TYPE "DGUX"
1808 extern ptr_t GC_SysVGetDataStart();
1809 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1811 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1815 /* If this still works, and if anyone cares, this should probably */
1816 /* be moved to the S390 category. */
1817 # define MACH_TYPE "S370"
1818 # define ALIGNMENT 4 /* Required by hardware */
1819 # define USE_GENERIC_PUSH_REGS
1821 # define OS_TYPE "UTS4"
1823 extern int _etext[];
1825 extern ptr_t GC_SysVGetDataStart();
1826 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1827 # define DATAEND (_end)
1833 # define MACH_TYPE "S390"
1834 # define USE_GENERIC_PUSH_REGS
1836 # define ALIGNMENT 4
1837 # define CPP_WORDSZ 32
1839 # define ALIGNMENT 8
1840 # define CPP_WORDSZ 64
1843 # define HBLKSIZE 4096
1846 # define OS_TYPE "LINUX"
1847 # define LINUX_STACKBOTTOM
1848 # define DYNAMIC_LOADING
1849 extern int __data_start[];
1850 # define DATASTART ((ptr_t)(__data_start))
1852 # define DATAEND (_end)
1853 # define CACHE_LINE_SIZE 256
1854 # define GETPAGESIZE() 4096
1859 # define ALIGNMENT 4
1860 extern int _etext[];
1861 # define DATASTART ((ptr_t)(_etext))
1866 # define CPP_WORDSZ 32
1867 # define MACH_TYPE "ARM32"
1868 # define ALIGNMENT 4
1870 # define OS_TYPE "NETBSD"
1873 # define DATASTART GC_data_start
1874 # define DYNAMIC_LOADING
1876 extern char etext[];
1877 # define DATASTART ((ptr_t)(etext))
1879 # define USE_GENERIC_PUSH_REGS
1882 # define OS_TYPE "LINUX"
1883 # define LINUX_STACKBOTTOM
1885 # define STACK_GRAN 0x10000000
1886 # define USE_GENERIC_PUSH_REGS
1888 # define DYNAMIC_LOADING
1889 # include <features.h>
1890 # if defined(__GLIBC__) && __GLIBC__ >= 2
1891 # define SEARCH_FOR_DATA_START
1892 # elif defined(PLATFORM_ANDROID)
1893 # define SEARCH_FOR_DATA_START
1895 extern char **__environ;
1896 # define DATASTART ((ptr_t)(&__environ))
1897 /* hideous kludge: __environ is the first */
1898 /* word in crt0.o, and delimits the start */
1899 /* of the data segment, no matter which */
1900 /* ld options were passed through. */
1901 /* We could use _etext instead, but that */
1902 /* would include .rodata, which may */
1903 /* contain large read-only data tables */
1904 /* that we'd rather not scan. */
1907 # define DATAEND (_end)
1910 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1914 # define OS_TYPE "MSWINCE"
1915 # define DATAEND /* not needed */
1918 # define OS_TYPE "DARWIN"
1919 # define DATASTART ((ptr_t) get_etext())
1920 # define DATAEND ((ptr_t) get_end())
1921 # define STACKBOTTOM ((ptr_t) 0x30000000)
1923 # define USE_MMAP_ANON
1927 /* __data_start is usually defined in the target linker script. */
1928 extern int __data_start[];
1929 # define DATASTART (ptr_t)(__data_start)
1930 # define USE_GENERIC_PUSH_REGS
1931 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1932 extern void *__stack_base__;
1933 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1938 # define MACH_TYPE "CRIS"
1939 # define CPP_WORDSZ 32
1940 # define ALIGNMENT 1
1941 # define OS_TYPE "LINUX"
1942 # define DYNAMIC_LOADING
1943 # define LINUX_STACKBOTTOM
1944 # define USE_GENERIC_PUSH_REGS
1945 # define SEARCH_FOR_DATA_START
1947 # define DATAEND (_end)
1951 # define MACH_TYPE "SH"
1952 # define ALIGNMENT 4
1954 # define OS_TYPE "MSWINCE"
1955 # define DATAEND /* not needed */
1958 # define OS_TYPE "LINUX"
1959 # define LINUX_STACKBOTTOM
1960 # define USE_GENERIC_PUSH_REGS
1961 # define DYNAMIC_LOADING
1962 # define SEARCH_FOR_DATA_START
1964 # define DATAEND (_end)
1967 # define OS_TYPE "NETBSD"
1969 # define DATASTART GC_data_start
1970 # define USE_GENERIC_PUSH_REGS
1971 # define DYNAMIC_LOADING
1976 # define MACH_TYPE "SH4"
1977 # define OS_TYPE "MSWINCE"
1978 # define ALIGNMENT 4
1979 # define DATAEND /* not needed */
1983 # define CPP_WORDSZ 32
1984 # define MACH_TYPE "M32R"
1985 # define ALIGNMENT 4
1987 # define OS_TYPE "LINUX"
1988 # define LINUX_STACKBOTTOM
1990 # define STACK_GRAN 0x10000000
1991 # define USE_GENERIC_PUSH_REGS
1992 # define DYNAMIC_LOADING
1993 # define SEARCH_FOR_DATA_START
1995 # define DATAEND (_end)
2000 # define MACH_TYPE "X86_64"
2001 # define ALIGNMENT 8
2002 # define CPP_WORDSZ 64
2004 # define HBLKSIZE 4096
2006 # define CACHE_LINE_SIZE 64
2007 # define USE_GENERIC_PUSH_REGS
2009 # define OS_TYPE "LINUX"
2010 # define LINUX_STACKBOTTOM
2012 # define FALLBACK_TO_MMAP
2014 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
2015 # define MPROTECT_VDB
2017 /* We seem to get random errors in incremental mode, */
2018 /* possibly because Linux threads is itself a malloc client */
2019 /* and can't deal with the signals. */
2022 # define DYNAMIC_LOADING
2023 # ifdef UNDEFINED /* includes ro data */
2024 extern int _etext[];
2025 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
2027 # include <features.h>
2028 # define SEARCH_FOR_DATA_START
2030 # define DATAEND (_end)
2033 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2035 # if defined(__GNUC__) && __GNUC >= 3
2036 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2037 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2041 # define OS_TYPE "FREEBSD"
2042 # ifndef GC_FREEBSD_THREADS
2043 # define MPROTECT_VDB
2045 # define SIG_SUSPEND SIGTSTP
2046 # define SIG_THR_RESTART SIGCONT
2047 # define NEED_FIND_LIMIT
2048 # define FREEBSD_STACKBOTTOM
2050 # define DYNAMIC_LOADING
2052 extern char etext[];
2053 extern char * GC_FreeBSDGetDataStart();
2054 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2057 # define OS_TYPE "NETBSD"
2059 # define DYNAMIC_LOADING
2062 extern char etext[];
2063 # define SEARCH_FOR_DATA_START
2067 #if defined(LINUX) && defined(USE_MMAP)
2068 /* The kernel may do a somewhat better job merging mappings etc. */
2069 /* with anonymous mappings. */
2070 # define USE_MMAP_ANON
2073 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2074 /* Rld appears to allocate some memory with its own allocator, and */
2075 /* some through malloc, which might be redirected. To make this */
2076 /* work with collectable memory, we have to scan memory allocated */
2077 /* by rld's internal malloc. */
2078 # define USE_PROC_FOR_LIBRARIES
2081 # ifndef STACK_GROWS_UP
2082 # define STACK_GROWS_DOWN
2086 # define CPP_WORDSZ 32
2095 # define DATAEND (end)
2098 # if defined(SVR4) && !defined(GETPAGESIZE)
2099 # include <unistd.h>
2100 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2103 # ifndef GETPAGESIZE
2104 # if defined(SUNOS5) || defined(IRIX5)
2105 # include <unistd.h>
2107 # define GETPAGESIZE() getpagesize()
2110 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2111 /* OS has SVR4 generic features. Probably others also qualify. */
2115 # if defined(SUNOS5) || defined(DRSNX)
2116 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2119 /* OS has SUNOS5 style signal handlers. */
2127 # if defined(FREEBSD) && (__FreeBSD__ >= 4)
2131 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2132 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2133 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2134 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2135 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2138 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2143 # undef DYNAMIC_LOADING
2148 # undef MPROTECT_VDB
2153 /* Postponed for now. */
2155 # undef MPROTECT_VDB
2158 # ifdef SMALL_CONFIG
2159 /* Presumably not worth the space it takes. */
2161 # undef MPROTECT_VDB
2165 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2168 # ifdef PARALLEL_MARK
2169 # undef MPROTECT_VDB /* For now. */
2172 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2173 # define DEFAULT_VDB
2177 # define PREFETCH(x)
2178 # define NO_PREFETCH
2181 # ifndef PREFETCH_FOR_WRITE
2182 # define PREFETCH_FOR_WRITE(x)
2183 # define NO_PREFETCH_FOR_WRITE
2186 # ifndef CACHE_LINE_SIZE
2187 # define CACHE_LINE_SIZE 32 /* Wild guess */
2191 # define REGISTER_LIBRARIES_EARLY
2192 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2193 /* lock. This isn't safe after the world has stopped. So we must */
2194 /* call GC_register_dynamic_libraries before stopping the world. */
2195 /* For performance reasons, this may be beneficial on other */
2196 /* platforms as well, though it should be avoided in win32. */
2199 # if defined(SEARCH_FOR_DATA_START)
2200 extern ptr_t GC_data_start;
2201 # define DATASTART GC_data_start
2204 # ifndef CLEAR_DOUBLE
2205 # define CLEAR_DOUBLE(x) \
2206 ((word*)x)[0] = 0; \
2208 # endif /* CLEAR_DOUBLE */
2210 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2211 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2212 # define GC_SOLARIS_THREADS
2215 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2216 --> inconsistent configuration
2218 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
2219 --> inconsistent configuration
2221 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2222 --> inconsistent configuration
2224 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2225 --> inconsistent configuration
2227 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2228 --> inconsistent configuration
2230 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2231 --> inconsistent configuration
2234 # if defined(PCR) || defined(SRC_M3) || \
2235 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2236 defined(GC_PTHREADS)
2240 # if defined(HP_PA) || defined(M88K) \
2241 || defined(POWERPC) && !defined(DARWIN) \
2242 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2243 || (defined(I386) && defined(__LCC__))
2244 /* Use setjmp based hack to mark from callee-save registers. */
2245 /* The define should move to the individual platform */
2247 # define USE_GENERIC_PUSH_REGS
2250 # if defined(MSWINCE)
2255 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2256 /* include assembly code to do it well. */
2259 /* Can we save call chain in objects for debugging? */
2260 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2261 /* frame) to reasonable values for the platform. */
2262 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2263 /* at build time, though we feel free to adjust it slightly. */
2264 /* Define NEED_CALLINFO if we either save the call stack or */
2265 /* GC_ADD_CALLER is defined. */
2266 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2269 # define CAN_SAVE_CALL_ARGS
2271 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
2272 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2273 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2274 # define CAN_SAVE_CALL_ARGS
2277 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2278 && defined(GC_CAN_SAVE_CALL_STACKS)
2279 # define SAVE_CALL_CHAIN
2281 # ifdef SAVE_CALL_CHAIN
2282 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2283 # define NARGS SAVE_CALL_NARGS
2285 # define NARGS 0 /* Number of arguments to save for each call. */
2288 # ifdef SAVE_CALL_CHAIN
2289 # ifndef SAVE_CALL_COUNT
2290 # define NFRAMES 6 /* Number of frames to save. Even for */
2291 /* alignment reasons. */
2293 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2295 # define NEED_CALLINFO
2296 # endif /* SAVE_CALL_CHAIN */
2297 # ifdef GC_ADD_CALLER
2300 # define NEED_CALLINFO
2303 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2304 # define DBG_HDRS_ALL
2307 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2308 # define POINTER_SHIFT 0
2311 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2312 # define POINTER_MASK ((GC_word)(-1))
2315 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2316 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2319 # if defined(FIXUP_POINTER)
2320 # define NEED_FIXUP_POINTER 1
2322 # define NEED_FIXUP_POINTER 0
2323 # define FIXUP_POINTER(p)
2327 /* This relies on some type definitions from gc_priv.h, from */
2328 /* where it's normally included. */
2330 /* How to get heap memory from the OS: */
2331 /* Note that sbrk()-like allocation is preferred, since it */
2332 /* usually makes it possible to merge consecutively allocated */
2333 /* chunks. It also avoids unintented recursion with */
2334 /* -DREDIRECT_MALLOC. */
2335 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2336 /* 0 is taken to mean failure. */
2337 /* In the case os USE_MMAP, the argument must also be a */
2338 /* physical page size. */
2339 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2340 /* though we should perhaps take advantage of the case in which */
2342 struct hblk; /* See gc_priv.h. */
2344 char * real_malloc();
2345 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2349 void * os2_alloc(size_t bytes);
2350 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2354 # if defined(NEXT) || defined(DOS4GW) || \
2355 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2356 (defined(SUNOS5) && !defined(USE_MMAP))
2357 # define GET_MEM(bytes) HBLKPTR((size_t) \
2358 calloc(1, (size_t)bytes + GC_page_size) \
2362 extern ptr_t GC_win32_get_mem();
2363 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2366 # if defined(USE_TEMPORARY_MEMORY)
2367 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2368 Boolean clearMemory);
2369 # define GET_MEM(bytes) HBLKPTR( \
2370 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2373 # define GET_MEM(bytes) HBLKPTR( \
2374 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2378 extern ptr_t GC_wince_get_mem();
2379 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2381 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2382 extern void *GC_amiga_get_mem(size_t size);
2383 # define GET_MEM(bytes) HBLKPTR((size_t) \
2384 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2387 # if defined(SN_TARGET_PS3)
\r
2388 extern void *ps3_get_mem (size_t size);
\r
2389 # define GET_MEM(bytes) (struct hblk*) ps3_get_mem (bytes)
\r
2391 extern ptr_t GC_unix_get_mem();
2392 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2402 #endif /* GC_PRIVATE_H */
2404 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2405 /* IBMs xlc compiler doesn't appear to follow the convention of */
2406 /* defining __STDC__ to be zero in extended mode. */
2410 # endif /* GCCONFIG_H */