diff -ur libgc-6.3.old/configure.in libgc-6.3/configure.in --- libgc-6.3.old/configure.in 2004-07-20 01:51:50.000000000 +0200 +++ libgc-6.3/configure.in 2004-07-20 01:54:03.000000000 +0200 @@ -89,6 +89,9 @@ AC_DEFINE(GC_LINUX_THREADS) AC_DEFINE(_REENTRANT) ;; + *-*-gnu* | *-*-k*bsd*-gnu) + AC_DEFINE(_REENTRANT) + ;; *-*-aix*) AC_DEFINE(GC_AIX_THREADS) AC_DEFINE(_REENTRANT) diff -ur libgc-6.3.old/dbg_mlc.c libgc-6.3/dbg_mlc.c --- libgc-6.3.old/dbg_mlc.c 2004-04-23 01:51:56.000000000 +0200 +++ libgc-6.3/dbg_mlc.c 2004-07-20 01:54:03.000000000 +0200 @@ -59,7 +59,7 @@ # include -# if defined(LINUX) || defined(SUNOS4) || defined(SUNOS5) \ +# if defined(LINUX) || defined(GLIBC) || defined(SUNOS4) || defined(SUNOS5) \ || defined(HPUX) || defined(IRIX5) || defined(OSF1) # define RANDOM() random() # else diff -ur libgc-6.3.old/dyn_load.c libgc-6.3/dyn_load.c --- libgc-6.3.old/dyn_load.c 2004-05-06 01:03:06.000000000 +0200 +++ libgc-6.3/dyn_load.c 2004-07-20 01:54:03.000000000 +0200 @@ -26,7 +26,8 @@ * None of this is safe with dlclose and incremental collection. * But then not much of anything is safe in the presence of dlclose. */ -#if defined(__linux__) && !defined(_GNU_SOURCE) +#if (defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) \ + && !defined(_GNU_SOURCE) /* Can't test LINUX, since this must be define before other includes */ # define _GNU_SOURCE #endif @@ -56,7 +57,7 @@ !(defined(ALPHA) && defined(OSF1)) && \ !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \ !defined(RS6000) && !defined(SCO_ELF) && !defined(DGUX) && \ - !(defined(FREEBSD) && defined(__ELF__)) && \ + !(defined(KFREEBSD) && defined(__ELF__)) && \ !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \ !defined(DARWIN) --> We only know how to find data segments of dynamic libraries for the @@ -81,7 +82,7 @@ #endif #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ - (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ + (defined(KFREEBSD) && defined(__ELF__)) || defined(DGUX) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) # include # include @@ -273,7 +274,7 @@ # endif /* SUNOS */ #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ - (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ + (defined(KFREEBSD) && defined(__ELF__)) || defined(DGUX) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) @@ -368,7 +369,7 @@ /* For glibc 2.2.4+. Unfortunately, it doesn't work for older */ /* versions. Thanks to Jakub Jelinek for most of the code. */ -# if defined(LINUX) /* Are others OK here, too? */ \ +# if defined(GLIBC) \ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) @@ -442,7 +443,7 @@ #define HAVE_REGISTER_MAIN_STATIC_DATA -# else /* !LINUX || version(glibc) < 2.2.4 */ +# else /* !GLIBC || version(glibc) < 2.2.4 */ /* Dynamic loading code for Linux running ELF. Somewhat tested on * Linux/x86, untested but hopefully should work on Linux/Alpha. diff -ur libgc-6.3.old/include/gc.h libgc-6.3/include/gc.h --- libgc-6.3.old/include/gc.h 2004-05-10 23:58:03.000000000 +0200 +++ libgc-6.3/include/gc.h 2004-07-20 01:54:03.000000000 +0200 @@ -465,7 +465,7 @@ # define GC_RETURN_ADDR (GC_word)__return_address #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) # include # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \ && !defined(__ia64__) @@ -494,7 +494,8 @@ /* This may also be desirable if it is possible but expensive to */ /* retrieve the call chain. */ #if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) \ - || defined(__FreeBSD__)) & !defined(GC_CAN_SAVE_CALL_STACKS) + || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \ + ) & !defined(GC_CAN_SAVE_CALL_STACKS) # define GC_ADD_CALLER # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) /* gcc knows how to retrieve return address, but we don't know */ diff -ur libgc-6.3.old/include/private/gcconfig.h libgc-6.3/include/private/gcconfig.h --- libgc-6.3.old/include/private/gcconfig.h 2004-05-06 01:10:54.000000000 +0200 +++ libgc-6.3/include/private/gcconfig.h 2004-07-20 01:54:04.000000000 +0200 @@ -44,6 +44,14 @@ # endif # endif +/* And one for Glibc: */ +#if defined(LINUX) || defined(__GNU__) || defined(__GLIBC__) +# include +#endif +#ifdef __GLIBC__ +# define GLIBC +#endif + /* And one for NetBSD: */ # if defined(__NetBSD__) # define NETBSD @@ -58,6 +66,9 @@ # if defined(__FreeBSD__) # define FREEBSD # endif +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# define KFREEBSD +# endif /* Determine the machine type: */ # if defined(__arm__) || defined(__thumb__) @@ -302,7 +313,7 @@ # define OPENBSD # define mach_type_known # endif -# if defined(FREEBSD) && (defined(i386) || defined(__i386__)) +# if defined(KFREEBSD) && (defined(i386) || defined(__i386__)) # define I386 # define mach_type_known # endif @@ -1188,13 +1199,25 @@ # endif # define SIG_SUSPEND SIGUSR1 # define SIG_THR_RESTART SIGUSR2 + extern char etext[]; + extern char * GC_FreeBSDGetDataStart(); +# define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext) +# endif +# if defined(GLIBC) && defined(KFREEBSD) +# define OS_TYPE "GNU/kFreeBSD" +# if !defined(GC_LINUX_THREADS) && !defined(REDIRECT_MALLOC) +# define MPROTECT_VDB +# endif +# define SIG_SUSPEND 57 /* arbitrary signal number <= 128 */ +# define SIG_THR_RESTART 58 /* arbitrary signal number <= 128 */ +# define SEARCH_FOR_DATA_START +# define DATAEND (sbrk (0)) +# endif +# ifdef KFREEBSD # 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 OS_TYPE "NETBSD" diff -ur libgc-6.3.old/os_dep.c libgc-6.3/os_dep.c --- libgc-6.3.old/os_dep.c 2004-07-07 21:16:28.000000000 +0200 +++ libgc-6.3/os_dep.c 2004-07-20 01:56:20.000000000 +0200 @@ -80,7 +80,7 @@ # define NEED_FIND_LIMIT # endif -#if defined(FREEBSD) && defined(I386) +#if defined(KFREEBSD) && defined(I386) # include # if !defined(PCR) # define NEED_FIND_LIMIT @@ -129,7 +129,7 @@ #ifdef UNIX_LIKE # include -# if defined(SUNOS5SIGS) && !defined(FREEBSD) +# if defined(SUNOS5SIGS) && !defined(KFREEBSD) # include # endif /* Define SETJMP and friends to be the version that restores */ @@ -318,7 +318,7 @@ /* for recent Linux versions. This seems to be the easiest way to */ /* cover all versions. */ -# ifdef LINUX +# if defined(LINUX) || defined(GLIBC) /* Some Linux distributions arrange to define __data_start. Some */ /* define data_start as a weak symbol. The latter is technically */ /* broken, since the user program may define data_start, in which */ @@ -328,7 +328,7 @@ extern int __data_start[]; # pragma weak data_start extern int data_start[]; -# endif /* LINUX */ +# endif /* LINUX || GLIBC */ extern int _end[]; ptr_t GC_data_start; @@ -337,7 +337,7 @@ { extern ptr_t GC_find_limit(); -# ifdef LINUX +# if defined(LINUX) || defined(GLIBC) /* Try the easy approaches first: */ if ((ptr_t)__data_start != 0) { GC_data_start = (ptr_t)(__data_start); @@ -347,7 +347,7 @@ GC_data_start = (ptr_t)(data_start); return; } -# endif /* LINUX */ +# endif /* LINUX || GLIBC */ GC_data_start = GC_find_limit((ptr_t)(_end), FALSE); } #endif @@ -2230,13 +2230,13 @@ #endif /* SUNOS4 || (FREEBSD && !SUNOS5SIGS) */ #if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX) \ - || defined(HURD) + || defined(GLIBC) # ifdef __STDC__ typedef void (* SIG_PF)(int); # else typedef void (* SIG_PF)(); # endif -#endif /* SUNOS5SIGS || OSF1 || LINUX || HURD */ +#endif /* SUNOS5SIGS || OSF1 || LINUX || GLIBC */ #if defined(MSWIN32) typedef LPTOP_LEVEL_EXCEPTION_FILTER SIG_PF; @@ -2359,7 +2359,7 @@ /*ARGSUSED*/ #if !defined(DARWIN) -# if defined (SUNOS4) || (defined(FREEBSD) && !defined(SUNOS5SIGS)) +# if defined (SUNOS4) || (defined(KFREEBSD) && !defined(SUNOS5SIGS)) void GC_write_fault_handler(sig, code, scp, addr) int sig, code; struct sigcontext *scp; @@ -2370,7 +2370,7 @@ || (FC_CODE(code) == FC_OBJERR \ && FC_ERRNO(code) == FC_PROT)) # endif -# ifdef FREEBSD +# ifdef KFREEBSD # define SIG_OK (sig == SIGBUS) # define CODE_OK (code == BUS_PAGE_FAULT) # endif @@ -3908,7 +3908,7 @@ /* I suspect the following works for most X86 *nix variants, so */ /* long as the frame pointer is explicitly stored. In the case of gcc, */ /* compiler flags (e.g. -fomit-frame-pointer) determine whether it is. */ -#if defined(I386) && defined(LINUX) && defined(SAVE_CALL_CHAIN) +#if defined(I386) && (defined(LINUX) || defined(GLIBC)) && defined(SAVE_CALL_CHAIN) # include struct frame { @@ -3919,7 +3919,7 @@ #endif #if defined(SPARC) -# if defined(LINUX) +# if defined(LINUX) || defined(GLIBC) # include struct frame {