diff options
author | Jo Shields <jo.shields@xamarin.com> | 2014-07-31 13:26:34 +0400 |
---|---|---|
committer | Jo Shields <jo.shields@xamarin.com> | 2014-07-31 14:44:51 +0400 |
commit | 1f513847b28b34ddf42719faac8cae4b562e70ff (patch) | |
tree | e772afca65d49f855a75709dc50414c4df89169d | |
parent | 303e42b130beac49a29868a8fcadaf42c598812f (diff) |
Support for GNU/kFreeBSD.
GNU/kFreeBSD is an experimental OS provided by the Debian project, consisting
of a FreeBSD kernel and GNU userland/libc. For a small number of cases, this
offers advantages over a more common GNU/Linux combination, such as fast
in-kernel support for ZFS storage.
This patch changes various ifdefs, either using __FreeBSD_kernel__ where a
trait from the kernel is what matters, or __GLIBC__ where a trait from the
C library matters.
This patch set has been carried downstream, in one form or another, since
1.2.3.1-1.
https://bugzilla.novell.com/show_bug.cgi?id=321634
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | libgc/configure.ac | 11 | ||||
-rw-r--r-- | libgc/dyn_load.c | 4 | ||||
-rw-r--r-- | libgc/include/gc.h | 2 | ||||
-rw-r--r-- | libgc/include/private/gcconfig.h | 30 | ||||
-rwxr-xr-x | mono/io-layer/io.c | 2 | ||||
-rw-r--r-- | mono/metadata/sgen-os-posix.c | 2 | ||||
-rw-r--r-- | mono/mini/mini-amd64.h | 2 | ||||
-rw-r--r-- | mono/mini/mini-x86.h | 2 | ||||
-rw-r--r-- | mono/utils/mono-sigcontext.h | 8 |
10 files changed, 62 insertions, 21 deletions
diff --git a/configure.ac b/configure.ac index c35b45826a7..9ba718b3854 100644 --- a/configure.ac +++ b/configure.ac @@ -142,6 +142,17 @@ case "$host" in with_sigaltstack=no use_sigposix=yes ;; + *-*-kfreebsd*-gnu) + platform_win32=no + CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP -DUSE_MUNMAP -DTHREAD_LOCAL_ALLOC -pthread" + libmono_cflags="-D_REENTRANT -DTHREAD_LOCAL_ALLOC -pthread" + libmono_ldflags="-lpthread -pthread" + libdl="-ldl" + libgc_threads=pthreads + need_link_unlink=yes + with_sigaltstack=no + use_sigposix=yes + ;; *-*-*freebsd*) host_win32=no if test "x$PTHREAD_CFLAGS" = "x"; then @@ -2565,7 +2576,7 @@ case "$host" in sgen_supported=true AOT_SUPPORTED="yes" ;; - openbsd*|freebsd*) + openbsd*|freebsd*|kfreebsd-gnu*) sgen_supported=true ;; esac @@ -2587,7 +2598,7 @@ case "$host" in sgen_supported=true AOT_SUPPORTED="yes" ;; - openbsd*|freebsd*) + openbsd*|freebsd*|kfreebsd-gnu*) sgen_supported=true ;; mingw*) @@ -2961,6 +2972,11 @@ case "$host" in LIBC="libc.so.12" INTL="libintl.so.0" ;; + *-*-kfreebsd*-gnu) + LIBC="libc.so.0.1" + INTL="libc.so.0.1" + X11="libX11.so.6" + ;; *-*-*freebsd*) LIBC="libc.so" INTL="libintl.so" diff --git a/libgc/configure.ac b/libgc/configure.ac index 7dc04985a90..ac992abfaf9 100644 --- a/libgc/configure.ac +++ b/libgc/configure.ac @@ -114,6 +114,17 @@ case "$THREADS" in AC_DEFINE(THREAD_LOCAL_ALLOC) THREADDLLIBS="-lpthread -lrt" ;; + *-*-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) + ;; *-*-freebsd*) AC_DEFINE(GC_FREEBSD_THREADS) if test "x$PTHREAD_CFLAGS" != "x"; then diff --git a/libgc/dyn_load.c b/libgc/dyn_load.c index ca7ce54f194..5db3503aacb 100644 --- a/libgc/dyn_load.c +++ b/libgc/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(__native_client__)) && !defined(_GNU_SOURCE) +#if (defined(__linux__) || defined(__GLIBC__) || defined(__native_client__)) && !defined(_GNU_SOURCE) /* Can't test LINUX, since this must be define before other includes */ # define _GNU_SOURCE #endif @@ -394,7 +394,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) || defined(NACL)) /* Are others OK here, too? */ \ +# if (defined(LINUX) || defined (__GLIBC__) || defined(NACL)) /* Are others OK here, too? */ \ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) diff --git a/libgc/include/gc.h b/libgc/include/gc.h index 4693a3d9a54..2265fdbd34a 100644 --- a/libgc/include/gc.h +++ b/libgc/include/gc.h @@ -497,7 +497,7 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb)); # define GC_RETURN_ADDR (GC_word)__return_address #endif -#ifdef __linux__ +#if defined(__linux__) || defined(__GLIBC__) # include <features.h> # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \ && !defined(__ia64__) diff --git a/libgc/include/private/gcconfig.h b/libgc/include/private/gcconfig.h index 418e046ae12..3cbab919b94 100644 --- a/libgc/include/private/gcconfig.h +++ b/libgc/include/private/gcconfig.h @@ -55,7 +55,7 @@ # endif /* And one for FreeBSD: */ -# if defined(__FreeBSD__) && !defined(FREEBSD) +# if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(FREEBSD) # define FREEBSD # endif @@ -1371,8 +1371,15 @@ # ifndef GC_FREEBSD_THREADS # define MPROTECT_VDB # endif -# define SIG_SUSPEND SIGTSTP -# define SIG_THR_RESTART SIGCONT +# ifdef __GLIBC__ +# define SIG_SUSPEND (32+6) +# define SIG_THR_RESTART (32+5) + extern int _end[]; +# define DATAEND (_end) +# else +# define SIG_SUSPEND SIGTSTP +# define SIG_THR_RESTART SIGCONT +# endif # define FREEBSD_STACKBOTTOM # ifdef __ELF__ # define DYNAMIC_LOADING @@ -2132,8 +2139,15 @@ # ifndef GC_FREEBSD_THREADS # define MPROTECT_VDB # endif -# define SIG_SUSPEND SIGTSTP -# define SIG_THR_RESTART SIGCONT +# 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 NEED_FIND_LIMIT # define FREEBSD_STACKBOTTOM # ifdef __ELF__ @@ -2230,7 +2244,7 @@ # define SUNOS5SIGS # endif -# if defined(FREEBSD) && (__FreeBSD__ >= 4) +# if defined(FREEBSD) && ((__FreeBSD__ >= 4) || (__FreeBSD_kernel__ >= 4)) # define SUNOS5SIGS # endif @@ -2293,7 +2307,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 */ @@ -2374,7 +2388,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 diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c index d87bee7ec41..169cb07617a 100755 --- a/mono/io-layer/io.c +++ b/mono/io-layer/io.c @@ -4260,7 +4260,7 @@ guint32 GetDriveType(const gunichar2 *root_path_name) return (drive_type); } -#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) +#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__) static gchar* get_fstypename (gchar *utfpath) { diff --git a/mono/metadata/sgen-os-posix.c b/mono/metadata/sgen-os-posix.c index 3a709276a6f..909b8382c81 100644 --- a/mono/metadata/sgen-os-posix.c +++ b/mono/metadata/sgen-os-posix.c @@ -36,7 +36,7 @@ #include "metadata/object-internals.h" #include "utils/mono-signal-handler.h" -#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) +#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) const static int suspend_signal_num = SIGXFSZ; #else const static int suspend_signal_num = SIGPWR; diff --git a/mono/mini/mini-amd64.h b/mono/mini/mini-amd64.h index fbe9910b626..b7c974e3acd 100644 --- a/mono/mini/mini-amd64.h +++ b/mono/mini/mini-amd64.h @@ -309,7 +309,7 @@ typedef struct { #define MONO_ARCH_NOMAP32BIT -#elif defined (__FreeBSD__) +#elif defined (__FreeBSD__) || defined(__FreeBSD_kernel__) #define REG_RAX 7 #define REG_RCX 4 diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h index e342054fceb..05b977c547a 100644 --- a/mono/mini/mini-x86.h +++ b/mono/mini/mini-x86.h @@ -48,7 +48,7 @@ struct sigcontext { #endif /* __HAIKU__ */ #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \ - defined(__FreeBSD__) || defined(__OpenBSD__) + defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) #define MONO_ARCH_USE_SIGACTION #endif diff --git a/mono/utils/mono-sigcontext.h b/mono/utils/mono-sigcontext.h index daa82bbef37..05817a842f3 100644 --- a/mono/utils/mono-sigcontext.h +++ b/mono/utils/mono-sigcontext.h @@ -16,14 +16,14 @@ #if defined(TARGET_X86) -#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__DragonFly__) #include <ucontext.h> #endif #if defined(__APPLE__) #include <AvailabilityMacros.h> #endif -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #define UCONTEXT_REG_EAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_eax) #define UCONTEXT_REG_EBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_ebx) #define UCONTEXT_REG_ECX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_ecx) @@ -154,7 +154,7 @@ typedef struct ucontext { #elif defined(TARGET_AMD64) -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include <ucontext.h> #endif @@ -176,7 +176,7 @@ typedef struct ucontext { #define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r13) #define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r14) #define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->uc_mcontext->__ss.__r15) -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rax) #define UCONTEXT_REG_RBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rbx) #define UCONTEXT_REG_RCX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rcx) |