From 49e069bbda0df25c4facbc646845f1119009a29f Mon Sep 17 00:00:00 2001 From: hboehm Date: Wed, 7 Jun 2006 05:35:31 +0000 Subject: [PATCH] 2006-06-06 Hans Boehm (Really Petr Salinger) * configure.ac, dyn_load.c, doc/README.changes, include/gc.h, include/private/gcconfig.h: Add macro tests and configuration information to support kFreeBSD + glibc. --- configure.ac | 13 +++++++++++- doc/README.changes | 1 + dyn_load.c | 4 ++-- include/gc.h | 2 +- include/private/gcconfig.h | 43 ++++++++++++++++++++++++++++++++------ 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 1c78502ce..d45f7693d 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_INIT(gc,7.0alpha6,Hans.Boehm@hp.com) AC_CONFIG_SRCDIR(gcj_mlc.c) AC_CANONICAL_TARGET AC_PREREQ(2.53) -AC_REVISION($Revision: 1.12 $) +AC_REVISION($Revision: 1.13 $) GC_SET_VERSION AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects nostdinc]) AM_MAINTAINER_MODE @@ -117,6 +117,17 @@ case "$THREADS" in AC_DEFINE(GC_FREEBSD_THREADS) INCLUDES="$INCLUDES -pthread" ;; + *-*-kfreebsd*-gnu) + AC_DEFINE(GC_FREEBSD_THREADS) + INCLUDES="$INCLUDES -pthread" + THREADDLLIBS=-pthread + AC_DEFINE(_REENTRANT) + if test "${enable_parallel_mark}" = yes; then + AC_DEFINE(PARALLEL_MARK) + fi + AC_DEFINE(THREAD_LOCAL_ALLOC) + AC_DEFINE(USE_COMPILER_TLS) + ;; *-*-netbsd*) AC_MSG_WARN("Only on NetBSD 2.0 or later.") AC_DEFINE(GC_NETBSD_THREADS) diff --git a/doc/README.changes b/doc/README.changes index e0a9035ab..afed32969 100644 --- a/doc/README.changes +++ b/doc/README.changes @@ -2283,6 +2283,7 @@ Since gc6.7: - GC_unix_get_mem could neglect to release the malloc lock on Irix, under extremely unlikely circumstances. Thanks to Jean-Baptiste Nivois for some careful code reading. + - Added support for kFreeBSD + glibc (Thanks to Petr Salinger) Since gc6.8: - Remove GC_PROTO, VOLATILE, GC_PTR, and GC_CONST. Assume ANSI C compiler diff --git a/dyn_load.c b/dyn_load.c index 5b21b870e..b17b45abf 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -26,7 +26,7 @@ * 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(__GLIBC__)) && !defined(_GNU_SOURCE) /* Can't test LINUX, since this must be define before other includes */ # define _GNU_SOURCE #endif @@ -319,7 +319,7 @@ GC_bool GC_register_main_static_data() /* 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(LINUX) || defined (__GLIBC__)) /* Are others OK here, too? */ \ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) diff --git a/include/gc.h b/include/gc.h index d08d60c75..019b3a805 100644 --- a/include/gc.h +++ b/include/gc.h @@ -456,7 +456,7 @@ GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb); # define GC_RETURN_ADDR (GC_word)__return_address #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__GLIBC__) # include # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \ && !defined(__ia64__) diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index eda38bb44..17ebc352d 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -56,7 +56,8 @@ # endif /* And one for FreeBSD: */ -# if (defined(__FreeBSD__) || defined(__DragonFly__)) && !defined(FREEBSD) +# if (defined(__FreeBSD__) || defined(__DragonFly__) || \ + defined(__FreeBSD_kernel__)) && !defined(FREEBSD) # define FREEBSD # endif @@ -1191,8 +1192,15 @@ # ifndef GC_FREEBSD_THREADS # define MPROTECT_VDB # endif -# define SIG_SUSPEND SIGUSR1 -# define SIG_THR_RESTART SIGUSR2 +# ifdef __GLIBC__ +# define SIG_SUSPEND (32+6) +# define SIG_THR_RESTART (32+5) + extern int _end[]; +# define DATAEND (_end) +# else +# define SIG_SUSPEND SIGUSR1 +# define SIG_THR_RESTART SIGUSR2 +# endif # define FREEBSD_STACKBOTTOM # ifdef __ELF__ # define DYNAMIC_LOADING @@ -1849,6 +1857,28 @@ # define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1) # endif # endif +# ifdef FREEBSD +# define OS_TYPE "FREEBSD" +# ifndef GC_FREEBSD_THREADS +# define MPROTECT_VDB +# endif +# ifdef __GLIBC__ +# define SIG_SUSPEND (32+6) +# define SIG_THR_RESTART (32+5) + extern int _end[]; +# define DATAEND (_end) +# else +# define SIG_SUSPEND SIGUSR1 +# define SIG_THR_RESTART SIGUSR2 +# endif +# 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" # ifdef __ELF__ @@ -1935,7 +1965,8 @@ # define SUNOS5SIGS # endif -# if defined(FREEBSD) && (defined(__DragonFly__) || __FreeBSD__ >= 4) +# if defined(FREEBSD) && \ + (defined(__DragonFly__) || __FreeBSD__ >= 4 || (__FreeBSD_kernel__ >= 4)) # define SUNOS5SIGS # endif @@ -2004,7 +2035,7 @@ # define CACHE_LINE_SIZE 32 /* Wild guess */ # endif -# ifdef LINUX +# if defined(LINUX) || 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 */ @@ -2088,7 +2119,7 @@ #if defined(SPARC) # define CAN_SAVE_CALL_ARGS #endif -#if (defined(I386) || defined(X86_64)) && defined(LINUX) +#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