📄 gcconfig.h
字号:
# define mach_type_known# endif# if defined(__pj__)# error PicoJava no longer supported /* The implementation had problems, and I haven't heard of users */ /* in ages. If you want it resurrected, let me know. */# endif# if defined(__embedded__) && defined(PPC)# define POWERPC# define NOSYS# define mach_type_known# endif/* Ivan Demakov */# if defined(__WATCOMC__) && defined(__386__)# define I386# if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)# if defined(__OS2__)# define OS2# else# if defined(__WINDOWS_386__) || defined(__NT__)# define MSWIN32# else# define DOS4GW# endif# endif# endif# define mach_type_known# endif# if defined(__s390__) && defined(LINUX)# define S390# define mach_type_known# endif# if defined(__GNU__)# if defined(__i386__)/* The Debian Hurd running on generic PC */ # define HURD# define I386# define mach_type_known# endif # endif# if defined(__TANDEM) /* Nonstop S-series */ /* FIXME: Should recognize Integrity series? */# define MIPS# define NONSTOP# define mach_type_known# endif/* Feel free to add more clauses here *//* Or manually define the machine type here. A machine type is *//* characterized by the architecture. Some *//* machine types are further subdivided by OS. *//* Macros such as LINUX, FREEBSD, etc. distinguish them. *//* SYSV on an M68K actually means A/UX. *//* The distinction in these cases is usually the stack starting address */# ifndef mach_type_known# error "The collector has not been ported to this machine/OS combination."# endif /* Mapping is: M68K ==> Motorola 680X0 */ /* (NEXT, and SYSV (A/UX), */ /* MACOS and AMIGA variants) */ /* I386 ==> Intel 386 */ /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */ /* FREEBSD, THREE86BSD, MSWIN32, */ /* BSDI,SOLARIS, NEXT, other variants) */ /* NS32K ==> Encore Multimax */ /* MIPS ==> R2000 through R14K */ /* (many variants) */ /* VAX ==> DEC VAX */ /* (BSD, ULTRIX variants) */ /* HP_PA ==> HP9000/700 & /800 */ /* HP/UX, LINUX */ /* SPARC ==> SPARC v7/v8/v9 */ /* (SOLARIS, LINUX, DRSNX variants) */ /* ALPHA ==> DEC Alpha */ /* (OSF1 and LINUX variants) */ /* M88K ==> Motorola 88XX0 */ /* (CX_UX and DGUX) */ /* S370 ==> 370-like machine */ /* running Amdahl UTS4 */ /* S390 ==> 390-like machine */ /* running LINUX */ /* ARM32 ==> Intel StrongARM */ /* IA64 ==> Intel IPF */ /* (e.g. Itanium) */ /* (LINUX and HPUX) */ /* SH ==> Hitachi SuperH */ /* (LINUX & MSWINCE) */ /* X86_64 ==> AMD x86-64 */ /* POWERPC ==> IBM/Apple PowerPC */ /* (MACOS(<=9),DARWIN(incl.MACOSX),*/ /* LINUX, NETBSD, AIX, NOSYS */ /* variants) */ /* Handles 32 and 64-bit variants. */ /* CRIS ==> Axis Etrax */ /* M32R ==> Renesas M32R *//* * For each architecture and OS, the following need to be defined: * * CPP_WORDSZ is a simple integer constant representing the word size. * in bits. We assume byte addressibility, where a byte has 8 bits. * We also assume CPP_WORDSZ is either 32 or 64. * (We care about the length of pointers, not hardware * bus widths. Thus a 64 bit processor with a C compiler that uses * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.) * * MACH_TYPE is a string representation of the machine type. * OS_TYPE is analogous for the OS. * * ALIGNMENT is the largest N, such that * all pointer are guaranteed to be aligned on N byte boundaries. * defining it to be 1 will always work, but perform poorly. * * DATASTART is the beginning of the data segment. * On some platforms SEARCH_FOR_DATA_START is defined. * SEARCH_FOR_DATASTART will cause GC_data_start to * be set to an address determined by accessing data backwards from _end * until an unmapped page is found. DATASTART will be defined to be * GC_data_start. * On UNIX-like systems, the collector will scan the area between DATASTART * and DATAEND for root pointers. * * DATAEND, if not `end' where `end' is defined as ``extern int end[];''. * RTH suggests gaining access to linker script synth'd values with * this idiom instead of `&end' where `end' is defined as ``extern int end;'' . * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g., * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-* * without any special options. * * STACKBOTTOM is the cool end of the stack, which is usually the * highest address in the stack. * Under PCR or OS/2, we have other ways of finding thread stacks. * For each machine, the following should: * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and * 2) define exactly one of * STACKBOTTOM (should be defined to be an expression) * LINUX_STACKBOTTOM * HEURISTIC1 * HEURISTIC2 * If STACKBOTTOM is defined, then it's value will be used directly as the * stack base. If LINUX_STACKBOTTOM is defined, then it will be determined * with a method appropriate for most Linux systems. Currently we look * first for __libc_stack_end, and if that fails read it from /proc. * If either of the last two macros are defined, then STACKBOTTOM is computed * during collector startup using one of the following two heuristics: * HEURISTIC1: Take an address inside GC_init's frame, and round it up to * the next multiple of STACK_GRAN. * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly * in small steps (decrement if STACK_GROWS_UP), and read the value * at each location. Remember the value when the first * Segmentation violation or Bus error is signalled. Round that * to the nearest plausible page boundary, and use that instead * of STACKBOTTOM. * * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines, * the value of environ is a pointer that can serve as STACKBOTTOM. * I expect that HEURISTIC2 can be replaced by this approach, which * interferes far less with debugging. However it has the disadvantage * that it's confused by a putenv call before the collector is initialized. * This could be dealt with by intercepting putenv ... * * If no expression for STACKBOTTOM can be found, and neither of the above * heuristics are usable, the collector can still be used with all of the above * undefined, provided one of the following is done: * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s) * without reference to STACKBOTTOM. This is appropriate for use in * conjunction with thread packages, since there will be multiple stacks. * (Allocating thread stacks in the heap, and treating them as ordinary * heap data objects is also possible as a last resort. However, this is * likely to introduce significant amounts of excess storage retention * unless the dead parts of the thread stacks are periodically cleared.) * 2) Client code may set GC_stackbottom before calling any GC_ routines. * If the author of the client code controls the main program, this is * easily accomplished by introducing a new main program, setting * GC_stackbottom to the address of a local variable, and then calling * the original main program. The new main program would read something * like: * * # include "gc_private.h" * * main(argc, argv, envp) * int argc; * char **argv, **envp; * { * int dummy; * * GC_stackbottom = (ptr_t)(&dummy); * return(real_main(argc, argv, envp)); * } * * * Each architecture may also define the style of virtual dirty bit * implementation to be used: * MPROTECT_VDB: Write protect the heap and catch faults. * GWW_VDB: Use win32 GetWriteWatch primitive. * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits. * * The first and second one may be combined, in which case a runtime * selection will be made, based on GetWriteWatch availability. * * An architecture may define DYNAMIC_LOADING if dynamic_load.c * defined GC_register_dynamic_libraries() for the architecture. * * An architecture may define PREFETCH(x) to preload the cache with *x. * This defaults to a no-op. * * PREFETCH_FOR_WRITE(x) is used if *x is about to be written. * * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to * clear the two words at GC_malloc-aligned address x. By default, * word stores of 0 are used instead. * * HEAP_START may be defined as the initial address hint for mmap-based * allocation. *//* If we are using a recent version of gcc, we can use __builtin_unwind_init() * to push the relevant registers onto the stack. */# if defined(__GNUC__) && ((__GNUC__ >= 3) || \ (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \ && !defined(__INTEL_COMPILER) && !defined(__PATHCC__)# define HAVE_BUILTIN_UNWIND_INIT# endif# define STACK_GRAN 0x1000000# ifdef M68K# define MACH_TYPE "M68K"# define ALIGNMENT 2# ifdef OPENBSD# define OS_TYPE "OPENBSD"# define HEURISTIC2# ifdef __ELF__# define DATASTART GC_data_start# define DYNAMIC_LOADING# else extern char etext[];# define DATASTART ((ptr_t)(etext))# endif# endif# ifdef NETBSD# define OS_TYPE "NETBSD"# define HEURISTIC2# ifdef __ELF__# define DATASTART GC_data_start# define DYNAMIC_LOADING# else extern char etext[];# define DATASTART ((ptr_t)(etext))# endif# endif# ifdef LINUX# define OS_TYPE "LINUX"# define LINUX_STACKBOTTOM# define MPROTECT_VDB# ifdef __ELF__# define DYNAMIC_LOADING# include <features.h># if defined(__GLIBC__)&& __GLIBC__>=2# define SEARCH_FOR_DATA_START# else /* !GLIBC2 */ extern char **__environ;# define DATASTART ((ptr_t)(&__environ)) /* hideous kludge: __environ is the first */ /* word in crt0.o, and delimits the start */ /* of the data segment, no matter which */ /* ld options were passed through. */ /* We could use _etext instead, but that */ /* would include .rodata, which may */ /* contain large read-only data tables */ /* that we'd rather not scan. */# endif /* !GLIBC2 */ extern int _end[];# define DATAEND (_end)# else extern int etext[];# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))# endif# endif# ifdef AMIGA# define OS_TYPE "AMIGA" /* STACKBOTTOM and DATASTART handled specially */ /* in os_dep.c */# define DATAEND /* not needed */# define GETPAGESIZE() 4096# endif# ifdef MACOS# ifndef __LOWMEM__# include <LowMem.h># endif# define OS_TYPE "MACOS" /* see os_dep.c for details of global data segments. */# define STACKBOTTOM ((ptr_t) LMGetCurStackBase())# define DATAEND /* not needed */# define GETPAGESIZE() 4096# endif# ifdef NEXT# define OS_TYPE "NEXT"# define DATASTART ((ptr_t) get_etext())# define STACKBOTTOM ((ptr_t) 0x4000000)# define DATAEND /* not needed */# endif# endif# if defined(POWERPC)# define MACH_TYPE "POWERPC"# ifdef MACOS# define ALIGNMENT 2 /* Still necessary? Could it be 4? */# ifndef __LOWMEM__# include <LowMem.h># endif# define OS_TYPE "MACOS" /* see os_dep.c for details of global data segments. */# define STACKBOTTOM ((ptr_t) LMGetCurStackBase())# define DATAEND /* not needed */# endif# ifdef LINUX# if defined(__powerpc64__)# define ALIGNMENT 8# define CPP_WORDSZ 64# ifndef HBLKSIZE# define HBLKSIZE 4096# endif# else# define ALIGNMENT 4# endif# define OS_TYPE "LINUX" /* HEURISTIC1 has been reliably reported to fail for a 32-bit */ /* executable on a 64 bit kernel. */# define LINUX_STACKBOTTOM# define DYNAMIC_LOADING# define SEARCH_FOR_DATA_START extern int _end[];# define DATAEND (_end)# endif# ifdef DARWIN# define OS_TYPE "DARWIN"# define DYNAMIC_LOADING# if defined(__ppc64__)# define ALIGNMENT 8# define CPP_WORDSZ 64# define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)# define CACHE_LINE_SIZE 64# ifndef HBLKSIZE# define HBLKSIZE 4096# endif# else# define ALIGNMENT 4# define STACKBOTTOM ((ptr_t) 0xc0000000)# endif /* XXX: see get_end(3), get_etext() and get_end() should not be used. These aren't used when dyld support is enabled (it is by default) */# define DATASTART ((ptr_t) get_etext())# define DATAEND ((ptr_t) get_end())# define USE_MMAP# define USE_MMAP_ANON# ifdef GC_DARWIN_THREADS# define MPROTECT_VDB# endif# include <unistd.h># define GETPAGESIZE() getpagesize()# if defined(USE_PPC_PREFETCH) && defined(__GNUC__) /* The performance impact of prefetches is untested */# define PREFETCH(x) \ __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))# define PREFETCH_FOR_WRITE(x) \ __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))# endif /* There seems to be some issues with trylock hanging on darwin. This should be looked into some more */# define NO_PTHREAD_TRYLOCK# endif# ifdef FREEBSD# define ALIGNMENT 4# define OS_TYPE "FREEBSD"# ifndef GC_FREEBSD_THREADS# define MPROTECT_VDB# endif# define SIG_SUSPEND SIGUSR1# define SIG_THR_RESTART SIGUSR2# define FREEBSD_STACKBOTTOM# ifdef __ELF__# define DYNAMIC_LOADING# endif extern char etext[]; extern char * GC_FreeBSDGetDataStart();# define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)# endif# ifdef NETBSD# define ALIGNMENT 4# define OS_TYPE "NETBSD"# define HEURISTIC2 extern char etext[];# define DATASTART GC_data_start# define DYNAMIC_LOADING# endif# ifdef AIX# define OS_TYPE "AIX"# undef ALIGNMENT /* in case it's defined */# ifdef IA64# undef IA64 /* DOB: some AIX installs stupidly define IA64 in */ /* /usr/include/sys/systemcfg.h */# endif# ifdef __64BIT__# define ALIGNMENT 8# define CPP_WORDSZ 64# define STACKBOTTOM ((ptr_t)0x1000000000000000)# else# define ALIGNMENT 4# define CPP_WORDSZ 32# define STACKBOTTOM ((ptr_t)((ulong)&errno))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -