2 * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
3 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
4 * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
5 * Copyright (c) 2000-2004 Hewlett-Packard Development Company, L.P.
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
18 * This header is private to the gc. It is almost always included from
19 * gc_priv.h. However it is possible to include it by itself if just the
20 * configuration macros are needed. In that
21 * case, a few declarations relying on types declared in gc_priv.h will be
30 /* Fake ptr_t declaration, just to avoid compilation errors. */
31 /* This avoids many instances if "ifndef GC_PRIVATE_H" below. */
32 typedef struct GC_undefined_struct * ptr_t;
35 /* Machine dependent parameters. Some tuning parameters can be found */
36 /* near the top of gc_private.h. */
38 /* Machine specific parts contributed by various people. See README file. */
40 /* First a unified test for Linux: */
41 # if defined(linux) || defined(__linux__)
47 /* And one for NetBSD: */
48 # if defined(__NetBSD__)
52 /* And one for OpenBSD: */
53 # if defined(__OpenBSD__)
57 /* And one for FreeBSD: */
58 # if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(FREEBSD)
62 /* And one for Darwin: */
63 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
67 /* Determine the machine type: */
68 # if defined(__native_client__)
70 # if !defined(__portable_native_client__) && !defined(__arm__)
72 # define mach_type_known
74 /* Here we will rely upon arch-specific defines. */
77 # if defined(__arm__) || defined(__thumb__)
80 # define mach_type_known
81 # elif !defined(LINUX) && !defined(NETBSD) && !defined(DARWIN)
83 # define mach_type_known
86 # if defined(sun) && defined(mc68000)
89 # define mach_type_known
91 # if defined(hp9000s300)
94 # define mach_type_known
96 # if defined(OPENBSD) && defined(m68k)
98 # define mach_type_known
100 # if defined(OPENBSD) && defined(__sparc__)
102 # define mach_type_known
104 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
106 # define mach_type_known
108 # if defined(NETBSD) && defined(__powerpc__)
110 # define mach_type_known
112 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
114 # define mach_type_known
116 # if defined(NETBSD) && defined(__sh__)
118 # define mach_type_known
127 # define mach_type_known
129 # if defined(__NetBSD__) && defined(__vax__)
131 # define mach_type_known
133 # if defined(mips) || defined(__mips) || defined(_mips)
135 # if defined(nec_ews) || defined(_nec_ews)
138 # if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
139 # if defined(ultrix) || defined(__ultrix)
142 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
143 || defined(__SYSTYPE_SVR4__)
144 # define IRIX5 /* or IRIX 6.X */
146 # define RISCOS /* or IRIX 4.X */
150 # if defined(__NetBSD__) && defined(__MIPSEL__)
153 # define mach_type_known
155 # if defined(DGUX) && (defined(i386) || defined(__i386__))
160 # define mach_type_known
162 # if defined(sequent) && (defined(i386) || defined(__i386__))
165 # define mach_type_known
167 # if defined(sun) && (defined(i386) || defined(__i386__))
170 # define mach_type_known
172 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
175 # define mach_type_known
179 # define mach_type_known
181 # if defined(sun) && (defined(sparc) || defined(__sparc))
183 /* Test for SunOS 5.x */
190 # define mach_type_known
192 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
193 && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
196 # define mach_type_known
200 # define mach_type_known
202 # if defined(__NetBSD__) && defined(__sparc__)
204 # define mach_type_known
206 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
207 /* The above test may need refinement */
209 # if defined(_SCO_ELF)
214 # define mach_type_known
216 # if defined(_AUX_SOURCE)
219 # define mach_type_known
221 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
222 || defined(hppa) || defined(__hppa__)
224 # if !defined(LINUX) && !defined(HPUX)
227 # define mach_type_known
229 # if defined(__ia64) && defined(_HPUX_SOURCE)
234 # define mach_type_known
236 # if defined(__BEOS__) && defined(_X86_)
239 # define mach_type_known
241 # if defined(LINUX) && (defined(i386) || defined(__i386__))
243 # define mach_type_known
245 # if defined(OPENBSD) && defined(__amd64__)
247 # define mach_type_known
249 # if defined(LINUX) && defined(__x86_64__)
251 # define mach_type_known
253 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
255 # define mach_type_known
257 # if defined(LINUX) && defined(__arm__)
259 # define mach_type_known
261 # if defined(LINUX) && defined(__cris__)
265 # define mach_type_known
267 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
268 defined(powerpc64) || defined(__powerpc64__))
270 # define mach_type_known
272 # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
274 # define mach_type_known
276 # if defined(LINUX) && defined(__mc68000__)
278 # define mach_type_known
280 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
282 # define mach_type_known
284 # if defined(LINUX) && defined(__arm__)
286 # define mach_type_known
288 # if defined(LINUX) && defined(__sh__)
290 # define mach_type_known
292 # if defined(LINUX) && defined(__m32r__)
294 # define mach_type_known
296 # if defined(__alpha) || defined(__alpha__)
298 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
299 # define OSF1 /* a.k.a Digital Unix */
301 # define mach_type_known
303 # if defined(_AMIGA) && !defined(AMIGA)
308 # define mach_type_known
310 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
313 # define mach_type_known
315 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
318 # define mach_type_known
321 # include "TargetConditionals.h"
322 # if defined(__ppc__) || defined(__ppc64__)
324 # define mach_type_known
325 # elif defined(__i386__)
327 # define mach_type_known
328 # define DARWIN_DONT_PARSE_STACK
329 # define OS_TYPE "DARWIN"
330 # if TARGET_IPHONE_SIMULATOR == 0
331 # define DYNAMIC_LOADING
333 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
334 These aren't used when dyld support is enabled (it is by default) */
335 # define DATASTART ((ptr_t) get_etext())
336 # define DATAEND ((ptr_t) get_end())
337 # define STACKBOTTOM ((ptr_t) pthread_get_stackaddr_np(pthread_self()))
341 # define USE_MMAP_ANON
342 # define USE_ASM_PUSH_REGS
343 /* This is potentially buggy. It needs more testing. See the comments in
344 os_dep.c. It relies on threads to track writes. */
345 # ifdef GC_DARWIN_THREADS
346 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
349 # define GETPAGESIZE() getpagesize()
350 # elif defined(__arm__)
352 # define mach_type_known
353 # define DARWIN_DONT_PARSE_STACK
354 # define GC_DONT_REGISTER_MAIN_STATIC_DATA
355 # elif defined(__x86_64)
357 # define mach_type_known
360 # if defined(NeXT) && defined(mc68000)
363 # define mach_type_known
365 # if defined(NeXT) && (defined(i386) || defined(__i386__))
368 # define mach_type_known
370 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
373 # define mach_type_known
375 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
377 # define mach_type_known
379 # if defined(FREEBSD) && defined(__x86_64__)
381 # define mach_type_known
383 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
385 # define mach_type_known
387 # if defined(__NetBSD__) && defined(__x86_64__)
389 # define mach_type_known
391 # if defined(FREEBSD) && defined(__sparc__)
393 # define mach_type_known
395 # if defined(bsdi) && (defined(i386) || defined(__i386__))
398 # define mach_type_known
400 # if !defined(mach_type_known) && defined(__386BSD__)
403 # define mach_type_known
405 # if defined(_CX_UX) && defined(_M88K)
408 # define mach_type_known
410 # if defined(DGUX) && defined(m88k)
413 # define mach_type_known
415 # if defined(_WIN32_WCE)
416 /* SH3, SH4, MIPS already defined for corresponding architectures */
417 # if defined(SH3) || defined(SH4)
427 # define mach_type_known
429 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
430 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
431 # if defined(__LP64__) || defined(_WIN64)
436 # define MSWIN32 /* or Win64 */
437 # define mach_type_known
439 # if defined(_MSC_VER) && defined(_M_IA64)
441 # define MSWIN32 /* Really win64, but we don't treat 64-bit */
442 /* variants as a differnt platform. */
445 # if defined(__DJGPP__)
448 # define DJGPP /* MSDOS running the DJGPP port of GCC */
450 # define mach_type_known
452 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
455 # define mach_type_known
457 # if defined(__MINGW32__)
460 # define mach_type_known
462 # if defined(__BORLANDC__)
465 # define mach_type_known
467 # if defined(_UTS) && !defined(mach_type_known)
470 # define mach_type_known
474 # define mach_type_known
476 # if defined(__embedded__) && defined(PPC)
479 # define mach_type_known
482 # if defined(__WATCOMC__) && defined(__386__)
484 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
485 # if defined(__OS2__)
488 # if defined(__WINDOWS_386__) || defined(__NT__)
495 # define mach_type_known
497 # if defined(__s390__) && defined(LINUX)
499 # define mach_type_known
501 # if defined(__GNU__)
502 # if defined(__i386__)
503 /* The Debian Hurd running on generic PC */
506 # define mach_type_known
510 /* Feel free to add more clauses here */
512 /* Or manually define the machine type here. A machine type is */
513 /* characterized by the architecture. Some */
514 /* machine types are further subdivided by OS. */
515 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
516 /* Note that SGI IRIX is treated identically to RISCOS. */
517 /* SYSV on an M68K actually means A/UX. */
518 /* The distinction in these cases is usually the stack starting address */
519 # ifndef mach_type_known
520 --> unknown machine type
522 /* Mapping is: M68K ==> Motorola 680X0 */
523 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
524 /* MACOS and AMIGA variants) */
525 /* I386 ==> Intel 386 */
526 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
527 /* FREEBSD, THREE86BSD, MSWIN32, */
528 /* BSDI,SUNOS5, NEXT, other variants) */
529 /* NS32K ==> Encore Multimax */
530 /* MIPS ==> R2000 or R3000 */
531 /* (RISCOS, ULTRIX variants) */
532 /* VAX ==> DEC VAX */
533 /* (BSD, ULTRIX variants) */
534 /* RS6000 ==> IBM RS/6000 AIX3.X */
535 /* RT ==> IBM PC/RT */
536 /* HP_PA ==> HP9000/700 & /800 */
538 /* SPARC ==> SPARC v7/v8/v9 */
539 /* (SUNOS4, SUNOS5, LINUX, */
540 /* DRSNX variants) */
541 /* ALPHA ==> DEC Alpha */
542 /* (OSF1 and LINUX variants) */
543 /* M88K ==> Motorola 88XX0 */
544 /* (CX_UX and DGUX) */
545 /* S370 ==> 370-like machine */
546 /* running Amdahl UTS4 */
547 /* S390 ==> 390-like machine */
549 /* ARM32 ==> Intel StrongARM */
550 /* IA64 ==> Intel IPF */
552 /* (LINUX and HPUX) */
553 /* SH ==> Hitachi SuperH */
554 /* (LINUX & MSWINCE) */
555 /* X86_64 ==> AMD x86-64 */
556 /* POWERPC ==> IBM/Apple PowerPC */
557 /* (MACOS(<=9),DARWIN(incl.MACOSX),*/
558 /* LINUX, NETBSD, NOSYS variants) */
559 /* Handles 32 and 64-bit variants. */
560 /* AIX should be handled here, but */
561 /* that's called an RS6000. */
562 /* CRIS ==> Axis Etrax */
563 /* M32R ==> Renesas M32R */
567 * For each architecture and OS, the following need to be defined:
569 * CPP_WORDSZ is a simple integer constant representing the word size.
570 * in bits. We assume byte addressibility, where a byte has 8 bits.
571 * We also assume CPP_WORDSZ is either 32 or 64.
572 * (We care about the length of pointers, not hardware
573 * bus widths. Thus a 64 bit processor with a C compiler that uses
574 * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
576 * MACH_TYPE is a string representation of the machine type.
577 * OS_TYPE is analogous for the OS.
579 * ALIGNMENT is the largest N, such that
580 * all pointer are guaranteed to be aligned on N byte boundaries.
581 * defining it to be 1 will always work, but perform poorly.
583 * DATASTART is the beginning of the data segment.
584 * On some platforms SEARCH_FOR_DATA_START is defined.
585 * SEARCH_FOR_DATASTART will cause GC_data_start to
586 * be set to an address determined by accessing data backwards from _end
587 * until an unmapped page is found. DATASTART will be defined to be
589 * On UNIX-like systems, the collector will scan the area between DATASTART
590 * and DATAEND for root pointers.
592 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
593 * RTH suggests gaining access to linker script synth'd values with
594 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
595 * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
596 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
597 * without any special options.
599 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
602 * STACKBOTTOM is the cool end of the stack, which is usually the
603 * highest address in the stack.
604 * Under PCR or OS/2, we have other ways of finding thread stacks.
605 * For each machine, the following should:
606 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
607 * 2) define exactly one of
608 * STACKBOTTOM (should be defined to be an expression)
612 * If STACKBOTTOM is defined, then it's value will be used directly as the
613 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
614 * with a method appropriate for most Linux systems. Currently we look
615 * first for __libc_stack_end, and if that fails read it from /proc.
616 * If either of the last two macros are defined, then STACKBOTTOM is computed
617 * during collector startup using one of the following two heuristics:
618 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
619 * the next multiple of STACK_GRAN.
620 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
621 * in small steps (decrement if STACK_GROWS_UP), and read the value
622 * at each location. Remember the value when the first
623 * Segmentation violation or Bus error is signalled. Round that
624 * to the nearest plausible page boundary, and use that instead
627 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
628 * the value of environ is a pointer that can serve as STACKBOTTOM.
629 * I expect that HEURISTIC2 can be replaced by this approach, which
630 * interferes far less with debugging. However it has the disadvantage
631 * that it's confused by a putenv call before the collector is initialized.
632 * This could be dealt with by intercepting putenv ...
634 * If no expression for STACKBOTTOM can be found, and neither of the above
635 * heuristics are usable, the collector can still be used with all of the above
636 * undefined, provided one of the following is done:
637 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
638 * without reference to STACKBOTTOM. This is appropriate for use in
639 * conjunction with thread packages, since there will be multiple stacks.
640 * (Allocating thread stacks in the heap, and treating them as ordinary
641 * heap data objects is also possible as a last resort. However, this is
642 * likely to introduce significant amounts of excess storage retention
643 * unless the dead parts of the thread stacks are periodically cleared.)
644 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
645 * If the author of the client code controls the main program, this is
646 * easily accomplished by introducing a new main program, setting
647 * GC_stackbottom to the address of a local variable, and then calling
648 * the original main program. The new main program would read something
651 * # include "gc_private.h"
653 * main(argc, argv, envp)
655 * char **argv, **envp;
659 * GC_stackbottom = (ptr_t)(&dummy);
660 * return(real_main(argc, argv, envp));
664 * Each architecture may also define the style of virtual dirty bit
665 * implementation to be used:
666 * MPROTECT_VDB: Write protect the heap and catch faults.
667 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
669 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
670 * defined GC_register_dynamic_libraries() for the architecture.
672 * An architecture may define PREFETCH(x) to preload the cache with *x.
673 * This defaults to a no-op.
675 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
677 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
678 * clear the two words at GC_malloc-aligned address x. By default,
679 * word stores of 0 are used instead.
681 * HEAP_START may be defined as the initial address hint for mmap-based
685 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
686 * to push the relevant registers onto the stack. This generally makes
687 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
689 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
690 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
691 && !defined(__INTEL_COMPILER) \
692 && !defined(__PATHCC__)
693 # define HAVE_BUILTIN_UNWIND_INIT
696 # define STACK_GRAN 0x1000000
698 # define MACH_TYPE "M68K"
701 # define OS_TYPE "OPENBSD"
704 # define DATASTART GC_data_start
705 # define DYNAMIC_LOADING
708 # define DATASTART ((ptr_t)(etext))
710 # define USE_GENERIC_PUSH_REGS
713 # define OS_TYPE "NETBSD"
716 # define DATASTART GC_data_start
717 # define DYNAMIC_LOADING
720 # define DATASTART ((ptr_t)(etext))
722 # define USE_GENERIC_PUSH_REGS
725 # define OS_TYPE "LINUX"
726 # define STACKBOTTOM ((ptr_t)0xf0000000)
727 # define USE_GENERIC_PUSH_REGS
728 /* We never got around to the assembly version. */
729 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
731 # define DYNAMIC_LOADING
732 # include <features.h>
733 # if defined(__GLIBC__)&& __GLIBC__>=2
734 # define SEARCH_FOR_DATA_START
736 # if defined(HOST_ANDROID)
737 # define __environ environ
739 extern char **__environ;
740 # define DATASTART ((ptr_t)(&__environ))
741 /* hideous kludge: __environ is the first */
742 /* word in crt0.o, and delimits the start */
743 /* of the data segment, no matter which */
744 /* ld options were passed through. */
745 /* We could use _etext instead, but that */
746 /* would include .rodata, which may */
747 /* contain large read-only data tables */
748 /* that we'd rather not scan. */
749 # endif /* !GLIBC2 */
751 # define DATAEND (_end)
754 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
758 # define OS_TYPE "SUNOS4"
760 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
761 # define HEURISTIC1 /* differs */
762 # define DYNAMIC_LOADING
765 # define OS_TYPE "HP"
767 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
768 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
769 /* empirically determined. seems to work. */
771 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
774 # define OS_TYPE "SYSV"
776 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
778 +((word)etext & 0x1fff))
779 /* This only works for shared-text binaries with magic number 0413.
780 The other sorts of SysV binaries put the data at the end of the text,
781 in which case the default of etext would work. Unfortunately,
782 handling both would require having the magic-number available.
785 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
786 /* The stack starts at the top of memory, but */
787 /* 0x0 cannot be used as setjump_test complains */
788 /* that the stack direction is incorrect. Two */
789 /* bytes down from 0x0 should be safe enough. */
791 # include <sys/mmu.h>
792 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
795 # define OS_TYPE "AMIGA"
796 /* STACKBOTTOM and DATASTART handled specially */
798 # define DATAEND /* not needed */
799 # define GETPAGESIZE() 4096
805 # define OS_TYPE "MACOS"
806 /* see os_dep.c for details of global data segments. */
807 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
808 # define DATAEND /* not needed */
809 # define GETPAGESIZE() 4096
812 # define OS_TYPE "NEXT"
813 # define DATASTART ((ptr_t) get_etext())
814 # define STACKBOTTOM ((ptr_t) 0x4000000)
815 # define DATAEND /* not needed */
819 # if defined(POWERPC)
820 # define MACH_TYPE "POWERPC"
822 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
826 # define OS_TYPE "MACOS"
827 /* see os_dep.c for details of global data segments. */
828 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
829 # define DATAEND /* not needed */
833 # if defined(__powerpc64__)
835 # define CPP_WORDSZ 64
837 # define HBLKSIZE 4096
842 # define OS_TYPE "LINUX"
843 /* HEURISTIC1 has been reliably reported to fail for a 32-bit */
844 /* executable on a 64 bit kernel. */
845 # define LINUX_STACKBOTTOM
846 # define DYNAMIC_LOADING
847 # define SEARCH_FOR_DATA_START
849 # define DATAEND (_end)
854 # define CPP_WORDSZ 64
858 # define OS_TYPE "DARWIN"
859 # define DYNAMIC_LOADING
860 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
861 These aren't used when dyld support is enabled (it is by default) */
862 # define DATASTART ((ptr_t) get_etext())
863 # define DATAEND ((ptr_t) get_end())
864 # define STACKBOTTOM ((ptr_t) 0xc0000000)
866 # define USE_MMAP_ANON
867 # define USE_ASM_PUSH_REGS
868 /* This is potentially buggy. It needs more testing. See the comments in
869 os_dep.c. It relies on threads to track writes. */
870 # ifdef GC_DARWIN_THREADS
871 /* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
874 # define GETPAGESIZE() getpagesize()
875 # if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
876 /* The performance impact of prefetches is untested */
877 # define PREFETCH(x) \
878 __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
879 # define PREFETCH_FOR_WRITE(x) \
880 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
882 /* There seems to be some issues with trylock hanging on darwin. This
883 should be looked into some more */
884 # define NO_PTHREAD_TRYLOCK
888 # define OS_TYPE "FREEBSD"
889 # ifndef GC_FREEBSD_THREADS
890 # define MPROTECT_VDB
892 # define SIG_SUSPEND SIGUSR1
893 # define SIG_THR_RESTART SIGUSR2
894 # define FREEBSD_STACKBOTTOM
896 # define DYNAMIC_LOADING
899 extern char * GC_FreeBSDGetDataStart();
900 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
904 # define OS_TYPE "NETBSD"
907 # define DATASTART GC_data_start
908 # define DYNAMIC_LOADING
910 # ifdef SN_TARGET_PS3
912 # define CPP_WORDSZ 32
915 // extern int _dso_handle[];
916 extern int __bss_start;
918 # define DATAEND (_end)
919 # define DATASTART (__bss_start)
920 # define STACKBOTTOM ((ptr_t) ps3_get_stack_bottom ())
921 # define USE_GENERIC_PUSHREGS
926 # define OS_TYPE "NOSYS"
927 extern void __end[], __dso_handle[];
928 # define DATASTART (__dso_handle) /* OK, that's ugly. */
929 # define DATAEND (__end)
930 /* Stack starts at 0xE0000000 for the simulator. */
932 # define STACK_GRAN 0x10000000
939 # define OS_TYPE "NACL"
940 # if defined(__GLIBC__)
941 # define DYNAMIC_LOADING
943 # define DATASTART ((ptr_t)0x10020000)
945 # define DATAEND (_end)
948 # endif /* STACK_GRAN */
949 # define STACK_GRAN 0x10000
953 # define USE_MMAP_ANON
954 # ifdef USE_MMAP_FIXED
955 # undef USE_MMAP_FIXED
957 # define GETPAGESIZE() 65536
958 # define MAX_NACL_GC_THREADS 1024
962 # define MACH_TYPE "VAX"
963 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
965 # define DATASTART ((ptr_t)(etext))
967 # define OS_TYPE "BSD"
969 /* HEURISTIC2 may be OK, but it's hard to test. */
972 # define OS_TYPE "ULTRIX"
973 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
978 # define MACH_TYPE "RT"
980 # define DATASTART ((ptr_t) 0x10000000)
981 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
985 # define MACH_TYPE "SPARC"
986 # if defined(__arch64__) || defined(__sparcv9)
988 # define CPP_WORDSZ 64
989 # define ELF_CLASS ELFCLASS64
991 # define ALIGNMENT 4 /* Required by hardware */
992 # define CPP_WORDSZ 32
994 # define ALIGN_DOUBLE
995 # ifdef _FILE_OFFSET_BITS
996 # undef _FILE_OFFSET_BITS /* libelf.h & procfs.h doesn't compile with large file support */
997 # define _FILE_OFFSET_BITS 32
1000 # define OS_TYPE "SUNOS5"
1001 extern int _etext[];
1003 extern ptr_t GC_SysVGetDataStart();
1004 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1005 # define DATAEND (_end)
1006 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1008 /* Otherwise we now use calloc. Mmap may result in the */
1009 /* heap interleaved with thread stacks, which can result in */
1010 /* excessive blacklisting. Sbrk is unusable since it */
1011 /* doesn't interact correctly with the system malloc. */
1014 # define HEAP_START (ptr_t)0x40000000
1016 # define HEAP_START DATAEND
1019 /* HEURISTIC1 reportedly no longer works under 2.7. */
1020 /* HEURISTIC2 probably works, but this appears to be preferable. */
1021 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
1022 /* installations that's undefined. We work around this with a */
1024 # include <sys/vmparam.h>
1026 /* This should work everywhere, but doesn't. */
1027 # define STACKBOTTOM USRSTACK
1031 # include <unistd.h>
1032 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1033 /* getpagesize() appeared to be missing from at least one */
1034 /* Solaris 5.4 installation. Weird. */
1035 # define DYNAMIC_LOADING
1038 # define OS_TYPE "SUNOS4"
1039 /* [If you have a weak stomach, don't read this.] */
1040 /* We would like to use: */
1041 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
1042 /* This fails occasionally, due to an ancient, but very */
1043 /* persistent ld bug. etext is set 32 bytes too high. */
1044 /* We instead read the text segment size from the a.out */
1045 /* header, which happens to be mapped into our address space */
1046 /* at the start of the text segment. The detective work here */
1047 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
1048 /* Serpette of INRIA. */
1049 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
1050 # define TEXTSTART 0x2000
1051 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
1052 # define MPROTECT_VDB
1054 # define DYNAMIC_LOADING
1057 # define OS_TYPE "DRSNX"
1058 extern ptr_t GC_SysVGetDataStart();
1060 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1061 # define MPROTECT_VDB
1062 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
1063 # define DYNAMIC_LOADING
1066 # define OS_TYPE "LINUX"
1068 # define DYNAMIC_LOADING
1070 Linux Sparc/a.out not supported
1073 # include <features.h>
1074 # if defined(__GLIBC__) && __GLIBC__ >= 2
1075 # define SEARCH_FOR_DATA_START
1077 extern char **__environ;
1078 # define DATASTART ((ptr_t)(&__environ))
1079 /* hideous kludge: __environ is the first */
1080 /* word in crt0.o, and delimits the start */
1081 /* of the data segment, no matter which */
1082 /* ld options were passed through. */
1083 /* We could use _etext instead, but that */
1084 /* would include .rodata, which may */
1085 /* contain large read-only data tables */
1086 /* that we'd rather not scan. */
1089 # define DATAEND (_end)
1090 # define LINUX_STACKBOTTOM
1093 # define OS_TYPE "OPENBSD"
1094 # define STACKBOTTOM ((ptr_t) 0xf8000000)
1096 # define DATASTART ((ptr_t)(etext))
1099 # define OS_TYPE "NETBSD"
1102 # define DATASTART GC_data_start
1103 # define DYNAMIC_LOADING
1105 extern char etext[];
1106 # define DATASTART ((ptr_t)(etext))
1110 # define OS_TYPE "FREEBSD"
1111 # define SIG_SUSPEND SIGUSR1
1112 # define SIG_THR_RESTART SIGUSR2
1113 # define FREEBSD_STACKBOTTOM
1115 # define DYNAMIC_LOADING
1117 extern char etext[];
1118 extern char edata[];
1120 # define NEED_FIND_LIMIT
1121 # define DATASTART ((ptr_t)(&etext))
1122 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1123 # define DATASTART2 ((ptr_t)(&edata))
1124 # define DATAEND2 ((ptr_t)(&end))
1129 # if defined( NACL )
1130 # define MACH_TYPE "NACL"
1131 # define CPP_WORDSZ 32
1132 # define ALIGNMENT 4
1134 # define MACH_TYPE "I386"
1135 # if defined(__LP64__) || defined(_WIN64)
1136 # define CPP_WORDSZ 64
1137 # define ALIGNMENT 8
1139 # define CPP_WORDSZ 32
1140 # define ALIGNMENT 4
1142 /* Appears to hold for all "32 bit" compilers */
1143 /* except Borland. The -a4 option fixes */
1145 /* Ivan Demakov: For Watcom the option is -zp4. */
1147 # ifndef SMALL_CONFIG
1148 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
1149 /* improvement on Pentiums. */
1151 # ifdef HAVE_BUILTIN_UNWIND_INIT
1152 # define USE_GENERIC_PUSH_REGS
1155 # define OS_TYPE "SEQUENT"
1157 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1158 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
1161 # define OS_TYPE "BEOS"
1163 # define GETPAGESIZE() B_PAGE_SIZE
1165 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1168 # define OS_TYPE "SUNOS5"
1169 extern int _etext[], _end[];
1170 extern ptr_t GC_SysVGetDataStart();
1171 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1172 # define DATAEND (_end)
1173 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
1174 /* but reportedly breaks under 2.8. It appears that the stack */
1175 /* base is a property of the executable, so this should not break */
1176 /* old executables. */
1177 /* HEURISTIC2 probably works, but this appears to be preferable. */
1178 # include <sys/vm.h>
1179 # define STACKBOTTOM USRSTACK
1180 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1181 /* It appears to be fixed in 2.8 and 2.9. */
1182 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1183 /* Reading of dirty bits doesn't seem to work even in solaris 10 */
1184 /*# define PROC_VDB */
1186 # define DYNAMIC_LOADING
1187 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1189 /* Otherwise we now use calloc. Mmap may result in the */
1190 /* heap interleaved with thread stacks, which can result in */
1191 /* excessive blacklisting. Sbrk is unusable since it */
1192 /* doesn't interact correctly with the system malloc. */
1195 # define HEAP_START (ptr_t)0x40000000
1197 # define HEAP_START DATAEND
1201 # define OS_TYPE "SCO"
1203 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1205 +((word)etext & 0xfff))
1206 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1209 # define OS_TYPE "SCO_ELF"
1211 # define DATASTART ((ptr_t)(etext))
1212 # define STACKBOTTOM ((ptr_t) 0x08048000)
1213 # define DYNAMIC_LOADING
1214 # define ELF_CLASS ELFCLASS32
1217 # define OS_TYPE "DGUX"
1218 extern int _etext, _end;
1219 extern ptr_t GC_SysVGetDataStart();
1220 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1221 # define DATAEND (&_end)
1222 # define STACK_GROWS_DOWN
1224 # include <unistd.h>
1225 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1226 # define DYNAMIC_LOADING
1229 # endif /* USE_MMAP */
1230 # define MAP_FAILED (void *) -1
1232 # define HEAP_START (ptr_t)0x40000000
1233 # else /* USE_MMAP */
1234 # define HEAP_START DATAEND
1235 # endif /* USE_MMAP */
1239 /* The Intel compiler doesn't like inline assembly */
1240 # define USE_GENERIC_PUSH_REGS
1242 # define OS_TYPE "LINUX"
1243 # define LINUX_STACKBOTTOM
1247 # define STACK_GRAN 0x10000000
1248 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
1249 /* different kernel configurations. In particular, systems */
1250 /* with 2GB physical memory will usually move the user */
1251 /* address space limit, and hence initial SP to 0x80000000. */
1253 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1254 # define MPROTECT_VDB
1256 /* We seem to get random errors in incremental mode, */
1257 /* possibly because Linux threads is itself a malloc client */
1258 /* and can't deal with the signals. */
1260 # define HEAP_START (ptr_t)0x1000
1261 /* This encourages mmap to give us low addresses, */
1262 /* thus allowing the heap to grow to ~3GB */
1264 # define DYNAMIC_LOADING
1265 # ifdef UNDEFINED /* includes ro data */
1266 extern int _etext[];
1267 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1269 # include <features.h>
1270 # if defined(__GLIBC__) && __GLIBC__ >= 2
1271 # define SEARCH_FOR_DATA_START
1273 extern char **__environ;
1274 # define DATASTART ((ptr_t)(&__environ))
1275 /* hideous kludge: __environ is the first */
1276 /* word in crt0.o, and delimits the start */
1277 /* of the data segment, no matter which */
1278 /* ld options were passed through. */
1279 /* We could use _etext instead, but that */
1280 /* would include .rodata, which may */
1281 /* contain large read-only data tables */
1282 /* that we'd rather not scan. */
1285 # define DATAEND (_end)
1288 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1290 # ifdef USE_I686_PREFETCH
1291 /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */
1292 /* for the next rtelease. */
1293 # define PREFETCH(x) \
1294 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1295 /* Empirically prefetcht0 is much more effective at reducing */
1296 /* cache miss stalls for the targetted load instructions. But it */
1297 /* seems to interfere enough with other cache traffic that the net */
1298 /* result is worse than prefetchnta. */
1300 /* Using prefetches for write seems to have a slight negative */
1301 /* impact on performance, at least for a PIII/500. */
1302 # define PREFETCH_FOR_WRITE(x) \
1303 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1306 # ifdef USE_3DNOW_PREFETCH
1307 # define PREFETCH(x) \
1308 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1309 # define PREFETCH_FOR_WRITE(x) \
1310 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1314 # define OS_TYPE "CYGWIN32"
1315 # define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
1316 # define DATAEND ((ptr_t)GC_DATAEND)
1318 # define STACK_GRAN 0x10000
1322 # define OS_TYPE "OS2"
1323 /* STACKBOTTOM and DATASTART are handled specially in */
1324 /* os_dep.c. OS2 actually has the right */
1326 # define DATAEND /* not needed */
1327 # define USE_GENERIC_PUSH_REGS
1330 # define OS_TYPE "MSWIN32"
1331 /* STACKBOTTOM and DATASTART are handled specially in */
1333 # ifndef __WATCOMC__
1334 # define MPROTECT_VDB
1336 # define DATAEND /* not needed */
1339 # define OS_TYPE "MSWINCE"
1340 # define DATAEND /* not needed */
1343 # define OS_TYPE "DJGPP"
1344 # include "stubinfo.h"
1347 extern int __djgpp_stack_limit;
1348 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1349 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1351 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1352 /* This may not be right. */
1355 # define OS_TYPE "OPENBSD"
1356 # ifdef GC_OPENBSD_THREADS
1357 # define UTHREAD_SP_OFFSET 192
1359 # include <sys/param.h>
1360 # include <uvm/uvm_extern.h>
1361 # define STACKBOTTOM USRSTACK
1363 extern int __data_start[];
1364 # define DATASTART ((ptr_t)(__data_start))
1366 # define DATAEND ((ptr_t)(&_end))
1367 # define DYNAMIC_LOADING
1370 # define OS_TYPE "FREEBSD"
1371 # ifndef GC_FREEBSD_THREADS
1372 # define MPROTECT_VDB
1375 # define SIG_SUSPEND (32+6)
1376 # define SIG_THR_RESTART (32+5)
1378 # define DATAEND (_end)
1380 # define SIG_SUSPEND SIGTSTP
1381 # define SIG_THR_RESTART SIGCONT
1383 # define FREEBSD_STACKBOTTOM
1385 # define DYNAMIC_LOADING
1387 extern char etext[];
1388 extern char * GC_FreeBSDGetDataStart();
1389 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1392 # define OS_TYPE "NETBSD"
1394 # define DYNAMIC_LOADING
1398 # define OS_TYPE "THREE86BSD"
1401 # define OS_TYPE "BSDI"
1403 # if defined(OPENBSD) || defined(NETBSD) \
1404 || defined(THREE86BSD) || defined(BSDI)
1406 extern char etext[];
1407 # define DATASTART ((ptr_t)(etext))
1410 # define OS_TYPE "NEXT"
1411 # define DATASTART ((ptr_t) get_etext())
1412 # define STACKBOTTOM ((ptr_t)0xc0000000)
1413 # define DATAEND /* not needed */
1416 # define OS_TYPE "DOS4GW"
1417 extern long __nullarea;
1419 extern char *_STACKTOP;
1420 /* Depending on calling conventions Watcom C either precedes
1421 or does not precedes with undescore names of C-variables.
1422 Make sure startup code variables always have the same names. */
1423 #pragma aux __nullarea "*";
1424 #pragma aux _end "*";
1425 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1426 /* confused? me too. */
1427 # define DATASTART ((ptr_t) &__nullarea)
1428 # define DATAEND ((ptr_t) &_end)
1431 # define OS_TYPE "HURD"
1432 # define STACK_GROWS_DOWN
1434 extern int __data_start[];
1435 # define DATASTART ( (ptr_t) (__data_start))
1437 # define DATAEND ( (ptr_t) (_end))
1438 /* # define MPROTECT_VDB Not quite working yet? */
1439 # define DYNAMIC_LOADING
1444 # define MACH_TYPE "NS32K"
1445 # define ALIGNMENT 4
1446 extern char **environ;
1447 # define DATASTART ((ptr_t)(&environ))
1448 /* hideous kludge: environ is the first */
1449 /* word in crt0.o, and delimits the start */
1450 /* of the data segment, no matter which */
1451 /* ld options were passed through. */
1452 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1456 # define MACH_TYPE "MIPS"
1458 /* This was developed for a linuxce style platform. Probably */
1459 /* needs to be tweaked for workstation class machines. */
1460 # define OS_TYPE "LINUX"
1461 # define DYNAMIC_LOADING
1463 # define DATAEND (_end)
1464 #pragma weak __data_start
1465 extern int __data_start[];
1466 # define DATASTART ((ptr_t)(__data_start))
1467 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1468 # define ALIGNMENT 8
1469 # define CPP_WORDSZ 64
1471 # define ALIGNMENT 4
1473 # define USE_GENERIC_PUSH_REGS
1474 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1475 # define LINUX_STACKBOTTOM
1477 # define STACKBOTTOM 0x80000000
1482 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1483 extern int _fdata[], _end[];
1484 # define DATASTART ((ptr_t)_fdata)
1485 # define DATAEND ((ptr_t)_end)
1486 # define CPP_WORDSZ _MIPS_SZPTR
1487 # define ALIGNMENT (_MIPS_SZPTR/8)
1489 extern int etext[], edata[], end[];
1490 extern int _DYNAMIC_LINKING[], _gp[];
1491 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1492 + ((word)etext & 0xffff)))
1493 # define DATAEND (edata)
1494 # define DATASTART2 (_DYNAMIC_LINKING \
1495 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1497 # define DATAEND2 (end)
1498 # define ALIGNMENT 4
1500 # define OS_TYPE "EWS4800"
1501 # define USE_GENERIC_PUSH_REGS 1
1505 # define DATASTART (ptr_t)0x10000000
1506 /* Could probably be slightly higher since */
1507 /* startup code allocates lots of stuff. */
1508 # define OS_TYPE "ULTRIX"
1509 # define ALIGNMENT 4
1513 # define DATASTART (ptr_t)0x10000000
1514 # define OS_TYPE "RISCOS"
1515 # define ALIGNMENT 4 /* Required by hardware */
1519 extern int _fdata[];
1520 # define DATASTART ((ptr_t)(_fdata))
1522 # define HEAP_START (ptr_t)0x30000000
1524 # define HEAP_START DATASTART
1526 /* Lowest plausible heap address. */
1527 /* In the MMAP case, we map there. */
1528 /* In either case it is used to identify */
1529 /* heap sections so they're not */
1530 /* considered as roots. */
1531 # define OS_TYPE "IRIX5"
1532 /*# define MPROTECT_VDB DOB: this should work, but there is evidence */
1533 /* of recent breakage. */
1535 # define CPP_WORDSZ _MIPS_SZPTR
1536 # define ALIGNMENT (_MIPS_SZPTR/8)
1537 # if CPP_WORDSZ != 64
1538 # define ALIGN_DOUBLE
1541 # define ALIGNMENT 4
1542 # define ALIGN_DOUBLE
1544 # define DYNAMIC_LOADING
1547 # define OS_TYPE "MSWINCE"
1548 # define ALIGNMENT 4
1549 # define DATAEND /* not needed */
1551 # if defined(NETBSD)
1552 # define ALIGNMENT 4
1553 # define OS_TYPE "NETBSD"
1555 # define USE_GENERIC_PUSH_REGS
1558 # define DATASTART GC_data_start
1559 # define NEED_FIND_LIMIT
1560 # define DYNAMIC_LOADING
1562 # define DATASTART ((ptr_t) 0x10000000)
1563 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1569 # define MACH_TYPE "RS6000"
1574 # undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1577 # define ALIGNMENT 8
1578 # define CPP_WORDSZ 64
1579 # define STACKBOTTOM ((ptr_t)0x1000000000000000)
1581 # define ALIGNMENT 4
1582 # define CPP_WORDSZ 32
1583 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1586 # define USE_MMAP_ANON
1587 /* From AIX linker man page:
1588 _text Specifies the first location of the program.
1589 _etext Specifies the first location after the program.
1590 _data Specifies the first location of the data.
1591 _edata Specifies the first location after the initialized data
1592 _end or end Specifies the first location after all data.
1594 extern int _data[], _end[];
1595 # define DATASTART ((ptr_t)((ulong)_data))
1596 # define DATAEND ((ptr_t)((ulong)_end))
1598 # define USE_GENERIC_PUSH_REGS
1599 # define DYNAMIC_LOADING
1600 /* For really old versions of AIX, this may have to be removed. */
1604 # define MACH_TYPE "HP_PA"
1606 # define CPP_WORDSZ 64
1607 # define ALIGNMENT 8
1609 # define CPP_WORDSZ 32
1610 # define ALIGNMENT 4
1611 # define ALIGN_DOUBLE
1613 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1614 # ifndef LINUX /* For now. */
1615 # define MPROTECT_VDB
1618 # define GENERIC_COMPARE_AND_SWAP
1619 /* No compare-and-swap instruction. Use pthread mutexes */
1620 /* when we absolutely have to. */
1621 # ifdef PARALLEL_MARK
1622 # define USE_MARK_BYTES
1623 /* Minimize compare-and-swap usage. */
1626 # define STACK_GROWS_UP
1628 # define OS_TYPE "HPUX"
1629 extern int __data_start[];
1630 # define DATASTART ((ptr_t)(__data_start))
1632 /* The following appears to work for 7xx systems running HP/UX */
1633 /* 9.xx Furthermore, it might result in much faster */
1634 /* collections than HEURISTIC2, which may involve scanning */
1635 /* segments that directly precede the stack. It is not the */
1636 /* default, since it may not work on older machine/OS */
1637 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1639 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1641 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1642 /* to this. Note that the GC must be initialized before the */
1643 /* first putenv call. */
1644 extern char ** environ;
1645 # define STACKBOTTOM ((ptr_t)environ)
1647 # define DYNAMIC_LOADING
1648 # include <unistd.h>
1649 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1651 # define PREFETCH(x) { \
1652 register long addr = (long)(x); \
1653 (void) _asm ("LDW", 0, 0, addr, 0); \
1658 # define OS_TYPE "LINUX"
1659 # define LINUX_STACKBOTTOM
1660 # define DYNAMIC_LOADING
1661 # define SEARCH_FOR_DATA_START
1663 # define DATAEND (&_end)
1668 # define MACH_TYPE "ALPHA"
1669 # define ALIGNMENT 8
1670 # define CPP_WORDSZ 64
1672 # define USE_GENERIC_PUSH_REGS
1673 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1674 /* fp registers in some cases when the target is a 21264. The assembly */
1675 /* code doesn't handle that yet, and version dependencies make that a */
1676 /* bit tricky. Do the easy thing for now. */
1679 # define OS_TYPE "NETBSD"
1681 # define DATASTART GC_data_start
1682 # define ELFCLASS32 32
1683 # define ELFCLASS64 64
1684 # define ELF_CLASS ELFCLASS64
1685 # define DYNAMIC_LOADING
1688 # define OS_TYPE "OPENBSD"
1690 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1691 # define DATASTART GC_data_start
1692 # define ELFCLASS32 32
1693 # define ELFCLASS64 64
1694 # define ELF_CLASS ELFCLASS64
1695 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1696 # define DATASTART ((ptr_t) 0x140000000)
1700 # define OS_TYPE "FREEBSD"
1701 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1702 # define SIG_SUSPEND SIGTSTP
1703 # define SIG_THR_RESTART SIGCONT
1704 # define FREEBSD_STACKBOTTOM
1706 # define DYNAMIC_LOADING
1708 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1709 extern char etext[];
1710 extern char edata[];
1712 # define NEED_FIND_LIMIT
1713 # define DATASTART ((ptr_t)(&etext))
1714 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1715 # define DATASTART2 ((ptr_t)(&edata))
1716 # define DATAEND2 ((ptr_t)(&end))
1719 # define OS_TYPE "OSF1"
1720 # define DATASTART ((ptr_t) 0x140000000)
1722 # define DATAEND ((ptr_t) &_end)
1723 extern char ** environ;
1724 /* round up from the value of environ to the nearest page boundary */
1725 /* Probably breaks if putenv is called before collector */
1726 /* initialization. */
1727 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1728 /* # define HEURISTIC2 */
1729 /* Normally HEURISTIC2 is too conervative, since */
1730 /* the text segment immediately follows the stack. */
1731 /* Hence we give an upper pound. */
1732 /* This is currently unused, since we disabled HEURISTIC2 */
1733 extern int __start[];
1734 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1735 # ifndef GC_OSF1_THREADS
1736 /* Unresolved signal issues with threads. */
1737 # define MPROTECT_VDB
1739 # define DYNAMIC_LOADING
1742 # define OS_TYPE "LINUX"
1743 # define LINUX_STACKBOTTOM
1745 # define SEARCH_FOR_DATA_START
1746 # define DYNAMIC_LOADING
1748 # define DATASTART ((ptr_t) 0x140000000)
1751 # define DATAEND (_end)
1752 # define MPROTECT_VDB
1753 /* Has only been superficially tested. May not */
1754 /* work on all versions. */
1759 # define MACH_TYPE "IA64"
1760 # define USE_GENERIC_PUSH_REGS
1761 /* We need to get preserved registers in addition to register */
1762 /* windows. That's easiest to do with setjmp. */
1763 # ifdef PARALLEL_MARK
1764 # define USE_MARK_BYTES
1765 /* Compare-and-exchange is too expensive to use for */
1766 /* setting mark bits. */
1770 # define CPP_WORDSZ 32
1771 # define ALIGN_DOUBLE
1772 /* Requires 8 byte alignment for malloc */
1773 # define ALIGNMENT 4
1778 # define CPP_WORDSZ 64
1779 # define ALIGN_DOUBLE
1780 /* Requires 16 byte alignment for malloc */
1781 # define ALIGNMENT 8
1783 # define OS_TYPE "HPUX"
1784 extern int __data_start[];
1785 # define DATASTART ((ptr_t)(__data_start))
1786 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1787 /* to this. Note that the GC must be initialized before the */
1788 /* first putenv call. */
1789 extern char ** environ;
1790 # define STACKBOTTOM ((ptr_t)environ)
1791 # define HPUX_STACKBOTTOM
1792 # define DYNAMIC_LOADING
1793 # include <unistd.h>
1794 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1795 /* The following was empirically determined, and is probably */
1796 /* not very robust. */
1797 /* Note that the backing store base seems to be at a nice */
1798 /* address minus one page. */
1799 # define BACKING_STORE_DISPLACEMENT 0x1000000
1800 # define BACKING_STORE_ALIGNMENT 0x1000
1801 extern ptr_t GC_register_stackbottom;
1802 # define BACKING_STORE_BASE GC_register_stackbottom
1803 /* Known to be wrong for recent HP/UX versions!!! */
1806 # define CPP_WORDSZ 64
1807 # define ALIGN_DOUBLE
1808 /* Requires 16 byte alignment for malloc */
1809 # define ALIGNMENT 8
1810 # define OS_TYPE "LINUX"
1811 /* The following works on NUE and older kernels: */
1812 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1813 /* This does not work on NUE: */
1814 # define LINUX_STACKBOTTOM
1815 /* We also need the base address of the register stack */
1816 /* backing store. This is computed in */
1817 /* GC_linux_register_stack_base based on the following */
1819 # define BACKING_STORE_ALIGNMENT 0x100000
1820 # define BACKING_STORE_DISPLACEMENT 0x80000000
1821 extern ptr_t GC_register_stackbottom;
1822 # define BACKING_STORE_BASE GC_register_stackbottom
1823 # define SEARCH_FOR_DATA_START
1825 # define DYNAMIC_LOADING
1827 /* In the Intel compiler environment, we seem to end up with */
1828 /* statically linked executables and an undefined reference */
1831 # define MPROTECT_VDB
1832 /* Requires Linux 2.3.47 or later. */
1834 # define DATAEND (_end)
1836 # ifndef __INTEL_COMPILER
1837 # define PREFETCH(x) \
1838 __asm__ (" lfetch [%0]": : "r"(x))
1839 # define PREFETCH_FOR_WRITE(x) \
1840 __asm__ (" lfetch.excl [%0]": : "r"(x))
1841 # define CLEAR_DOUBLE(x) \
1842 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1844 # include <ia64intrin.h>
1845 # define PREFETCH(x) \
1846 __lfetch(__lfhint_none, (x))
1847 # define PREFETCH_FOR_WRITE(x) \
1848 __lfetch(__lfhint_nta, (x))
1849 # define CLEAR_DOUBLE(x) \
1850 __stf_spill((void *)(x), 0)
1851 # endif // __INTEL_COMPILER
1855 /* FIXME: This is a very partial guess. There is no port, yet. */
1856 # define OS_TYPE "MSWIN32"
1857 /* STACKBOTTOM and DATASTART are handled specially in */
1859 # define DATAEND /* not needed */
1860 # if defined(_WIN64)
1861 # define CPP_WORDSZ 64
1863 # define CPP_WORDSZ 32 /* Is this possible? */
1865 # define ALIGNMENT 8
1870 # define MACH_TYPE "M88K"
1871 # define ALIGNMENT 4
1872 # define ALIGN_DOUBLE
1875 # define OS_TYPE "CX_UX"
1876 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1879 # define OS_TYPE "DGUX"
1880 extern ptr_t GC_SysVGetDataStart();
1881 # define DATASTART GC_SysVGetDataStart(0x10000, etext)
1883 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1887 /* If this still works, and if anyone cares, this should probably */
1888 /* be moved to the S390 category. */
1889 # define MACH_TYPE "S370"
1890 # define ALIGNMENT 4 /* Required by hardware */
1891 # define USE_GENERIC_PUSH_REGS
1893 # define OS_TYPE "UTS4"
1895 extern int _etext[];
1897 extern ptr_t GC_SysVGetDataStart();
1898 # define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1899 # define DATAEND (_end)
1905 # define MACH_TYPE "S390"
1906 # define USE_GENERIC_PUSH_REGS
1908 # define ALIGNMENT 4
1909 # define CPP_WORDSZ 32
1911 # define ALIGNMENT 8
1912 # define CPP_WORDSZ 64
1915 # define HBLKSIZE 4096
1918 # define OS_TYPE "LINUX"
1919 # define LINUX_STACKBOTTOM
1920 # define DYNAMIC_LOADING
1921 extern int __data_start[] __attribute__((weak));
1922 # define DATASTART ((ptr_t)(__data_start))
1923 extern int _end[] __attribute__((weak));
1924 # define DATAEND (_end)
1925 # define CACHE_LINE_SIZE 256
1926 # define GETPAGESIZE() 4096
1931 # define ALIGNMENT 4
1932 extern int _etext[];
1933 # define DATASTART ((ptr_t)(_etext))
1938 # if defined( NACL )
1939 # define MACH_TYPE "NACL"
1941 # define MACH_TYPE "ARM32"
1943 # define CPP_WORDSZ 32
1944 # define ALIGNMENT 4
1946 # define OS_TYPE "NETBSD"
1949 # define DATASTART GC_data_start
1950 # define DYNAMIC_LOADING
1952 extern char etext[];
1953 # define DATASTART ((ptr_t)(etext))
1955 # define USE_GENERIC_PUSH_REGS
1958 # define OS_TYPE "LINUX"
1959 # define LINUX_STACKBOTTOM
1961 # define STACK_GRAN 0x10000000
1962 # define USE_GENERIC_PUSH_REGS
1964 # define DYNAMIC_LOADING
1965 # include <features.h>
1966 # if defined(__GLIBC__) && __GLIBC__ >= 2
1967 # define SEARCH_FOR_DATA_START
1968 # elif defined(HOST_ANDROID)
1969 # define SEARCH_FOR_DATA_START
1971 extern char **__environ;
1972 # define DATASTART ((ptr_t)(&__environ))
1973 /* hideous kludge: __environ is the first */
1974 /* word in crt0.o, and delimits the start */
1975 /* of the data segment, no matter which */
1976 /* ld options were passed through. */
1977 /* We could use _etext instead, but that */
1978 /* would include .rodata, which may */
1979 /* contain large read-only data tables */
1980 /* that we'd rather not scan. */
1983 # define DATAEND (_end)
1986 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1990 # define OS_TYPE "MSWINCE"
1991 # define DATAEND /* not needed */
1994 # define OS_TYPE "DARWIN"
1995 # define DATASTART ((ptr_t) get_etext())
1996 # define DATAEND ((ptr_t) get_end())
1997 # define STACKBOTTOM ((ptr_t) 0x30000000)
1999 # define USE_MMAP_ANON
2003 /* __data_start is usually defined in the target linker script. */
2004 extern int __data_start[];
2005 # define DATASTART (ptr_t)(__data_start)
2006 # define USE_GENERIC_PUSH_REGS
2007 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
2008 extern void *__stack_base__;
2009 # define STACKBOTTOM ((ptr_t) (__stack_base__))
2014 # define MACH_TYPE "CRIS"
2015 # define CPP_WORDSZ 32
2016 # define ALIGNMENT 1
2017 # define OS_TYPE "LINUX"
2018 # define DYNAMIC_LOADING
2019 # define LINUX_STACKBOTTOM
2020 # define USE_GENERIC_PUSH_REGS
2021 # define SEARCH_FOR_DATA_START
2023 # define DATAEND (_end)
2027 # define MACH_TYPE "SH"
2028 # define ALIGNMENT 4
2030 # define OS_TYPE "MSWINCE"
2031 # define DATAEND /* not needed */
2034 # define OS_TYPE "LINUX"
2035 # define LINUX_STACKBOTTOM
2036 # define USE_GENERIC_PUSH_REGS
2037 # define DYNAMIC_LOADING
2038 # define SEARCH_FOR_DATA_START
2040 # define DATAEND (_end)
2043 # define OS_TYPE "NETBSD"
2045 # define DATASTART GC_data_start
2046 # define USE_GENERIC_PUSH_REGS
2047 # define DYNAMIC_LOADING
2052 # define MACH_TYPE "SH4"
2053 # define OS_TYPE "MSWINCE"
2054 # define ALIGNMENT 4
2055 # define DATAEND /* not needed */
2059 # define CPP_WORDSZ 32
2060 # define MACH_TYPE "M32R"
2061 # define ALIGNMENT 4
2063 # define OS_TYPE "LINUX"
2064 # define LINUX_STACKBOTTOM
2066 # define STACK_GRAN 0x10000000
2067 # define USE_GENERIC_PUSH_REGS
2068 # define DYNAMIC_LOADING
2069 # define SEARCH_FOR_DATA_START
2071 # define DATAEND (_end)
2076 # define MACH_TYPE "X86_64"
2077 # define ALIGNMENT 8
2078 # define CPP_WORDSZ 64
2080 # define HBLKSIZE 4096
2082 # define CACHE_LINE_SIZE 64
2083 # define USE_GENERIC_PUSH_REGS
2085 # define OS_TYPE "LINUX"
2086 # define LINUX_STACKBOTTOM
2088 # define FALLBACK_TO_MMAP
2090 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
2091 # define MPROTECT_VDB
2093 /* We seem to get random errors in incremental mode, */
2094 /* possibly because Linux threads is itself a malloc client */
2095 /* and can't deal with the signals. */
2098 # define DYNAMIC_LOADING
2099 # ifdef UNDEFINED /* includes ro data */
2100 extern int _etext[];
2101 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
2103 # include <features.h>
2104 # define SEARCH_FOR_DATA_START
2106 # define DATAEND (_end)
2109 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2111 # if defined(__GNUC__) && __GNUC >= 3
2112 # define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2113 # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2117 # define OS_TYPE "DARWIN"
2118 # define DARWIN_DONT_PARSE_STACK
2119 # define DYNAMIC_LOADING
2120 /* XXX: see get_end(3), get_etext() and get_end() should not be used.
2121 These aren't used when dyld support is enabled (it is by default) */
2122 # define DATASTART ((ptr_t) get_etext())
2123 # define DATAEND ((ptr_t) get_end())
2124 # define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
2128 # define USE_MMAP_ANON
2129 # ifdef GC_DARWIN_THREADS
2130 # define MPROTECT_VDB
2132 # include <unistd.h>
2133 # define GETPAGESIZE() getpagesize()
2134 /* There seems to be some issues with trylock hanging on darwin. This
2135 should be looked into some more */
2138 # define OS_TYPE "FREEBSD"
2139 # ifndef GC_FREEBSD_THREADS
2140 # define MPROTECT_VDB
2143 # define SIG_SUSPEND (32+6)
2144 # define SIG_THR_RESTART (32+5)
2146 # define DATAEND (_end)
2148 # define SIG_SUSPEND SIGUSR1
2149 # define SIG_THR_RESTART SIGUSR2
2151 # define NEED_FIND_LIMIT
2152 # define FREEBSD_STACKBOTTOM
2154 # define DYNAMIC_LOADING
2156 extern char etext[];
2157 extern char * GC_FreeBSDGetDataStart();
2158 # define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2161 # define OS_TYPE "NETBSD"
2163 # define DYNAMIC_LOADING
2166 extern char etext[];
2167 # define SEARCH_FOR_DATA_START
2170 # define OS_TYPE "OPENBSD"
2171 # define ELF_CLASS ELFCLASS64
2172 # ifdef GC_OPENBSD_THREADS
2173 # define UTHREAD_SP_OFFSET 400
2175 # include <sys/param.h>
2176 # include <uvm/uvm_extern.h>
2177 # define STACKBOTTOM USRSTACK
2179 extern int __data_start[];
2180 # define DATASTART ((ptr_t)(__data_start))
2182 # define DATAEND ((ptr_t)(&_end))
2183 # define DYNAMIC_LOADING
2187 #if defined(LINUX) && defined(USE_MMAP)
2188 /* The kernel may do a somewhat better job merging mappings etc. */
2189 /* with anonymous mappings. */
2190 # define USE_MMAP_ANON
2193 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2194 /* Rld appears to allocate some memory with its own allocator, and */
2195 /* some through malloc, which might be redirected. To make this */
2196 /* work with collectable memory, we have to scan memory allocated */
2197 /* by rld's internal malloc. */
2198 # define USE_PROC_FOR_LIBRARIES
2201 # ifndef STACK_GROWS_UP
2202 # define STACK_GROWS_DOWN
2206 # define CPP_WORDSZ 32
2215 # define DATAEND (end)
2218 # if defined(SVR4) && !defined(GETPAGESIZE)
2219 # include <unistd.h>
2220 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
2223 # ifndef GETPAGESIZE
2224 # if defined(SUNOS5) || defined(IRIX5)
2225 # include <unistd.h>
2227 # define GETPAGESIZE() getpagesize()
2230 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2231 /* OS has SVR4 generic features. Probably others also qualify. */
2235 # if defined(SUNOS5) || defined(DRSNX)
2236 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
2239 /* OS has SUNOS5 style signal handlers. */
2247 # if defined(FREEBSD) && ((__FreeBSD__ >= 4) || (__FreeBSD_kernel__ >= 4))
2251 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2252 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2253 || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2254 || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2255 # define UNIX_LIKE /* Basic Unix-like system calls work. */
2258 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2263 # undef DYNAMIC_LOADING
2268 # undef MPROTECT_VDB
2273 /* Postponed for now. */
2275 # undef MPROTECT_VDB
2278 # ifdef SMALL_CONFIG
2279 /* Presumably not worth the space it takes. */
2281 # undef MPROTECT_VDB
2285 # undef MPROTECT_VDB /* Can't deal with address space holes. */
2288 # ifdef PARALLEL_MARK
2289 # undef MPROTECT_VDB /* For now. */
2292 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2293 # define DEFAULT_VDB
2297 # define PREFETCH(x)
2298 # define NO_PREFETCH
2301 # ifndef PREFETCH_FOR_WRITE
2302 # define PREFETCH_FOR_WRITE(x)
2303 # define NO_PREFETCH_FOR_WRITE
2306 # ifndef CACHE_LINE_SIZE
2307 # define CACHE_LINE_SIZE 32 /* Wild guess */
2310 # if defined(LINUX) || defined(__GLIBC__)
2311 # define REGISTER_LIBRARIES_EARLY
2312 /* We sometimes use dl_iterate_phdr, which may acquire an internal */
2313 /* lock. This isn't safe after the world has stopped. So we must */
2314 /* call GC_register_dynamic_libraries before stopping the world. */
2315 /* For performance reasons, this may be beneficial on other */
2316 /* platforms as well, though it should be avoided in win32. */
2319 # if defined(SEARCH_FOR_DATA_START)
2320 extern ptr_t GC_data_start;
2321 # define DATASTART GC_data_start
2324 # ifndef CLEAR_DOUBLE
2325 # define CLEAR_DOUBLE(x) \
2326 ((word*)x)[0] = 0; \
2328 # endif /* CLEAR_DOUBLE */
2330 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2331 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2332 # define GC_SOLARIS_THREADS
2335 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2336 --> inconsistent configuration
2338 # if defined(GC_LINUX_THREADS) && !(defined(LINUX) || defined(NACL))
2339 --> inconsistent configuration
2341 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2342 --> inconsistent configuration
2344 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2345 --> inconsistent configuration
2347 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2348 --> inconsistent configuration
2350 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2351 --> inconsistent configuration
2354 # if defined(PCR) || defined(SRC_M3) || \
2355 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2356 defined(GC_PTHREADS) || defined(SN_TARGET_PS3)
2360 # if defined(HP_PA) || defined(M88K) \
2361 || defined(POWERPC) && !defined(DARWIN) \
2362 || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2363 || (defined(I386) && defined(__LCC__))
2364 /* Use setjmp based hack to mark from callee-save registers. */
2365 /* The define should move to the individual platform */
2367 # define USE_GENERIC_PUSH_REGS
2370 # if defined(MSWINCE)
2375 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
2376 /* include assembly code to do it well. */
2379 /* Can we save call chain in objects for debugging? */
2380 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */
2381 /* frame) to reasonable values for the platform. */
2382 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */
2383 /* at build time, though we feel free to adjust it slightly. */
2384 /* Define NEED_CALLINFO if we either save the call stack or */
2385 /* GC_ADD_CALLER is defined. */
2386 /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */
2389 # define CAN_SAVE_CALL_ARGS
2391 #if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__))
2392 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
2393 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
2394 # define CAN_SAVE_CALL_ARGS
2397 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2398 && defined(GC_CAN_SAVE_CALL_STACKS)
2399 # define SAVE_CALL_CHAIN
2401 # ifdef SAVE_CALL_CHAIN
2402 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2403 # define NARGS SAVE_CALL_NARGS
2405 # define NARGS 0 /* Number of arguments to save for each call. */
2408 # ifdef SAVE_CALL_CHAIN
2409 # ifndef SAVE_CALL_COUNT
2410 # define NFRAMES 6 /* Number of frames to save. Even for */
2411 /* alignment reasons. */
2413 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2415 # define NEED_CALLINFO
2416 # endif /* SAVE_CALL_CHAIN */
2417 # ifdef GC_ADD_CALLER
2420 # define NEED_CALLINFO
2423 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2424 # define DBG_HDRS_ALL
2427 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2428 # define POINTER_SHIFT 0
2431 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2432 # define POINTER_MASK ((GC_word)(-1))
2435 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2436 # define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2439 # if defined(FIXUP_POINTER)
2440 # define NEED_FIXUP_POINTER 1
2442 # define NEED_FIXUP_POINTER 0
2443 # define FIXUP_POINTER(p)
2447 /* This relies on some type definitions from gc_priv.h, from */
2448 /* where it's normally included. */
2450 /* How to get heap memory from the OS: */
2451 /* Note that sbrk()-like allocation is preferred, since it */
2452 /* usually makes it possible to merge consecutively allocated */
2453 /* chunks. It also avoids unintented recursion with */
2454 /* -DREDIRECT_MALLOC. */
2455 /* GET_MEM() returns a HLKSIZE aligned chunk. */
2456 /* 0 is taken to mean failure. */
2457 /* In the case os USE_MMAP, the argument must also be a */
2458 /* physical page size. */
2459 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2460 /* though we should perhaps take advantage of the case in which */
2462 struct hblk; /* See gc_priv.h. */
2464 char * real_malloc();
2465 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2469 void * os2_alloc(size_t bytes);
2470 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2474 # if defined(NEXT) || defined(DOS4GW) || \
2475 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2476 (defined(SUNOS5) && !defined(USE_MMAP))
2477 # define GET_MEM(bytes) HBLKPTR((size_t) \
2478 calloc(1, (size_t)bytes + GC_page_size) \
2482 extern ptr_t GC_win32_get_mem();
2483 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2486 # if defined(USE_TEMPORARY_MEMORY)
2487 extern Ptr GC_MacTemporaryNewPtr(size_t size,
2488 Boolean clearMemory);
2489 # define GET_MEM(bytes) HBLKPTR( \
2490 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2493 # define GET_MEM(bytes) HBLKPTR( \
2494 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2498 extern ptr_t GC_wince_get_mem();
2499 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2501 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2502 extern void *GC_amiga_get_mem(size_t size);
2503 # define GET_MEM(bytes) HBLKPTR((size_t) \
2504 GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2507 # if defined(SN_TARGET_PS3)
2508 extern void *ps3_get_mem (size_t size);
2509 # define GET_MEM(bytes) (struct hblk*) ps3_get_mem (bytes)
2511 extern ptr_t GC_unix_get_mem(word size);
2512 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2522 #endif /* GC_PRIVATE_H */
2524 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2525 /* IBMs xlc compiler doesn't appear to follow the convention of */
2526 /* defining __STDC__ to be zero in extended mode. */
2530 # endif /* GCCONFIG_H */