diff options
Diffstat (limited to 'include/private/gcconfig.h')
-rw-r--r-- | include/private/gcconfig.h | 780 |
1 files changed, 412 insertions, 368 deletions
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index e914391b..81aa4b52 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -54,8 +54,8 @@ # endif /* And one for FreeBSD: */ -# if (defined(__FreeBSD__) || defined(__DragonFly__) || \ - defined(__FreeBSD_kernel__)) && !defined(FREEBSD) +# if (defined(__FreeBSD__) || defined(__DragonFly__) \ + || defined(__FreeBSD_kernel__)) && !defined(FREEBSD) # define FREEBSD # endif @@ -70,7 +70,7 @@ # define I386 # define mach_type_known # endif -# if defined(__arm__) || defined(__thumb__) +# if defined(__arm) || defined(__arm__) || defined(__thumb__) # define ARM32 # if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \ && !defined(DARWIN) && !defined(_WIN32) && !defined(__CEGCC__) @@ -186,8 +186,8 @@ # define mach_type_known # endif # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \ - && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) \ - && !defined(__DragonFly__) + && !defined(__OpenBSD__) && !defined(__NetBSD__) \ + && !defined(__FreeBSD__) && !defined(__DragonFly__) # define SPARC # define DRSNX # define mach_type_known @@ -250,7 +250,7 @@ # define IA64 # define mach_type_known # endif -# if defined(LINUX) && defined(__arm__) +# if defined(LINUX) && (defined(__arm) || defined(__arm__)) # define ARM32 # define mach_type_known # endif @@ -260,12 +260,8 @@ # endif # define mach_type_known # endif -# if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \ - defined(powerpc64) || defined(__powerpc64__)) -# define POWERPC -# define mach_type_known -# endif -# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__)) +# if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) \ + || defined(powerpc64) || defined(__powerpc64__)) # define POWERPC # define mach_type_known # endif @@ -277,10 +273,6 @@ # define SPARC # define mach_type_known # endif -# if defined(LINUX) && defined(__arm__) -# define ARM32 -# define mach_type_known -# endif # if defined(LINUX) && defined(__sh__) # define SH # define mach_type_known @@ -293,9 +285,14 @@ # define M32R # define mach_type_known # endif +# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__)) +# define POWERPC +# define mach_type_known +# endif # if defined(__alpha) || defined(__alpha__) # define ALPHA -# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD) +# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) \ + && !defined(FREEBSD) # define OSF1 /* a.k.a Digital Unix */ # endif # define mach_type_known @@ -338,6 +335,11 @@ # define DARWIN_DONT_PARSE_STACK # endif # endif +# if defined(__rtems__) && (defined(i386) || defined(__i386__)) +# define I386 +# define RTEMS +# define mach_type_known +# endif # if defined(NeXT) && defined(mc68000) # define M68K # define NEXT @@ -669,11 +671,10 @@ * 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)) \ +/* 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 @@ -750,7 +751,7 @@ # include <LowMem.h> # endif # define OS_TYPE "MACOS" - /* see os_dep.c for details of global data segments. */ + /* see os_dep.c for details of global data segments. */ # define STACKBOTTOM ((ptr_t) LMGetCurStackBase()) # define DATAEND /* not needed */ # define GETPAGESIZE() 4096 @@ -810,8 +811,8 @@ # 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) */ + /* 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()) # ifndef USE_MMAP @@ -828,8 +829,8 @@ # 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 */ + /* There seems to be some issues with trylock hanging on darwin. */ + /* This should be looked into some more. */ # define NO_PTHREAD_TRYLOCK # endif # ifdef OPENBSD @@ -877,7 +878,6 @@ # define ALIGNMENT 4 # define OS_TYPE "NETBSD" # define HEURISTIC2 - extern char etext[]; extern ptr_t GC_data_start; # define DATASTART GC_data_start # define DYNAMIC_LOADING @@ -1128,6 +1128,9 @@ # ifdef SOLARIS25_PROC_VDB_BUG_FIXED # define PROC_VDB # endif +# ifndef GC_THREADS +# define MPROTECT_VDB +# endif # define DYNAMIC_LOADING # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) # define USE_MMAP @@ -1247,26 +1250,26 @@ # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) # endif # ifdef USE_I686_PREFETCH - /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */ - /* for the next rtelease. */ + /* FIXME: Thus should use __builtin_prefetch, but we'll leave that */ + /* for the next rtelease. */ # define PREFETCH(x) \ - __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x))) - /* Empirically prefetcht0 is much more effective at reducing */ - /* cache miss stalls for the targeted load instructions. But it */ - /* seems to interfere enough with other cache traffic that the net */ - /* result is worse than prefetchnta. */ -# if 0 - /* Using prefetches for write seems to have a slight negative */ - /* impact on performance, at least for a PIII/500. */ + __asm__ __volatile__ ("prefetchnta %0" : : "m"(*(char *)(x))) + /* Empirically prefetcht0 is much more effective at reducing */ + /* cache miss stalls for the targeted load instructions. But it */ + /* seems to interfere enough with other cache traffic that the */ + /* net result is worse than prefetchnta. */ +# ifdef FORCE_WRITE_PREFETCH + /* Using prefetches for write seems to have a slight negative */ + /* impact on performance, at least for a PIII/500. */ # define PREFETCH_FOR_WRITE(x) \ - __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x))) + __asm__ __volatile__ ("prefetcht0 %0" : : "m"(*(char *)(x))) # endif # endif # ifdef USE_3DNOW_PREFETCH # define PREFETCH(x) \ - __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x))) + __asm__ __volatile__ ("prefetch %0" : : "m"(*(char *)(x))) # define PREFETCH_FOR_WRITE(x) \ - __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x))) + __asm__ __volatile__ ("prefetchw %0" : : "m"(*(char *)(x))) # endif # endif # ifdef CYGWIN32 @@ -1306,8 +1309,7 @@ extern int _stklen; extern int __djgpp_stack_limit; # define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff)) -/* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \ - + _stklen)) */ +/* #define STACKBOTTOM ((ptr_t)((word)_stubinfo+_stubinfo->size+_stklen)) */ # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen)) /* This may not be right. */ # endif @@ -1373,14 +1375,24 @@ # define STACKBOTTOM ((ptr_t)0xc0000000) # define DATAEND /* not needed */ # endif +# ifdef RTEMS +# define OS_TYPE "RTEMS" +# include <sys/unistd.h> + extern int etext[]; + extern int end[]; + extern void *InitStackBottom; +# define DATASTART ((ptr_t)etext) +# define DATAEND ((ptr_t)end) +# define STACKBOTTOM ((ptr_t)InitStackBottom) +# endif # ifdef DOS4GW # define OS_TYPE "DOS4GW" extern long __nullarea; extern char _end; extern char *_STACKTOP; - /* Depending on calling conventions Watcom C either precedes - or does not precedes with underscore names of C-variables. - Make sure startup code variables always have the same names. */ + /* Depending on calling conventions Watcom C either precedes */ + /* or does not precedes with underscore names of C-variables. */ + /* Make sure startup code variables always have the same names. */ #pragma aux __nullarea "*"; #pragma aux _end "*"; # define STACKBOTTOM ((ptr_t) _STACKTOP) @@ -1404,8 +1416,8 @@ # define OS_TYPE "DARWIN" # define DARWIN_DONT_PARSE_STACK # define DYNAMIC_LOADING - /* 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) */ + /* 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 STACKBOTTOM ((ptr_t) 0xc0000000) @@ -1416,8 +1428,8 @@ # define MPROTECT_VDB # include <unistd.h> # define GETPAGESIZE() getpagesize() - /* There seems to be some issues with trylock hanging on darwin. This - should be looked into some more */ + /* There seems to be some issues with trylock hanging on darwin. */ + /* This should be looked into some more. */ # define NO_PTHREAD_TRYLOCK # endif /* DARWIN */ # endif @@ -1516,7 +1528,6 @@ # define ALIGNMENT 4 # define HEURISTIC2 # ifdef __ELF__ - extern int etext[]; extern ptr_t GC_data_start; # define DATASTART GC_data_start # define NEED_FIND_LIMIT @@ -1563,22 +1574,15 @@ # define ALIGNMENT 4 # endif # if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS) \ - && !defined(OPENBSD) -# ifndef LINUX /* For now. */ -# define MPROTECT_VDB -# endif -# else -# ifdef PARALLEL_MARK -# define USE_MARK_BYTES - /* Minimize compare-and-swap usage. */ -# endif + && !defined(OPENBSD) && !defined(LINUX) /* For now. */ +# define MPROTECT_VDB # endif # define STACK_GROWS_UP # ifdef HPUX # define OS_TYPE "HPUX" extern int __data_start[]; # define DATASTART ((ptr_t)(__data_start)) -# if 0 +# ifdef USE_HPUX_FIXED_STACKBOTTOM /* The following appears to work for 7xx systems running HP/UX */ /* 9.xx Furthermore, it might result in much faster */ /* collections than HEURISTIC2, which may involve scanning */ @@ -1729,7 +1733,7 @@ # define ALIGNMENT 4 # else # ifndef _LP64 - ---> unknown ABI +# error --> unknown ABI # endif # define CPP_WORDSZ 64 /* Requires 16 byte alignment for malloc */ @@ -2124,8 +2128,8 @@ # define OS_TYPE "DARWIN" # define DARWIN_DONT_PARSE_STACK # define DYNAMIC_LOADING - /* 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) */ + /* 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 STACKBOTTOM ((ptr_t) 0x7fff5fc00000) @@ -2136,8 +2140,8 @@ # define MPROTECT_VDB # include <unistd.h> # define GETPAGESIZE() getpagesize() - /* There seems to be some issues with trylock hanging on darwin. This - should be looked into some more */ + /* 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 @@ -2165,12 +2169,14 @@ # endif # ifdef NETBSD # define OS_TYPE "NETBSD" +# define HEURISTIC2 # ifdef __ELF__ + extern ptr_t GC_data_start; +# define DATASTART GC_data_start # define DYNAMIC_LOADING +# else +# define SEARCH_FOR_DATA_START # endif -# define HEURISTIC2 - extern char etext[]; -# define SEARCH_FOR_DATA_START # endif # ifdef SOLARIS # define OS_TYPE "SOLARIS" @@ -2200,6 +2206,9 @@ # ifdef SOLARIS25_PROC_VDB_BUG_FIXED # define PROC_VDB # endif +# ifndef GC_THREADS +# define MPROTECT_VDB +# endif # define DYNAMIC_LOADING # if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) # define USE_MMAP @@ -2244,7 +2253,8 @@ # define USE_MMAP_ANON #endif -#if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) +#if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \ + && !defined(USE_PROC_FOR_LIBRARIES) /* Nptl allocates thread stacks with mmap, which is fine. But it */ /* keeps a cache of thread stacks. Thread stacks contain the */ /* thread control blocks. These in turn contain a pointer to */ @@ -2270,354 +2280,387 @@ # define USE_PROC_FOR_LIBRARIES #endif -# ifndef STACK_GROWS_UP -# define STACK_GROWS_DOWN -# endif +#ifndef STACK_GROWS_UP +# define STACK_GROWS_DOWN +#endif -# ifndef CPP_WORDSZ -# define CPP_WORDSZ 32 -# endif +#ifndef CPP_WORDSZ +# define CPP_WORDSZ 32 +#endif -# ifndef OS_TYPE -# define OS_TYPE "" -# endif +#ifndef OS_TYPE +# define OS_TYPE "" +#endif -# ifndef DATAEND - extern int end[]; -# define DATAEND (ptr_t)(end) -# endif +#ifndef DATAEND + extern int end[]; +# define DATAEND (ptr_t)(end) +#endif -# if defined(SVR4) && !defined(GETPAGESIZE) -# include <unistd.h> -# define GETPAGESIZE() sysconf(_SC_PAGESIZE) -# endif +#if (defined(SVR4) || defined(PLATFORM_ANDROID)) && !defined(GETPAGESIZE) +# include <unistd.h> +# define GETPAGESIZE() sysconf(_SC_PAGESIZE) +#endif -# ifndef GETPAGESIZE -# if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \ - || defined(NETBSD) || defined(FREEBSD) || defined(HPUX) -# include <unistd.h> -# endif -# define GETPAGESIZE() getpagesize() +#ifndef GETPAGESIZE +# if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \ + || defined(NETBSD) || defined(FREEBSD) || defined(HPUX) +# include <unistd.h> # endif +# define GETPAGESIZE() getpagesize() +#endif -# if defined(SOLARIS) || defined(DRSNX) || defined(UTS4) - /* OS has SVR4 generic features. */ - /* Probably others also qualify. */ -# define SVR4 -# endif +#if defined(SOLARIS) || defined(DRSNX) || defined(UTS4) + /* OS has SVR4 generic features. */ + /* Probably others also qualify. */ +# define SVR4 +#endif -# if defined(SOLARIS) || defined(DRSNX) - /* OS has SOLARIS style semi-undocumented interface */ - /* to dynamic loader. */ -# define SOLARISDL - /* OS has SOLARIS style signal handlers. */ -# define SUNOS5SIGS -# endif +#if defined(SOLARIS) || defined(DRSNX) + /* OS has SOLARIS style semi-undocumented interface */ + /* to dynamic loader. */ +# define SOLARISDL + /* OS has SOLARIS style signal handlers. */ +# define SUNOS5SIGS +#endif -# if defined(HPUX) -# define SUNOS5SIGS -# endif +#if defined(HPUX) +# define SUNOS5SIGS +#endif -# if defined(FREEBSD) && \ - (defined(__DragonFly__) || __FreeBSD__ >= 4 || (__FreeBSD_kernel__ >= 4)) -# define SUNOS5SIGS -# endif +#if defined(FREEBSD) && (defined(__DragonFly__) || __FreeBSD__ >= 4 \ + || (__FreeBSD_kernel__ >= 4)) +# define SUNOS5SIGS +#endif -# ifdef GC_NETBSD_THREADS -# define SIGRTMIN 33 -# define SIGRTMAX 63 -# endif +#if !defined(GC_EXPLICIT_SIGNALS_UNBLOCK) && defined(SUNOS5SIGS) \ + && !defined(GC_NO_PTHREAD_SIGMASK) +# define GC_EXPLICIT_SIGNALS_UNBLOCK +#endif -# if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \ - || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \ - || defined(DGUX) || defined(BSD) || defined(HURD) \ - || defined(AIX) || defined(DARWIN) || defined(OSF1) -# define UNIX_LIKE /* Basic Unix-like system calls work. */ -# endif +#ifdef GC_NETBSD_THREADS +# define SIGRTMIN 33 +# define SIGRTMAX 63 +#endif -# if CPP_WORDSZ != 32 && CPP_WORDSZ != 64 - -> bad word size -# endif +#if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \ + || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \ + || defined(DGUX) || defined(BSD) || defined(HURD) \ + || defined(AIX) || defined(DARWIN) || defined(OSF1) +# define UNIX_LIKE /* Basic Unix-like system calls work. */ +#endif -# ifndef ALIGNMENT - --> undefined ALIGNMENT -# endif +#if CPP_WORDSZ != 32 && CPP_WORDSZ != 64 +# error --> bad word size +#endif -# ifdef PCR -# undef DYNAMIC_LOADING -# undef STACKBOTTOM -# undef HEURISTIC1 -# undef HEURISTIC2 -# undef PROC_VDB -# undef MPROTECT_VDB -# define PCR_VDB -# endif +#ifndef ALIGNMENT +# error --> undefined ALIGNMENT +#endif -# if !defined(STACKBOTTOM) && (defined(ECOS) || defined(NOSYS)) -# error --> undefined STACKBOTTOM -# endif +#ifdef PCR +# undef DYNAMIC_LOADING +# undef STACKBOTTOM +# undef HEURISTIC1 +# undef HEURISTIC2 +# undef PROC_VDB +# undef MPROTECT_VDB +# define PCR_VDB +#endif -# ifdef IGNORE_DYNAMIC_LOADING -# undef DYNAMIC_LOADING -# endif +#if !defined(STACKBOTTOM) && (defined(ECOS) || defined(NOSYS)) +# error --> undefined STACKBOTTOM +#endif -# if defined(SMALL_CONFIG) && !defined(GC_DISABLE_INCREMENTAL) - /* Presumably not worth the space it takes. */ -# define GC_DISABLE_INCREMENTAL -# endif +#ifdef IGNORE_DYNAMIC_LOADING +# undef DYNAMIC_LOADING +#endif -# ifdef GC_DISABLE_INCREMENTAL -# undef GWW_VDB -# undef MPROTECT_VDB -# undef PCR_VDB -# undef PROC_VDB -# undef CHECKSUMS -# endif +#if defined(SMALL_CONFIG) && !defined(GC_DISABLE_INCREMENTAL) + /* Presumably not worth the space it takes. */ +# define GC_DISABLE_INCREMENTAL +#endif -# ifdef USE_GLOBAL_ALLOC - /* Cannot pass MEM_WRITE_WATCH to GlobalAlloc(). */ -# undef GWW_VDB -# endif +#if defined(GC_DISABLE_INCREMENTAL) || defined(MANUAL_VDB) +# undef GWW_VDB +# undef MPROTECT_VDB +# undef PCR_VDB +# undef PROC_VDB +#endif -# ifdef USE_MUNMAP - /* FIXME: Remove this undef if possible. */ -# undef MPROTECT_VDB /* Can't deal with address space holes. */ -# endif +#ifdef GC_DISABLE_INCREMENTAL +# undef CHECKSUMS +#endif + +#ifdef USE_GLOBAL_ALLOC + /* Cannot pass MEM_WRITE_WATCH to GlobalAlloc(). */ +# undef GWW_VDB +#endif + +#ifdef USE_MUNMAP + /* FIXME: Remove this undef if possible. */ +# undef MPROTECT_VDB /* Can't deal with address space holes. */ +#endif /* PARALLEL_MARK does not cause undef MPROTECT_VDB any longer. */ -# if defined(MPROTECT_VDB) && defined(GC_PREFER_MPROTECT_VDB) - /* Choose MPROTECT_VDB manually (if multiple strategies available). */ -# undef PCR_VDB -# undef PROC_VDB - /* #undef GWW_VDB - handled in os_dep.c */ -# endif +#if defined(MPROTECT_VDB) && defined(GC_PREFER_MPROTECT_VDB) + /* Choose MPROTECT_VDB manually (if multiple strategies available). */ +# undef PCR_VDB +# undef PROC_VDB + /* #undef GWW_VDB - handled in os_dep.c */ +#endif -# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) \ - && !defined(GWW_VDB) && !defined(GC_DISABLE_INCREMENTAL) -# define DEFAULT_VDB -# endif +#ifdef PROC_VDB + /* Multi-VDB mode is not implemented. */ +# undef MPROTECT_VDB +#endif -# ifndef PREFETCH -# define PREFETCH(x) -# define NO_PREFETCH -# endif +#if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) \ + && !defined(GWW_VDB) && !defined(MANUAL_VDB) \ + && !defined(GC_DISABLE_INCREMENTAL) +# define DEFAULT_VDB +#endif -# ifndef PREFETCH_FOR_WRITE -# define PREFETCH_FOR_WRITE(x) -# define NO_PREFETCH_FOR_WRITE -# endif +#if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HURD) \ + || defined(OPENBSD) || defined(ARM32) \ + || defined(MIPS) || defined(AVR32))) \ + || (defined(LINUX) && (defined(SPARC) || defined(M68K))) \ + || (defined(RTEMS) && defined(I386))) && !defined(NO_GETCONTEXT) +# define NO_GETCONTEXT +#endif -# ifndef CACHE_LINE_SIZE -# define CACHE_LINE_SIZE 32 /* Wild guess */ -# endif +#ifndef PREFETCH +# define PREFETCH(x) +# define NO_PREFETCH +#endif -# ifndef STATIC -# ifndef NO_DEBUGGING -# define STATIC /* ignore to aid profiling and possibly debugging */ -# else -# define STATIC static -# endif -# endif +#ifndef PREFETCH_FOR_WRITE +# define PREFETCH_FOR_WRITE(x) +# define NO_PREFETCH_FOR_WRITE +#endif -# if defined(LINUX) || defined(HURD) || defined(__GLIBC__) -# define REGISTER_LIBRARIES_EARLY - /* We sometimes use dl_iterate_phdr, which may acquire an internal */ - /* lock. This isn't safe after the world has stopped. So we must */ - /* call GC_register_dynamic_libraries before stopping the world. */ - /* For performance reasons, this may be beneficial on other */ - /* platforms as well, though it should be avoided in win32. */ -# endif /* LINUX */ +#ifndef CACHE_LINE_SIZE +# define CACHE_LINE_SIZE 32 /* Wild guess */ +#endif -# if defined(SEARCH_FOR_DATA_START) - extern ptr_t GC_data_start; -# define DATASTART GC_data_start +#ifndef STATIC +# ifndef NO_DEBUGGING +# define STATIC /* ignore to aid profiling and possibly debugging */ +# else +# define STATIC static # endif +#endif -# ifndef CLEAR_DOUBLE -# define CLEAR_DOUBLE(x) \ - ((word*)x)[0] = 0; \ - ((word*)x)[1] = 0; -# endif /* CLEAR_DOUBLE */ +#if defined(LINUX) && (defined(USE_PROC_FOR_LIBRARIES) || defined(IA64) \ + || !defined(SMALL_CONFIG)) +# define NEED_PROC_MAPS +#endif -# if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \ - && !defined(INCLUDE_LINUX_THREAD_DESCR) - /* Will not work, since libc and the dynamic loader use thread */ - /* locals, sometimes as the only reference. */ -# define INCLUDE_LINUX_THREAD_DESCR -# endif +#if defined(LINUX) || defined(HURD) || defined(__GLIBC__) +# define REGISTER_LIBRARIES_EARLY + /* We sometimes use dl_iterate_phdr, which may acquire an internal */ + /* lock. This isn't safe after the world has stopped. So we must */ + /* call GC_register_dynamic_libraries before stopping the world. */ + /* For performance reasons, this may be beneficial on other */ + /* platforms as well, though it should be avoided in win32. */ +#endif /* LINUX */ + +#if defined(SEARCH_FOR_DATA_START) + extern ptr_t GC_data_start; +# define DATASTART GC_data_start +#endif -# if defined(GC_IRIX_THREADS) && !defined(IRIX5) - --> inconsistent configuration -# endif -# if defined(GC_LINUX_THREADS) && !defined(LINUX) && !defined(NACL) - --> inconsistent configuration -# endif -# if defined(GC_NETBSD_THREADS) && !defined(NETBSD) - --> inconsistent configuration -# endif -# if defined(GC_FREEBSD_THREADS) && !defined(FREEBSD) - --> inconsistent configuration -# endif -# if defined(GC_SOLARIS_THREADS) && !defined(SOLARIS) - --> inconsistent configuration -# endif -# if defined(GC_HPUX_THREADS) && !defined(HPUX) - --> inconsistent configuration -# endif -# if defined(GC_AIX_THREADS) && !defined(_AIX) - --> inconsistent configuration -# endif -# if defined(GC_GNU_THREADS) && !defined(HURD) - --> inconsistent configuration -# endif -# if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32) \ - && !defined(MSWINCE) - --> inconsistent configuration -# endif +#ifndef CLEAR_DOUBLE +# define CLEAR_DOUBLE(x) (((word*)(x))[0] = 0, ((word*)(x))[1] = 0) +#endif -# if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS) \ - || defined(SN_TARGET_PS3) -# define THREADS -# endif +#if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \ + && !defined(INCLUDE_LINUX_THREAD_DESCR) + /* Will not work, since libc and the dynamic loader use thread */ + /* locals, sometimes as the only reference. */ +# define INCLUDE_LINUX_THREAD_DESCR +#endif -# if defined(UNIX_LIKE) && defined(THREADS) && !defined(NO_CANCEL_SAFE) \ - && !defined(PLATFORM_ANDROID) - /* Make the code cancellation-safe. This basically means that we */ - /* ensure that cancellation requests are ignored while we are in */ - /* the collector. This applies only to Posix deferred cancellation;*/ - /* we don't handle Posix asynchronous cancellation. */ - /* Note that this only works if pthread_setcancelstate is */ - /* async-signal-safe, at least in the absence of asynchronous */ - /* cancellation. This appears to be true for the glibc version, */ - /* though it is not documented. Without that assumption, there */ - /* seems to be no way to safely wait in a signal handler, which */ - /* we need to do for thread suspension. */ - /* Also note that little other code appears to be cancellation-safe.*/ - /* Hence it may make sense to turn this off for performance. */ -# define CANCEL_SAFE -# endif +#if defined(GC_IRIX_THREADS) && !defined(IRIX5) +# error --> inconsistent configuration +#endif +#if defined(GC_LINUX_THREADS) && !defined(LINUX) && !defined(NACL) +# error --> inconsistent configuration +#endif +#if defined(GC_NETBSD_THREADS) && !defined(NETBSD) +# error --> inconsistent configuration +#endif +#if defined(GC_FREEBSD_THREADS) && !defined(FREEBSD) +# error --> inconsistent configuration +#endif +#if defined(GC_SOLARIS_THREADS) && !defined(SOLARIS) +# error --> inconsistent configuration +#endif +#if defined(GC_HPUX_THREADS) && !defined(HPUX) +# error --> inconsistent configuration +#endif +#if defined(GC_AIX_THREADS) && !defined(_AIX) +# error --> inconsistent configuration +#endif +#if defined(GC_GNU_THREADS) && !defined(HURD) +# error --> inconsistent configuration +#endif +#if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32) \ + && !defined(MSWINCE) +# error --> inconsistent configuration +#endif -# ifdef CANCEL_SAFE -# define IF_CANCEL(x) x -# else -# define IF_CANCEL(x) -# endif +#if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS) \ + || defined(SN_TARGET_PS3) +# define THREADS +#endif -# if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES) -# if defined(THREADS) && defined(PARALLEL_MARK) -# define USE_MARK_BYTES -# else -# define USE_MARK_BITS -# endif -# endif +#if defined(UNIX_LIKE) && defined(THREADS) && !defined(NO_CANCEL_SAFE) \ + && !defined(PLATFORM_ANDROID) + /* Make the code cancellation-safe. This basically means that we */ + /* ensure that cancellation requests are ignored while we are in */ + /* the collector. This applies only to Posix deferred cancellation; */ + /* we don't handle Posix asynchronous cancellation. */ + /* Note that this only works if pthread_setcancelstate is */ + /* async-signal-safe, at least in the absence of asynchronous */ + /* cancellation. This appears to be true for the glibc version, */ + /* though it is not documented. Without that assumption, there */ + /* seems to be no way to safely wait in a signal handler, which */ + /* we need to do for thread suspension. */ + /* Also note that little other code appears to be cancellation-safe. */ + /* Hence it may make sense to turn this off for performance. */ +# define CANCEL_SAFE +#endif -# if defined(MSWINCE) && !defined(__CEGCC__) && !defined(NO_GETENV) -# define NO_GETENV -# endif +#ifdef CANCEL_SAFE +# define IF_CANCEL(x) x +#else +# define IF_CANCEL(x) /* empty */ +#endif -# if (defined(NO_GETENV) || defined(MSWINCE)) && !defined(NO_GETENV_WIN32) -# define NO_GETENV_WIN32 -# endif +#if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES) \ + && defined(PARALLEL_MARK) + /* Minimize compare-and-swap usage. */ +# define USE_MARK_BYTES +#endif -# ifndef STRTOULL -# if defined(_WIN64) && !defined(__GNUC__) -# define STRTOULL _strtoui64 -# elif defined(_LLP64) || defined(__LLP64__) || defined(_WIN64) -# define STRTOULL strtoull -# else - /* strtoul() fits since sizeof(long) >= sizeof(word). */ -# define STRTOULL strtoul -# endif +#if defined(MSWINCE) && !defined(__CEGCC__) && !defined(NO_GETENV) +# define NO_GETENV +#endif + +#if (defined(NO_GETENV) || defined(MSWINCE)) && !defined(NO_GETENV_WIN32) +# define NO_GETENV_WIN32 +#endif + +#ifndef STRTOULL +# if defined(_WIN64) && !defined(__GNUC__) +# define STRTOULL _strtoui64 +# elif defined(_LLP64) || defined(__LLP64__) || defined(_WIN64) +# define STRTOULL strtoull +# else + /* strtoul() fits since sizeof(long) >= sizeof(word). */ +# define STRTOULL strtoul # endif +#endif /* !STRTOULL */ -# if defined(SPARC) -# define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */ - /* include assembly code to do it well. */ +#ifndef GC_WORD_C +# if defined(_WIN64) && !defined(__GNUC__) +# define GC_WORD_C(val) val##ui64 +# elif defined(_LLP64) || defined(__LLP64__) || defined(_WIN64) +# define GC_WORD_C(val) val##ULL +# else +# define GC_WORD_C(val) ((word)val##UL) # endif +#endif /* !GC_WORD_C */ - /* Can we save call chain in objects for debugging? */ - /* SET NFRAMES (# of saved frames) and NARGS (#of args for each */ - /* frame) to reasonable values for the platform. */ - /* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */ - /* at build time, though we feel free to adjust it slightly. */ - /* Define NEED_CALLINFO if we either save the call stack or */ - /* GC_ADD_CALLER is defined. */ - /* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */ +#if defined(SPARC) +# define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */ + /* include assembly code to do it well. */ +#endif +/* Can we save call chain in objects for debugging? */ +/* SET NFRAMES (# of saved frames) and NARGS (#of args for each */ +/* frame) to reasonable values for the platform. */ +/* Set SAVE_CALL_CHAIN if we can. SAVE_CALL_COUNT can be specified */ +/* at build time, though we feel free to adjust it slightly. */ +/* Define NEED_CALLINFO if we either save the call stack or */ +/* GC_ADD_CALLER is defined. */ +/* GC_CAN_SAVE_CALL_STACKS is set in gc.h. */ #if defined(SPARC) # define CAN_SAVE_CALL_ARGS #endif -#if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__)) - /* SAVE_CALL_CHAIN is supported if the code is compiled to save */ - /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */ +#if (defined(I386) || defined(X86_64)) \ + && (defined(LINUX) || defined(__GLIBC__)) + /* SAVE_CALL_CHAIN is supported if the code is compiled to save */ + /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */ # define CAN_SAVE_CALL_ARGS #endif -# if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \ - && defined(GC_CAN_SAVE_CALL_STACKS) -# define SAVE_CALL_CHAIN -# endif -# ifdef SAVE_CALL_CHAIN -# if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS) -# define NARGS SAVE_CALL_NARGS -# else -# define NARGS 0 /* Number of arguments to save for each call. */ -# endif -# endif -# ifdef SAVE_CALL_CHAIN -# ifndef SAVE_CALL_COUNT -# define NFRAMES 6 /* Number of frames to save. Even for */ - /* alignment reasons. */ -# else -# define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1) -# endif -# define NEED_CALLINFO -# endif /* SAVE_CALL_CHAIN */ -# ifdef GC_ADD_CALLER -# define NFRAMES 1 -# define NARGS 0 -# define NEED_CALLINFO +#if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \ + && defined(GC_CAN_SAVE_CALL_STACKS) +# define SAVE_CALL_CHAIN +#endif +#ifdef SAVE_CALL_CHAIN +# if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS) +# define NARGS SAVE_CALL_NARGS +# else +# define NARGS 0 /* Number of arguments to save for each call. */ # endif +#endif +#ifdef SAVE_CALL_CHAIN +# ifndef SAVE_CALL_COUNT +# define NFRAMES 6 /* Number of frames to save. Even for */ + /* alignment reasons. */ +# else +# define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1) +# endif +# define NEED_CALLINFO +#endif /* SAVE_CALL_CHAIN */ +#ifdef GC_ADD_CALLER +# define NFRAMES 1 +# define NARGS 0 +# define NEED_CALLINFO +#endif -# if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL) -# define DBG_HDRS_ALL -# endif +#if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL) +# define DBG_HDRS_ALL +#endif -# if defined(POINTER_MASK) && !defined(POINTER_SHIFT) -# define POINTER_SHIFT 0 -# endif +#if defined(POINTER_MASK) && !defined(POINTER_SHIFT) +# define POINTER_SHIFT 0 +#endif -# if defined(POINTER_SHIFT) && !defined(POINTER_MASK) -# define POINTER_MASK ((GC_word)(-1)) -# endif +#if defined(POINTER_SHIFT) && !defined(POINTER_MASK) +# define POINTER_MASK ((GC_word)(-1)) +#endif -# if !defined(FIXUP_POINTER) && defined(POINTER_MASK) -# define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT) -# endif +#if !defined(FIXUP_POINTER) && defined(POINTER_MASK) +# define FIXUP_POINTER(p) (p = ((p) & POINTER_MASK) << POINTER_SHIFT) +#endif -# if defined(FIXUP_POINTER) -# define NEED_FIXUP_POINTER 1 -# else -# define NEED_FIXUP_POINTER 0 -# define FIXUP_POINTER(p) -# endif +#if defined(FIXUP_POINTER) +# define NEED_FIXUP_POINTER 1 +#else +# define NEED_FIXUP_POINTER 0 +# define FIXUP_POINTER(p) +#endif -# if !defined(MARK_BIT_PER_GRANULE) && !defined(MARK_BIT_PER_OBJ) -# define MARK_BIT_PER_GRANULE /* Usually faster */ -# endif +#if !defined(MARK_BIT_PER_GRANULE) && !defined(MARK_BIT_PER_OBJ) +# define MARK_BIT_PER_GRANULE /* Usually faster */ +#endif /* Some static sanity tests. */ -# if defined(MARK_BIT_PER_GRANULE) && defined(MARK_BIT_PER_OBJ) -# error Define only one of MARK_BIT_PER_GRANULE and MARK_BIT_PER_OBJ. -# endif +#if defined(MARK_BIT_PER_GRANULE) && defined(MARK_BIT_PER_OBJ) +# error Define only one of MARK_BIT_PER_GRANULE and MARK_BIT_PER_OBJ. +#endif -# if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN) -# error "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd." -# endif -# if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN) -# error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd." -# endif +#if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN) +# error "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd." +#endif +#if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN) +# error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd." +#endif # if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) // FIXME: no idea if this is really true! @@ -2643,18 +2686,19 @@ struct hblk; /* See gc_priv.h. */ # if defined(PCR) char * real_malloc(size_t bytes); -# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \ +# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)(bytes) + GC_page_size) \ + GC_page_size-1) # elif defined(OS2) void * os2_alloc(size_t bytes); -# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \ - + GC_page_size) \ - + GC_page_size-1) -# elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) || \ - (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \ - (defined(SOLARIS) && !defined(USE_MMAP)) -# define GET_MEM(bytes) HBLKPTR((size_t) calloc(1, (size_t)bytes + GC_page_size) \ - + GC_page_size-1) +# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)(bytes) \ + + GC_page_size) + GC_page_size-1) +# elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) \ + || (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) \ + || (defined(SOLARIS) && !defined(USE_MMAP)) || defined(RTEMS) \ + || defined(__CC_ARM) +# define GET_MEM(bytes) HBLKPTR((size_t)calloc(1, \ + (size_t)(bytes) + GC_page_size) \ + + GC_page_size - 1) # elif defined(MSWIN32) || defined(CYGWIN32) ptr_t GC_win32_get_mem(GC_word bytes); # define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes) @@ -2662,10 +2706,10 @@ # if defined(USE_TEMPORARY_MEMORY) Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory); # define GET_MEM(bytes) HBLKPTR( \ - GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \ - + GC_page_size-1) + GC_MacTemporaryNewPtr((bytes) + GC_page_size, true) \ + + GC_page_size-1) # else -# define GET_MEM(bytes) HBLKPTR(NewPtrClear(bytes + GC_page_size) \ +# define GET_MEM(bytes) HBLKPTR(NewPtrClear((bytes) + GC_page_size) \ + GC_page_size-1) # endif # elif defined(MSWINCE) @@ -2674,7 +2718,7 @@ # elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC) void *GC_amiga_get_mem(size_t size); # define GET_MEM(bytes) HBLKPTR((size_t) \ - GC_amiga_get_mem((size_t)bytes + GC_page_size) \ + GC_amiga_get_mem((size_t)(bytes) + GC_page_size) \ + GC_page_size-1) # elif defined(SN_TARGET_PS3) void *ps3_get_mem(size_t size); |