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 by Hewlett-Packard Company. All rights reserved.
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
29 /* Machine dependent parameters. Some tuning parameters can be found */
30 /* near the top of gc_private.h. */
32 /* Machine specific parts contributed by various people. See README file. */
34 /* First a unified test for Linux: */
35 # if defined(linux) || defined(__linux__)
39 /* And one for NetBSD: */
40 # if defined(__NetBSD__)
44 /* And one for OpenBSD: */
45 # if defined(__OpenBSD__)
49 /* And one for FreeBSD: */
50 # if defined(__FreeBSD__)
54 /* Determine the machine type: */
55 # if defined(__XSCALE__)
59 # define mach_type_known
62 # if defined(sun) && defined(mc68000)
65 # define mach_type_known
67 # if defined(hp9000s300)
70 # define mach_type_known
72 # if defined(OPENBSD) && defined(m68k)
74 # define mach_type_known
76 # if defined(OPENBSD) && defined(__sparc__)
78 # define mach_type_known
80 # if defined(NETBSD) && defined(m68k)
82 # define mach_type_known
84 # if defined(NETBSD) && defined(__powerpc__)
86 # define mach_type_known
88 # if defined(NETBSD) && defined(__arm32__)
90 # define mach_type_known
99 # define mach_type_known
101 # if defined(mips) || defined(__mips) || defined(_mips)
103 # if defined(nec_ews) || defined(_nec_ews)
106 # if !defined(LINUX) && !defined(EWS4800)
107 # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
110 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
111 || defined(__SYSTYPE_SVR4__)
112 # define IRIX5 /* or IRIX 6.X */
114 # define RISCOS /* or IRIX 4.X */
118 # if defined(__NetBSD__) && defined(__MIPSEL__)
121 # define mach_type_known
123 # if defined(DGUX) && (defined(i386) || defined(__i386__))
128 # define mach_type_known
130 # if defined(sequent) && (defined(i386) || defined(__i386__))
133 # define mach_type_known
135 # if defined(sun) && (defined(i386) || defined(__i386__))
138 # define mach_type_known
140 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
143 # define mach_type_known
147 # define mach_type_known
149 # if defined(sun) && (defined(sparc) || defined(__sparc))
151 /* Test for SunOS 5.x */
158 # define mach_type_known
160 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
161 && !defined(__OpenBSD__) && !(__NetBSD__)
164 # define mach_type_known
168 # define mach_type_known
170 # if defined(__NetBSD__) && defined(__sparc__)
172 # define mach_type_known
174 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
175 /* The above test may need refinement */
177 # if defined(_SCO_ELF)
182 # define mach_type_known
184 # if defined(_AUX_SOURCE)
187 # define mach_type_known
189 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
190 || defined(hppa) || defined(__hppa__)
195 # define mach_type_known
197 # if defined(__ia64) && defined(_HPUX_SOURCE)
200 # define mach_type_known
202 # if defined(__BEOS__) && defined(_X86_)
205 # define mach_type_known
207 # if defined(LINUX) && (defined(i386) || defined(__i386__))
209 # define mach_type_known
211 # if defined(LINUX) && defined(__x86_64__)
213 # define mach_type_known
215 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
217 # define mach_type_known
219 # if defined(LINUX) && defined(__arm__)
221 # define mach_type_known
223 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
225 # define mach_type_known
227 # if defined(LINUX) && defined(__mc68000__)
229 # define mach_type_known
231 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
233 # define mach_type_known
235 # if defined(LINUX) && defined(__arm__)
237 # define mach_type_known
239 # if defined(LINUX) && defined(__sh__)
241 # define mach_type_known
243 # if defined(__alpha) || defined(__alpha__)
245 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
246 # define OSF1 /* a.k.a Digital Unix */
248 # define mach_type_known
250 # if defined(_AMIGA) && !defined(AMIGA)
255 # define mach_type_known
257 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
260 # define mach_type_known
262 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
265 # define mach_type_known
267 # if defined(macosx) || \
268 defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
271 # define mach_type_known
273 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
276 --> Not really supported
, but at least we recognize it
.
278 # if defined(NeXT) && defined(mc68000)
281 # define mach_type_known
283 # if defined(NeXT) && (defined(i386) || defined(__i386__))
286 # define mach_type_known
288 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
291 # define mach_type_known
293 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
295 # define mach_type_known
297 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
299 # define mach_type_known
301 # if defined(bsdi) && (defined(i386) || defined(__i386__))
304 # define mach_type_known
306 # if !defined(mach_type_known) && defined(__386BSD__)
309 # define mach_type_known
311 # if defined(_CX_UX) && defined(_M88K)
314 # define mach_type_known
316 # if defined(DGUX) && defined(m88k)
319 # define mach_type_known
321 # if defined(_WIN32_WCE)
322 /* SH3, SH4, MIPS already defined for corresponding architectures */
323 # if defined(SH3) || defined(SH4)
333 # define mach_type_known
335 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
336 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
338 # define MSWIN32 /* or Win32s */
339 # define mach_type_known
343 # if defined(__DJGPP__)
346 # define DJGPP /* MSDOS running the DJGPP port of GCC */
348 # define mach_type_known
350 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
353 # define mach_type_known
355 # if defined(__MINGW32__)
358 # define mach_type_known
360 # if defined(__BORLANDC__)
363 # define mach_type_known
365 # if defined(_UTS) && !defined(mach_type_known)
368 # define mach_type_known
372 # define mach_type_known
374 # if defined(__embedded__) && defined(PPC)
377 # define mach_type_known
380 # if defined(__WATCOMC__) && defined(__386__)
382 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
383 # if defined(__OS2__)
386 # if defined(__WINDOWS_386__) || defined(__NT__)
393 # define mach_type_known
395 # if defined(__s390__) && defined(LINUX)
397 # define mach_type_known
399 # if defined(__GNU__)
400 # if defined(__i386__)
401 /* The Debian Hurd running on generic PC */
404 # define mach_type_known
408 /* Feel free to add more clauses here */
410 /* Or manually define the machine type here. A machine type is */
411 /* characterized by the architecture. Some */
412 /* machine types are further subdivided by OS. */
413 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
414 /* Note that SGI IRIX is treated identically to RISCOS. */
415 /* SYSV on an M68K actually means A/UX. */
416 /* The distinction in these cases is usually the stack starting address */
417 # ifndef mach_type_known
418 --> unknown machine type
420 /* Mapping is: M68K ==> Motorola 680X0 */
421 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
422 /* MACOS and AMIGA variants) */
423 /* I386 ==> Intel 386 */
424 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
425 /* FREEBSD, THREE86BSD, MSWIN32, */
426 /* BSDI,SUNOS5, NEXT, other variants) */
427 /* NS32K ==> Encore Multimax */
428 /* MIPS ==> R2000 or R3000 */
429 /* (RISCOS, ULTRIX variants) */
430 /* VAX ==> DEC VAX */
431 /* (BSD, ULTRIX variants) */
432 /* RS6000 ==> IBM RS/6000 AIX3.X */
433 /* RT ==> IBM PC/RT */
434 /* HP_PA ==> HP9000/700 & /800 */
436 /* SPARC ==> SPARC v7/v8/v9 */
437 /* (SUNOS4, SUNOS5, LINUX, */
438 /* DRSNX variants) */
439 /* ALPHA ==> DEC Alpha */
440 /* (OSF1 and LINUX variants) */
441 /* M88K ==> Motorola 88XX0 */
442 /* (CX_UX and DGUX) */
443 /* S370 ==> 370-like machine */
444 /* running Amdahl UTS4 */
445 /* or a 390 running LINUX */
446 /* ARM32 ==> Intel StrongARM */
447 /* IA64 ==> Intel IPF */
449 /* (LINUX and HPUX) */
450 /* SH ==> Hitachi SuperH */
451 /* (LINUX & MSWINCE) */
452 /* X86_64 ==> AMD x86-64 */
456 * For each architecture and OS, the following need to be defined:
458 * CPP_WORD_SZ is a simple integer constant representing the word size.
459 * in bits. We assume byte addressibility, where a byte has 8 bits.
460 * We also assume CPP_WORD_SZ is either 32 or 64.
461 * (We care about the length of pointers, not hardware
462 * bus widths. Thus a 64 bit processor with a C compiler that uses
463 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
465 * MACH_TYPE is a string representation of the machine type.
466 * OS_TYPE is analogous for the OS.
468 * ALIGNMENT is the largest N, such that
469 * all pointer are guaranteed to be aligned on N byte boundaries.
470 * defining it to be 1 will always work, but perform poorly.
472 * DATASTART is the beginning of the data segment.
473 * On some platforms SEARCH_FOR_DATA_START is defined.
474 * SEARCH_FOR_DATASTART will cause GC_data_start to
475 * be set to an address determined by accessing data backwards from _end
476 * until an unmapped page is found. DATASTART will be defined to be
478 * On UNIX-like systems, the collector will scan the area between DATASTART
479 * and DATAEND for root pointers.
481 * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
482 * RTH suggests gaining access to linker script synth'd values with
483 * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
485 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
488 * STACKBOTTOM is the cool end of the stack, which is usually the
489 * highest address in the stack.
490 * Under PCR or OS/2, we have other ways of finding thread stacks.
491 * For each machine, the following should:
492 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
493 * 2) define exactly one of
494 * STACKBOTTOM (should be defined to be an expression)
498 * If STACKBOTTOM is defined, then it's value will be used directly as the
499 * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined
500 * with a method appropriate for most Linux systems. Currently we look
501 * first for __libc_stack_end, and if that fails read it from /proc.
502 * If either of the last two macros are defined, then STACKBOTTOM is computed
503 * during collector startup using one of the following two heuristics:
504 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
505 * the next multiple of STACK_GRAN.
506 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
507 * in small steps (decrement if STACK_GROWS_UP), and read the value
508 * at each location. Remember the value when the first
509 * Segmentation violation or Bus error is signalled. Round that
510 * to the nearest plausible page boundary, and use that instead
513 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
514 * the value of environ is a pointer that can serve as STACKBOTTOM.
515 * I expect that HEURISTIC2 can be replaced by this approach, which
516 * interferes far less with debugging. However it has the disadvantage
517 * that it's confused by a putenv call before the collector is initialized.
518 * This could be dealt with by intercepting putenv ...
520 * If no expression for STACKBOTTOM can be found, and neither of the above
521 * heuristics are usable, the collector can still be used with all of the above
522 * undefined, provided one of the following is done:
523 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
524 * without reference to STACKBOTTOM. This is appropriate for use in
525 * conjunction with thread packages, since there will be multiple stacks.
526 * (Allocating thread stacks in the heap, and treating them as ordinary
527 * heap data objects is also possible as a last resort. However, this is
528 * likely to introduce significant amounts of excess storage retention
529 * unless the dead parts of the thread stacks are periodically cleared.)
530 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
531 * If the author of the client code controls the main program, this is
532 * easily accomplished by introducing a new main program, setting
533 * GC_stackbottom to the address of a local variable, and then calling
534 * the original main program. The new main program would read something
537 * # include "gc_private.h"
539 * main(argc, argv, envp)
541 * char **argv, **envp;
545 * GC_stackbottom = (ptr_t)(&dummy);
546 * return(real_main(argc, argv, envp));
550 * Each architecture may also define the style of virtual dirty bit
551 * implementation to be used:
552 * MPROTECT_VDB: Write protect the heap and catch faults.
553 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
555 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
556 * defined GC_register_dynamic_libraries() for the architecture.
558 * An architecture may define PREFETCH(x) to preload the cache with *x.
559 * This defaults to a no-op.
561 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
563 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
564 * clear the two words at GC_malloc-aligned address x. By default,
565 * word stores of 0 are used instead.
567 * HEAP_START may be defined as the initial address hint for mmap-based
571 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
572 * to push the relevant registers onto the stack. This generally makes
573 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
575 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
576 (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
577 # define HAVE_BUILTIN_UNWIND_INIT
580 # define STACK_GRAN 0x1000000
582 # define MACH_TYPE "M68K"
585 # define OS_TYPE "OPENBSD"
588 # define DATASTART ((ptr_t)(etext))
591 # define OS_TYPE "NETBSD"
594 # define DATASTART ((ptr_t)(etext))
597 # define OS_TYPE "LINUX"
598 # define STACKBOTTOM ((ptr_t)0xf0000000)
599 /* # define MPROTECT_VDB - Reported to not work 9/17/01 */
601 # define DYNAMIC_LOADING
602 # include <features.h>
603 # if defined(__GLIBC__)&& __GLIBC__>=2
604 # define SEARCH_FOR_DATA_START
606 extern char **__environ
;
607 # define DATASTART ((ptr_t)(&__environ))
608 /* hideous kludge: __environ is the first */
609 /* word in crt0.o, and delimits the start */
610 /* of the data segment, no matter which */
611 /* ld options were passed through. */
612 /* We could use _etext instead, but that */
613 /* would include .rodata, which may */
614 /* contain large read-only data tables */
615 /* that we'd rather not scan. */
616 # endif /* !GLIBC2 */
618 # define DATAEND (_end)
621 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
625 # define OS_TYPE "SUNOS4"
627 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
628 # define HEURISTIC1 /* differs */
629 # define DYNAMIC_LOADING
632 # define OS_TYPE "HP"
634 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
635 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
636 /* empirically determined. seems to work. */
638 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
641 # define OS_TYPE "SYSV"
643 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
645 +((word)etext & 0x1fff))
646 /* This only works for shared-text binaries with magic number 0413.
647 The other sorts of SysV binaries put the data at the end of the text,
648 in which case the default of etext would work. Unfortunately,
649 handling both would require having the magic-number available.
652 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
653 /* The stack starts at the top of memory, but */
654 /* 0x0 cannot be used as setjump_test complains */
655 /* that the stack direction is incorrect. Two */
656 /* bytes down from 0x0 should be safe enough. */
658 # include <sys/mmu.h>
659 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
662 # define OS_TYPE "AMIGA"
663 /* STACKBOTTOM and DATASTART handled specially */
665 # define DATAEND /* not needed */
666 # define GETPAGESIZE() 4096
672 # define OS_TYPE "MACOS"
673 /* see os_dep.c for details of global data segments. */
674 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
675 # define DATAEND /* not needed */
676 # define GETPAGESIZE() 4096
679 # define OS_TYPE "NEXT"
680 # define DATASTART ((ptr_t) get_etext())
681 # define STACKBOTTOM ((ptr_t) 0x4000000)
682 # define DATAEND /* not needed */
687 # define MACH_TYPE "POWERPC"
689 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
693 # define OS_TYPE "MACOS"
694 /* see os_dep.c for details of global data segments. */
695 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
696 # define DATAEND /* not needed */
699 # define ALIGNMENT 4 /* Guess. Can someone verify? */
700 /* This was 2, but that didn't sound right. */
701 # define OS_TYPE "LINUX"
703 # define DYNAMIC_LOADING
705 # define STACK_GRAN 0x10000000
706 /* Stack usually starts at 0x80000000 */
707 # define SEARCH_FOR_DATA_START
709 # define DATAEND (_end)
712 /* There are reasons to suspect this may not be reliable. */
714 # define OS_TYPE "MACOSX"
715 # define DATASTART ((ptr_t) get_etext())
716 # define STACKBOTTOM ((ptr_t) 0xc0000000)
717 # define DATAEND /* not needed */
718 # define MPROTECT_VDB
720 # define GETPAGESIZE() getpagesize()
724 # define OS_TYPE "NETBSD"
727 # define DATASTART GC_data_start
728 # define DYNAMIC_LOADING
732 # define OS_TYPE "NOSYS"
733 extern void __end
[], __dso_handle
[];
734 # define DATASTART (__dso_handle) /* OK, that's ugly. */
735 # define DATAEND (__end)
736 /* Stack starts at 0xE0000000 for the simulator. */
738 # define STACK_GRAN 0x10000000
744 # define MACH_TYPE "VAX"
745 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
747 # define DATASTART ((ptr_t)(etext))
749 # define OS_TYPE "BSD"
751 /* HEURISTIC2 may be OK, but it's hard to test. */
754 # define OS_TYPE "ULTRIX"
755 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
760 # define MACH_TYPE "RT"
762 # define DATASTART ((ptr_t) 0x10000000)
763 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
767 # define MACH_TYPE "SPARC"
768 # if defined(__arch64__) || defined(__sparcv9)
770 # define CPP_WORDSZ 64
771 # define ELF_CLASS ELFCLASS64
773 # define ALIGNMENT 4 /* Required by hardware */
774 # define CPP_WORDSZ 32
776 # define ALIGN_DOUBLE
778 # define OS_TYPE "SUNOS5"
781 extern char * GC_SysVGetDataStart();
782 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
783 # define DATAEND (_end)
784 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
786 /* Otherwise we now use calloc. Mmap may result in the */
787 /* heap interleaved with thread stacks, which can result in */
788 /* excessive blacklisting. Sbrk is unusable since it */
789 /* doesn't interact correctly with the system malloc. */
792 # define HEAP_START (ptr_t)0x40000000
794 # define HEAP_START DATAEND
797 /* HEURISTIC1 reportedly no longer works under 2.7. */
798 /* HEURISTIC2 probably works, but this appears to be preferable. */
799 /* Apparently USRSTACK is defined to be USERLIMIT, but in some */
800 /* installations that's undefined. We work around this with a */
802 # include <sys/vmparam.h>
804 /* This should work everywhere, but doesn't. */
805 # define STACKBOTTOM USRSTACK
810 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
811 /* getpagesize() appeared to be missing from at least one */
812 /* Solaris 5.4 installation. Weird. */
813 # define DYNAMIC_LOADING
816 # define OS_TYPE "SUNOS4"
817 /* [If you have a weak stomach, don't read this.] */
818 /* We would like to use: */
819 /* # define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
820 /* This fails occasionally, due to an ancient, but very */
821 /* persistent ld bug. etext is set 32 bytes too high. */
822 /* We instead read the text segment size from the a.out */
823 /* header, which happens to be mapped into our address space */
824 /* at the start of the text segment. The detective work here */
825 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
826 /* Serpette of INRIA. */
827 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
828 # define TEXTSTART 0x2000
829 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
830 # define MPROTECT_VDB
832 # define DYNAMIC_LOADING
835 # define OS_TYPE "DRSNX"
836 extern char * GC_SysVGetDataStart();
838 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
839 # define MPROTECT_VDB
840 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
841 # define DYNAMIC_LOADING
844 # define OS_TYPE "LINUX"
846 # define DYNAMIC_LOADING
848 Linux Sparc
/a
.out
not supported
852 # define DATAEND (_end)
855 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, _etext)
856 /* libc_stack_end is not set reliably for sparc64 */
857 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
859 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
860 # define LINUX_STACKBOTTOM
864 # define OS_TYPE "OPENBSD"
865 # define STACKBOTTOM ((ptr_t) 0xf8000000)
867 # define DATASTART ((ptr_t)(etext))
870 # define OS_TYPE "NETBSD"
873 # define DATASTART GC_data_start
874 # define DYNAMIC_LOADING
877 # define DATASTART ((ptr_t)(etext))
883 # define MACH_TYPE "I386"
884 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
885 /* except Borland. The -a4 option fixes */
887 /* Ivan Demakov: For Watcom the option is -zp4. */
888 # ifndef SMALL_CONFIG
889 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
890 /* improvement on Pentiums. */
892 # ifdef HAVE_BUILTIN_UNWIND_INIT
893 # define USE_GENERIC_PUSH_REGS
896 # define OS_TYPE "SEQUENT"
898 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
899 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
902 # define OS_TYPE "BEOS"
904 # define GETPAGESIZE() B_PAGE_SIZE
906 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
909 # define OS_TYPE "SUNOS5"
910 extern int _etext
[], _end
[];
911 extern char * GC_SysVGetDataStart();
912 # define DATASTART GC_SysVGetDataStart(0x1000, _etext)
913 # define DATAEND (_end)
914 /* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
915 /* but reportedly breaks under 2.8. It appears that the stack */
916 /* base is a property of the executable, so this should not break */
917 /* old executables. */
918 /* HEURISTIC2 probably works, but this appears to be preferable. */
920 # define STACKBOTTOM USRSTACK
921 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
922 /* It appears to be fixed in 2.8 and 2.9. */
923 # ifdef SOLARIS25_PROC_VDB_BUG_FIXED
926 # define DYNAMIC_LOADING
927 # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
929 /* Otherwise we now use calloc. Mmap may result in the */
930 /* heap interleaved with thread stacks, which can result in */
931 /* excessive blacklisting. Sbrk is unusable since it */
932 /* doesn't interact correctly with the system malloc. */
935 # define HEAP_START (ptr_t)0x40000000
937 # define HEAP_START DATAEND
941 # define OS_TYPE "SCO"
943 # define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
945 +((word)etext & 0xfff))
946 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
949 # define OS_TYPE "SCO_ELF"
951 # define DATASTART ((ptr_t)(etext))
952 # define STACKBOTTOM ((ptr_t) 0x08048000)
953 # define DYNAMIC_LOADING
954 # define ELF_CLASS ELFCLASS32
957 # define OS_TYPE "DGUX"
958 extern int _etext
, _end
;
959 extern char * GC_SysVGetDataStart();
960 # define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
961 # define DATAEND (&_end)
962 # define STACK_GROWS_DOWN
965 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
966 # define DYNAMIC_LOADING
969 # endif /* USE_MMAP */
970 # define MAP_FAILED (void *) -1
972 # define HEAP_START (ptr_t)0x40000000
973 # else /* USE_MMAP */
974 # define HEAP_START DATAEND
975 # endif /* USE_MMAP */
980 /* The Intel compiler doesn't like inline assembly */
981 # define USE_GENERIC_PUSH_REGS
983 # define OS_TYPE "LINUX"
984 # define LINUX_STACKBOTTOM
988 # define STACK_GRAN 0x10000000
989 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
990 /* different kernel configurations. In particular, systems */
991 /* with 2GB physical memory will usually move the user */
992 /* address space limit, and hence initial SP to 0x80000000. */
994 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
995 # define MPROTECT_VDB
997 /* We seem to get random errors in incremental mode, */
998 /* possibly because Linux threads is itself a malloc client */
999 /* and can't deal with the signals. */
1001 # define HEAP_START 0x1000
1002 /* This encourages mmap to give us low addresses, */
1003 /* thus allowing the heap to grow to ~3GB */
1005 # define DYNAMIC_LOADING
1006 # ifdef UNDEFINED /* includes ro data */
1007 extern int _etext
[];
1008 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1010 # include <features.h>
1011 # if defined(__GLIBC__) && __GLIBC__ >= 2
1012 # define SEARCH_FOR_DATA_START
1014 extern char **__environ
;
1015 # define DATASTART ((ptr_t)(&__environ))
1016 /* hideous kludge: __environ is the first */
1017 /* word in crt0.o, and delimits the start */
1018 /* of the data segment, no matter which */
1019 /* ld options were passed through. */
1020 /* We could use _etext instead, but that */
1021 /* would include .rodata, which may */
1022 /* contain large read-only data tables */
1023 /* that we'd rather not scan. */
1026 # define DATAEND (_end)
1029 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1031 # ifdef USE_I686_PREFETCH
1032 # define PREFETCH(x) \
1033 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
1034 /* Empirically prefetcht0 is much more effective at reducing */
1035 /* cache miss stalls for the targetted load instructions. But it */
1036 /* seems to interfere enough with other cache traffic that the net */
1037 /* result is worse than prefetchnta. */
1039 /* Using prefetches for write seems to have a slight negative */
1040 /* impact on performance, at least for a PIII/500. */
1041 # define PREFETCH_FOR_WRITE(x) \
1042 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
1045 # ifdef USE_3DNOW_PREFETCH
1046 # define PREFETCH(x) \
1047 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1048 # define PREFETCH_FOR_WRITE(x) \
1049 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1053 # define OS_TYPE "CYGWIN32"
1054 extern int _data_start__
[];
1055 extern int _data_end__
[];
1056 extern int _bss_start__
[];
1057 extern int _bss_end__
[];
1058 /* For binutils 2.9.1, we have */
1059 /* DATASTART = _data_start__ */
1060 /* DATAEND = _bss_end__ */
1061 /* whereas for some earlier versions it was */
1062 /* DATASTART = _bss_start__ */
1063 /* DATAEND = _data_end__ */
1064 /* To get it right for both, we take the */
1065 /* minumum/maximum of the two. */
1066 # define MAX(x,y) ((x) > (y) ? (x) : (y))
1067 # define MIN(x,y) ((x) < (y) ? (x) : (y))
1068 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
1069 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
1071 # define STACK_GRAN 0x10000
1075 # define OS_TYPE "OS2"
1076 /* STACKBOTTOM and DATASTART are handled specially in */
1077 /* os_dep.c. OS2 actually has the right */
1079 # define DATAEND /* not needed */
1080 # define USE_GENERIC_PUSH_REGS
1083 # define OS_TYPE "MSWIN32"
1084 /* STACKBOTTOM and DATASTART are handled specially in */
1086 # ifndef __WATCOMC__
1087 # define MPROTECT_VDB
1089 # define DATAEND /* not needed */
1092 # define OS_TYPE "MSWINCE"
1093 # define DATAEND /* not needed */
1096 # define OS_TYPE "DJGPP"
1097 # include "stubinfo.h"
1100 extern int __djgpp_stack_limit
;
1101 # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1102 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1104 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1105 /* This may not be right. */
1108 # define OS_TYPE "OPENBSD"
1111 # define OS_TYPE "FREEBSD"
1112 # ifndef GC_FREEBSD_THREADS
1113 # define MPROTECT_VDB
1115 # define SIG_SUSPEND SIGUSR1
1116 # define SIG_THR_RESTART SIGUSR2
1117 # define FREEBSD_STACKBOTTOM
1119 # define DYNAMIC_LOADING
1121 extern char etext
[];
1122 # define DATASTART ((ptr_t)(etext))
1125 # define OS_TYPE "NETBSD"
1127 # define DYNAMIC_LOADING
1131 # define OS_TYPE "THREE86BSD"
1134 # define OS_TYPE "BSDI"
1136 # if defined(OPENBSD) || defined(NETBSD) \
1137 || defined(THREE86BSD) || defined(BSDI)
1139 extern char etext
[];
1140 # define DATASTART ((ptr_t)(etext))
1143 # define OS_TYPE "NEXT"
1144 # define DATASTART ((ptr_t) get_etext())
1145 # define STACKBOTTOM ((ptr_t)0xc0000000)
1146 # define DATAEND /* not needed */
1149 # define OS_TYPE "DOS4GW"
1150 extern long __nullarea
;
1152 extern char *_STACKTOP
;
1153 /* Depending on calling conventions Watcom C either precedes
1154 or does not precedes with undescore names of C-variables.
1155 Make sure startup code variables always have the same names. */
1156 #pragma aux __nullarea "*";
1157 #pragma aux _end "*";
1158 # define STACKBOTTOM ((ptr_t) _STACKTOP)
1159 /* confused? me too. */
1160 # define DATASTART ((ptr_t) &__nullarea)
1161 # define DATAEND ((ptr_t) &_end)
1164 # define OS_TYPE "HURD"
1165 # define STACK_GROWS_DOWN
1167 extern int __data_start
[];
1168 # define DATASTART ( (ptr_t) (__data_start))
1170 # define DATAEND ( (ptr_t) (_end))
1171 /* # define MPROTECT_VDB Not quite working yet? */
1172 # define DYNAMIC_LOADING
1177 # define MACH_TYPE "NS32K"
1178 # define ALIGNMENT 4
1179 extern char **environ
;
1180 # define DATASTART ((ptr_t)(&environ))
1181 /* hideous kludge: environ is the first */
1182 /* word in crt0.o, and delimits the start */
1183 /* of the data segment, no matter which */
1184 /* ld options were passed through. */
1185 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1189 # define MACH_TYPE "MIPS"
1191 /* This was developed for a linuxce style platform. Probably */
1192 /* needs to be tweaked for workstation class machines. */
1193 # define OS_TYPE "LINUX"
1194 # define DYNAMIC_LOADING
1196 # define DATAEND (_end)
1197 extern int __data_start
[];
1198 # define DATASTART ((ptr_t)(__data_start))
1199 # define ALIGNMENT 4
1200 # define USE_GENERIC_PUSH_REGS
1201 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 4 || __GLIBC__ > 2
1202 # define LINUX_STACKBOTTOM
1204 # define STACKBOTTOM 0x80000000
1209 # if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1210 extern int _fdata
[], _end
[];
1211 # define DATASTART ((ptr_t)_fdata)
1212 # define DATAEND ((ptr_t)_end)
1213 # define CPP_WORDSZ _MIPS_SZPTR
1214 # define ALIGNMENT (_MIPS_SZPTR/8)
1216 extern int etext
[], edata
[], end
[];
1217 extern int _DYNAMIC_LINKING
[], _gp
[];
1218 # define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1219 + ((word)etext & 0xffff)))
1220 # define DATAEND (edata)
1221 # define DATASTART2 (_DYNAMIC_LINKING \
1222 ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1224 # define DATAEND2 (end)
1225 # define ALIGNMENT 4
1227 # define OS_TYPE "EWS4800"
1228 # define USE_GENERIC_PUSH_REGS 1
1232 # define DATASTART (ptr_t)0x10000000
1233 /* Could probably be slightly higher since */
1234 /* startup code allocates lots of stuff. */
1235 # define OS_TYPE "ULTRIX"
1236 # define ALIGNMENT 4
1240 # define DATASTART (ptr_t)0x10000000
1241 # define OS_TYPE "RISCOS"
1242 # define ALIGNMENT 4 /* Required by hardware */
1246 extern int _fdata
[];
1247 # define DATASTART ((ptr_t)(_fdata))
1249 # define HEAP_START (ptr_t)0x30000000
1251 # define HEAP_START DATASTART
1253 /* Lowest plausible heap address. */
1254 /* In the MMAP case, we map there. */
1255 /* In either case it is used to identify */
1256 /* heap sections so they're not */
1257 /* considered as roots. */
1258 # define OS_TYPE "IRIX5"
1259 # define MPROTECT_VDB
1261 # define CPP_WORDSZ _MIPS_SZPTR
1262 # define ALIGNMENT (_MIPS_SZPTR/8)
1263 # if CPP_WORDSZ != 64
1264 # define ALIGN_DOUBLE
1267 # define ALIGNMENT 4
1268 # define ALIGN_DOUBLE
1270 # define DYNAMIC_LOADING
1273 # define OS_TYPE "MSWINCE"
1274 # define ALIGNMENT 4
1275 # define DATAEND /* not needed */
1277 # if defined(NETBSD)
1278 /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
1279 /* should be handled at the top of the file. */
1280 # define ALIGNMENT 4
1281 # define OS_TYPE "NETBSD"
1283 # define USE_GENERIC_PUSH_REGS
1286 # define DATASTART GC_data_start
1287 # define NEED_FIND_LIMIT
1288 # define DYNAMIC_LOADING
1290 # define DATASTART ((ptr_t) 0x10000000)
1291 # define STACKBOTTOM ((ptr_t) 0x7ffff000)
1297 # define MACH_TYPE "RS6000"
1299 # define ALIGNMENT 8
1300 # define CPP_WORDSZ 64
1301 # define STACKBOTTOM 0x1000000000000000
1303 # define ALIGNMENT 4
1304 # define CPP_WORDSZ 32
1305 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1307 extern int _data
[], _end
[];
1308 # define DATASTART ((ptr_t)((ulong)_data))
1309 # define DATAEND ((ptr_t)((ulong)_end))
1311 # define USE_GENERIC_PUSH_REGS
1312 # define DYNAMIC_LOADING
1313 /* For really old versions of AIX, this may have to be removed. */
1317 # define MACH_TYPE "HP_PA"
1319 # define CPP_WORDSZ 64
1320 # define ALIGNMENT 8
1322 # define CPP_WORDSZ 32
1323 # define ALIGNMENT 4
1324 # define ALIGN_DOUBLE
1326 # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1327 # ifndef LINUX /* For now. */
1328 # define MPROTECT_VDB
1331 # define GENERIC_COMPARE_AND_SWAP
1332 /* No compare-and-swap instruction. Use pthread mutexes */
1333 /* when we absolutely have to. */
1334 # ifdef PARALLEL_MARK
1335 # define USE_MARK_BYTES
1336 /* Minimize compare-and-swap usage. */
1339 # define STACK_GROWS_UP
1341 # define OS_TYPE "HPUX"
1342 extern int __data_start
[];
1343 # define DATASTART ((ptr_t)(__data_start))
1345 /* The following appears to work for 7xx systems running HP/UX */
1346 /* 9.xx Furthermore, it might result in much faster */
1347 /* collections than HEURISTIC2, which may involve scanning */
1348 /* segments that directly precede the stack. It is not the */
1349 /* default, since it may not work on older machine/OS */
1350 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1352 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1354 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1355 /* to this. Note that the GC must be initialized before the */
1356 /* first putenv call. */
1357 extern char ** environ
;
1358 # define STACKBOTTOM ((ptr_t)environ)
1360 # define DYNAMIC_LOADING
1361 # include <unistd.h>
1362 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1364 # define PREFETCH(x) { \
1365 register long addr = (long)(x); \
1366 (void) _asm ("LDW", 0, 0, addr, 0); \
1371 # define OS_TYPE "LINUX"
1372 # define LINUX_STACKBOTTOM
1373 # define DYNAMIC_LOADING
1374 # define SEARCH_FOR_DATA_START
1376 # define DATAEND (&_end)
1381 # define MACH_TYPE "ALPHA"
1382 # define ALIGNMENT 8
1383 # define CPP_WORDSZ 64
1385 # define USE_GENERIC_PUSH_REGS
1386 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1387 /* fp registers in some cases when the target is a 21264. The assembly */
1388 /* code doesn't handle that yet, and version dependencies make that a */
1389 /* bit tricky. Do the easy thing for now. */
1392 # define OS_TYPE "NETBSD"
1394 # define DATASTART GC_data_start
1395 # define ELFCLASS32 32
1396 # define ELFCLASS64 64
1397 # define ELF_CLASS ELFCLASS64
1398 # define DYNAMIC_LOADING
1401 # define OS_TYPE "OPENBSD"
1403 # ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */
1404 # define DATASTART GC_data_start
1405 # define ELFCLASS32 32
1406 # define ELFCLASS64 64
1407 # define ELF_CLASS ELFCLASS64
1408 # else /* ECOFF, until OpenBSD/Alpha 2.7 */
1409 # define DATASTART ((ptr_t) 0x140000000)
1413 # define OS_TYPE "FREEBSD"
1414 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1415 # define SIG_SUSPEND SIGUSR1
1416 # define SIG_THR_RESTART SIGUSR2
1417 # define FREEBSD_STACKBOTTOM
1419 # define DYNAMIC_LOADING
1421 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1422 extern char etext
[];
1423 extern char edata
[];
1425 # define NEED_FIND_LIMIT
1426 # define DATASTART ((ptr_t)(&etext))
1427 # define DATAEND (GC_find_limit (DATASTART, TRUE))
1428 # define DATASTART2 ((ptr_t)(&edata))
1429 # define DATAEND2 ((ptr_t)(&end))
1432 # define OS_TYPE "OSF1"
1433 # define DATASTART ((ptr_t) 0x140000000)
1435 # define DATAEND ((ptr_t) &_end)
1436 extern char ** environ
;
1437 /* round up from the value of environ to the nearest page boundary */
1438 /* Probably breaks if putenv is called before collector */
1439 /* initialization. */
1440 # define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1441 /* # define HEURISTIC2 */
1442 /* Normally HEURISTIC2 is too conervative, since */
1443 /* the text segment immediately follows the stack. */
1444 /* Hence we give an upper pound. */
1445 /* This is currently unused, since we disabled HEURISTIC2 */
1446 extern int __start
[];
1447 # define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1448 # ifndef GC_OSF1_THREADS
1449 /* Unresolved signal issues with threads. */
1450 # define MPROTECT_VDB
1452 # define DYNAMIC_LOADING
1455 # define OS_TYPE "LINUX"
1456 # define STACKBOTTOM ((ptr_t) 0x120000000)
1458 # define SEARCH_FOR_DATA_START
1459 # define DYNAMIC_LOADING
1461 # define DATASTART ((ptr_t) 0x140000000)
1464 # define DATAEND (_end)
1465 # define MPROTECT_VDB
1466 /* Has only been superficially tested. May not */
1467 /* work on all versions. */
1472 # define MACH_TYPE "IA64"
1473 # define USE_GENERIC_PUSH_REGS
1474 /* We need to get preserved registers in addition to register */
1475 /* windows. That's easiest to do with setjmp. */
1476 # ifdef PARALLEL_MARK
1477 # define USE_MARK_BYTES
1478 /* Compare-and-exchange is too expensive to use for */
1479 /* setting mark bits. */
1483 # define CPP_WORDSZ 32
1484 # define ALIGN_DOUBLE
1485 /* Requires 8 byte alignment for malloc */
1486 # define ALIGNMENT 4
1491 # define CPP_WORDSZ 64
1492 # define ALIGN_DOUBLE
1493 /* Requires 16 byte alignment for malloc */
1494 # define ALIGNMENT 8
1496 # define OS_TYPE "HPUX"
1497 extern int __data_start
[];
1498 # define DATASTART ((ptr_t)(__data_start))
1499 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1500 /* to this. Note that the GC must be initialized before the */
1501 /* first putenv call. */
1502 extern char ** environ
;
1503 # define STACKBOTTOM ((ptr_t)environ)
1504 # define DYNAMIC_LOADING
1505 # include <unistd.h>
1506 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1507 /* The following was empirically determined, and is probably */
1508 /* not very robust. */
1509 /* Note that the backing store base seems to be at a nice */
1510 /* address minus one page. */
1511 # define BACKING_STORE_DISPLACEMENT 0x1000000
1512 # define BACKING_STORE_ALIGNMENT 0x1000
1513 # define BACKING_STORE_BASE \
1514 (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1515 & ~(BACKING_STORE_ALIGNMENT - 1))
1518 # define CPP_WORDSZ 64
1519 # define ALIGN_DOUBLE
1520 /* Requires 16 byte alignment for malloc */
1521 # define ALIGNMENT 8
1522 # define OS_TYPE "LINUX"
1523 /* The following works on NUE and older kernels: */
1524 /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */
1525 /* This does not work on NUE: */
1526 # define LINUX_STACKBOTTOM
1527 /* We also need the base address of the register stack */
1528 /* backing store. This is computed in */
1529 /* GC_linux_register_stack_base based on the following */
1531 # define BACKING_STORE_ALIGNMENT 0x100000
1532 # define BACKING_STORE_DISPLACEMENT 0x80000000
1533 extern char * GC_register_stackbottom
;
1534 # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1535 # define SEARCH_FOR_DATA_START
1537 # define DYNAMIC_LOADING
1539 /* In the Intel compiler environment, we seem to end up with */
1540 /* statically linked executables and an undefined reference */
1543 # define MPROTECT_VDB
1544 /* Requires Linux 2.3.47 or later. */
1546 # define DATAEND (_end)
1548 # define PREFETCH(x) \
1549 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1550 # define PREFETCH_FOR_WRITE(x) \
1551 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1552 # define CLEAR_DOUBLE(x) \
1553 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1559 # define MACH_TYPE "M88K"
1560 # define ALIGNMENT 4
1561 # define ALIGN_DOUBLE
1564 # define OS_TYPE "CX_UX"
1565 # define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1568 # define OS_TYPE "DGUX"
1569 extern char * GC_SysVGetDataStart();
1570 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, etext)
1572 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1576 # define MACH_TYPE "S370"
1577 # define ALIGNMENT 4 /* Required by hardware */
1578 # define USE_GENERIC_PUSH_REGS
1580 # define OS_TYPE "UTS4"
1582 extern int _etext
[];
1584 extern char * GC_SysVGetDataStart();
1585 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, _etext)
1586 # define DATAEND (_end)
1590 # define OS_TYPE "LINUX"
1592 # define DYNAMIC_LOADING
1593 extern int __data_start
[];
1594 # define DATASTART ((ptr_t)(__data_start))
1599 # define ALIGNMENT 4
1600 extern int _etext
[];
1601 # define DATASTART ((ptr_t)(_etext))
1606 # define CPP_WORDSZ 32
1607 # define MACH_TYPE "ARM32"
1608 # define ALIGNMENT 4
1610 # define OS_TYPE "NETBSD"
1612 extern char etext
[];
1613 # define DATASTART ((ptr_t)(etext))
1614 # define USE_GENERIC_PUSH_REGS
1617 # define OS_TYPE "LINUX"
1620 # define STACK_GRAN 0x10000000
1621 # define USE_GENERIC_PUSH_REGS
1623 # define DYNAMIC_LOADING
1624 # include <features.h>
1625 # if defined(__GLIBC__) && __GLIBC__ >= 2
1626 # define SEARCH_FOR_DATA_START
1628 extern char **__environ
;
1629 # define DATASTART ((ptr_t)(&__environ))
1630 /* hideous kludge: __environ is the first */
1631 /* word in crt0.o, and delimits the start */
1632 /* of the data segment, no matter which */
1633 /* ld options were passed through. */
1634 /* We could use _etext instead, but that */
1635 /* would include .rodata, which may */
1636 /* contain large read-only data tables */
1637 /* that we'd rather not scan. */
1640 # define DATAEND (_end)
1643 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1647 # define OS_TYPE "MSWINCE"
1648 # define DATAEND /* not needed */
1651 /* __data_start is usually defined in the target linker script. */
1652 extern int __data_start
[];
1653 # define DATASTART (ptr_t)(__data_start)
1654 # define USE_GENERIC_PUSH_REGS
1655 /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S */
1656 extern void *__stack_base__
;
1657 # define STACKBOTTOM ((ptr_t) (__stack_base__))
1662 # define MACH_TYPE "SH"
1663 # define ALIGNMENT 4
1665 # define OS_TYPE "MSWINCE"
1666 # define DATAEND /* not needed */
1669 # define OS_TYPE "LINUX"
1670 # define STACKBOTTOM ((ptr_t) 0x7c000000)
1671 # define USE_GENERIC_PUSH_REGS
1672 # define DYNAMIC_LOADING
1673 # define SEARCH_FOR_DATA_START
1675 # define DATAEND (_end)
1680 # define MACH_TYPE "SH4"
1681 # define OS_TYPE "MSWINCE"
1682 # define ALIGNMENT 4
1683 # define DATAEND /* not needed */
1687 # define MACH_TYPE "X86_64"
1688 # define ALIGNMENT 8
1689 # define CPP_WORDSZ 64
1690 # define CACHE_LINE_SIZE 64
1691 # define USE_GENERIC_PUSH_REGS
1693 # define OS_TYPE "LINUX"
1694 # define LINUX_STACKBOTTOM
1695 # if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1696 # define MPROTECT_VDB
1698 /* We seem to get random errors in incremental mode, */
1699 /* possibly because Linux threads is itself a malloc client */
1700 /* and can't deal with the signals. */
1703 # define DYNAMIC_LOADING
1704 # ifdef UNDEFINED /* includes ro data */
1705 extern int _etext
[];
1706 # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1708 # include <features.h>
1709 # define SEARCH_FOR_DATA_START
1711 # define DATAEND (_end)
1714 # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1716 # define PREFETCH(x) \
1717 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
1718 # define PREFETCH_FOR_WRITE(x) \
1719 __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
1723 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1724 /* Rld appears to allocate some memory with its own allocator, and */
1725 /* some through malloc, which might be redirected. To make this */
1726 /* work with collectable memory, we have to scan memory allocated */
1727 /* by rld's internal malloc. */
1728 # define USE_PROC_FOR_LIBRARIES
1731 # ifndef STACK_GROWS_UP
1732 # define STACK_GROWS_DOWN
1736 # define CPP_WORDSZ 32
1745 # define DATAEND (end)
1748 # if defined(SVR4) && !defined(GETPAGESIZE)
1749 # include <unistd.h>
1750 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1753 # ifndef GETPAGESIZE
1754 # if defined(SUNOS5) || defined(IRIX5)
1755 # include <unistd.h>
1757 # define GETPAGESIZE() getpagesize()
1760 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1761 /* OS has SVR4 generic features. Probably others also qualify. */
1765 # if defined(SUNOS5) || defined(DRSNX)
1766 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1769 /* OS has SUNOS5 style signal handlers. */
1777 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1778 || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) || defined(DGUX) \
1779 || defined(BSD) || defined(AIX) || defined(MACOSX) || defined(OSF1)
1780 # define UNIX_LIKE /* Basic Unix-like system calls work. */
1783 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1788 # undef DYNAMIC_LOADING
1793 # undef MPROTECT_VDB
1798 /* Postponed for now. */
1800 # undef MPROTECT_VDB
1803 # ifdef SMALL_CONFIG
1804 /* Presumably not worth the space it takes. */
1806 # undef MPROTECT_VDB
1810 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1813 # ifdef PARALLEL_MARK
1814 # undef MPROTECT_VDB /* For now. */
1817 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1818 # define DEFAULT_VDB
1822 # define PREFETCH(x)
1823 # define NO_PREFETCH
1826 # ifndef PREFETCH_FOR_WRITE
1827 # define PREFETCH_FOR_WRITE(x)
1828 # define NO_PREFETCH_FOR_WRITE
1831 # ifndef CACHE_LINE_SIZE
1832 # define CACHE_LINE_SIZE 32 /* Wild guess */
1835 # if defined(SEARCH_FOR_DATA_START) && defined(GC_PRIVATE_H)
1836 extern ptr_t GC_data_start
;
1837 # define DATASTART GC_data_start
1840 # ifndef CLEAR_DOUBLE
1841 # define CLEAR_DOUBLE(x) \
1842 ((word*)x)[0] = 0; \
1844 # endif /* CLEAR_DOUBLE */
1846 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1847 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1848 # define GC_SOLARIS_THREADS
1851 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1852 --> inconsistent configuration
1854 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1855 --> inconsistent configuration
1857 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1858 --> inconsistent configuration
1860 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1861 --> inconsistent configuration
1863 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
1864 --> inconsistent configuration
1867 # if defined(PCR) || defined(SRC_M3) || \
1868 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1869 defined(GC_PTHREADS)
1873 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1874 || defined(LINT) || defined(MSWINCE) || defined(ARM32) \
1875 || (defined(I386) && defined(__LCC__))
1876 /* Use setjmp based hack to mark from callee-save registers. */
1877 /* The define should move to the individual platform */
1879 # define USE_GENERIC_PUSH_REGS
1883 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1884 /* include assembly code to do it well. */
1887 /* Can we save call chain in objects for debugging? */
1888 /* SET NFRAMES (# of saved frames) and NARGS (#of args for each frame) */
1889 /* to reasonable values for the platform. */
1890 /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified at */
1891 /* build time, though we feel free to adjust it slightly. */
1892 /* Define NEED_CALLINFO if we either save the call stack or */
1893 /* GC_ADD_CALLER is defined. */
1895 # include <features.h>
1896 # if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2
1897 # define HAVE_BUILTIN_BACKTRACE
1902 # define CAN_SAVE_CALL_STACKS
1903 # define CAN_SAVE_CALL_ARGS
1905 #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1906 /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
1907 /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
1908 # define CAN_SAVE_CALL_STACKS
1909 # define CAN_SAVE_CALL_ARGS
1911 #if defined(HAVE_BUILTIN_BACKTRACE) && !defined(CAN_SAVE_CALL_STACKS)
1912 # define CAN_SAVE_CALL_STACKS
1915 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1916 && defined(CAN_SAVE_CALL_STACKS)
1917 # define SAVE_CALL_CHAIN
1919 # ifdef SAVE_CALL_CHAIN
1920 # if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
1921 # define NARGS SAVE_CALL_NARGS
1923 # define NARGS 0 /* Number of arguments to save for each call. */
1926 # ifdef SAVE_CALL_CHAIN
1927 # ifndef SAVE_CALL_COUNT
1928 # define NFRAMES 6 /* Number of frames to save. Even for */
1929 /* alignment reasons. */
1931 # define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
1933 # define NEED_CALLINFO
1934 # endif /* SAVE_CALL_CHAIN */
1935 # ifdef GC_ADD_CALLER
1938 # define NEED_CALLINFO
1941 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
1942 # define DBG_HDRS_ALL
1946 /* This relies on some type definitions from gc_priv.h, from */
1947 /* where it's normally included. */
1949 /* How to get heap memory from the OS: */
1950 /* Note that sbrk()-like allocation is preferred, since it */
1951 /* usually makes it possible to merge consecutively allocated */
1952 /* chunks. It also avoids unintented recursion with */
1953 /* -DREDIRECT_MALLOC. */
1954 /* GET_MEM() returns a HLKSIZE aligned chunk. */
1955 /* 0 is taken to mean failure. */
1956 /* In the case os USE_MMAP, the argument must also be a */
1957 /* physical page size. */
1958 /* GET_MEM is currently not assumed to retrieve 0 filled space, */
1959 /* though we should perhaps take advantage of the case in which */
1961 struct hblk
; /* See gc_priv.h. */
1963 char * real_malloc();
1964 # define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
1968 void * os2_alloc(size_t bytes
);
1969 # define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
1973 # if defined(NEXT) || defined(MACOSX) || defined(DOS4GW) || \
1974 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
1975 (defined(SUNOS5) && !defined(USE_MMAP))
1976 # define GET_MEM(bytes) HBLKPTR((size_t) \
1977 calloc(1, (size_t)bytes + GC_page_size) \
1981 # ifdef GC_PRIVATE_H
1982 extern ptr_t
GC_win32_get_mem();
1984 # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
1987 # if defined(USE_TEMPORARY_MEMORY)
1988 extern Ptr
GC_MacTemporaryNewPtr(size_t size
,
1989 Boolean clearMemory
);
1990 # define GET_MEM(bytes) HBLKPTR( \
1991 GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
1994 # define GET_MEM(bytes) HBLKPTR( \
1995 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
1999 # ifdef GC_PRIVATE_H
2000 extern ptr_t
GC_wince_get_mem();
2002 # define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2004 # if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2005 extern void *GC_amiga_get_mem(size_t size
);
2006 define
GET_MEM(bytes
) HBLKPTR((size_t) \
2007 GC_amiga_get_mem((size_t)bytes
+ GC_page_size
) \
2010 # ifdef GC_PRIVATE_H
2011 extern ptr_t
GC_unix_get_mem();
2013 # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2022 #endif /* GC_PRIVATE_H */
2024 # endif /* GCCONFIG_H */