From 695140772fd9fd593a25811d48033e16ee5e55f5 Mon Sep 17 00:00:00 2001 From: fbrosson Date: Thu, 26 Apr 2018 00:33:35 +0000 Subject: [PATCH] boehm_gc: drop patches. --- .../boehm_gc/patches/boehm_gc-7.6.0.patchset | 362 ---------------- .../boehm_gc/patches/boehm_gc-7.6.4.patchset | 393 ------------------ 2 files changed, 755 deletions(-) delete mode 100644 dev-libs/boehm_gc/patches/boehm_gc-7.6.0.patchset delete mode 100644 dev-libs/boehm_gc/patches/boehm_gc-7.6.4.patchset diff --git a/dev-libs/boehm_gc/patches/boehm_gc-7.6.0.patchset b/dev-libs/boehm_gc/patches/boehm_gc-7.6.0.patchset deleted file mode 100644 index fd0a7d06c..000000000 --- a/dev-libs/boehm_gc/patches/boehm_gc-7.6.0.patchset +++ /dev/null @@ -1,362 +0,0 @@ -From be7dcfe5587d55097be2dd203de41bfb95be86f6 Mon Sep 17 00:00:00 2001 -From: "Joseph C, Hill" -Date: Thu, 6 Apr 2017 21:58:07 +0000 -Subject: [PATCH] Haiku patches for x86_64 - ---- - configure.ac | 5 ++++ - dyn_load.c | 17 ++++++++++- - include/config.h.in | 3 ++ - include/gc_config_macros.h | 5 ++-- - include/private/gcconfig.h | 37 ++++++++++++++++++++++-- - include/private/thread_local_alloc.h | 2 +- - os_dep.c | 56 ++++++++++++++++++++++++++---------- - pthread_stop_world.c | 2 +- - pthread_support.c | 2 +- - 9 files changed, 106 insertions(+), 23 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 3763c23..99e633d 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -137,6 +137,7 @@ AH_TEMPLATE([GC_AIX_THREADS], [Define to support IBM AIX threads.]) - AH_TEMPLATE([GC_DARWIN_THREADS], [Define to support Darwin pthreads.]) - AH_TEMPLATE([GC_FREEBSD_THREADS], [Define to support FreeBSD pthreads.]) - AH_TEMPLATE([GC_GNU_THREADS], [Define to support GNU pthreads.]) -+AH_TEMPLATE([GC_HAIKU_THREADS], [Define to support Haiku pthreads.]) - AH_TEMPLATE([GC_HPUX_THREADS], [Define to support HP/UX 11 pthreads.]) - AH_TEMPLATE([GC_IRIX_THREADS], [Define to support Irix pthreads.]) - AH_TEMPLATE([GC_LINUX_THREADS], [Define to support pthreads on Linux.]) -@@ -195,6 +196,10 @@ case "$THREADS" in - AC_DEFINE(GC_AIX_THREADS) - AC_DEFINE(_REENTRANT) - ;; -+ *-*-haiku*) -+ AC_DEFINE(GC_HAIKU_THREADS) -+ AC_DEFINE(_REENTRANT) -+ ;; - *-*-hpux11*) - AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.") - AC_DEFINE(GC_HPUX_THREADS) -diff --git a/dyn_load.c b/dyn_load.c -index 614f1d1..a2fd107 100644 ---- a/dyn_load.c -+++ b/dyn_load.c -@@ -55,7 +55,7 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0; - #if !defined(DARWIN) && !defined(SCO_ELF) && !defined(SOLARISDL) \ - && !defined(AIX) && !defined(DGUX) && !defined(IRIX5) && !defined(HPUX) \ - && !defined(CYGWIN32) && !defined(MSWIN32) && !defined(MSWINCE) \ -- && !(defined(ALPHA) && defined(OSF1)) \ -+ && !(defined(ALPHA) && defined(OSF1)) && !defined(HAIKU) \ - && !(defined(FREEBSD) && defined(__ELF__)) \ - && !((defined(LINUX) || defined(NACL)) && defined(__ELF__)) \ - && !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) \ -@@ -1480,7 +1480,22 @@ GC_INNER GC_bool GC_register_main_static_data(void) - } - - #endif /* DARWIN */ -+#ifdef HAIKU -+#include - -+GC_INNER void GC_register_dynamic_libraries() -+{ -+ image_info info; -+ int32 cookie = 0; -+ while (get_next_image_info(0, &cookie, &info) == B_OK) -+ { -+ void *data = info.data; -+ GC_add_roots_inner(data, data + info.data_size, TRUE); -+ } -+} -+ -+#endif -+/* HAIKU */ - #elif defined(PCR) - - # include "il/PCR_IL.h" -diff --git a/include/config.h.in b/include/config.h.in -index fc0667e..33b626f 100644 ---- a/include/config.h.in -+++ b/include/config.h.in -@@ -51,6 +51,9 @@ - /* Define to support GNU pthreads. */ - #undef GC_GNU_THREADS - -+/* Define to support Haiku pthreads. */ -+#undef GC_HAIKU_THREADS -+ - /* Define if backtrace information is supported. */ - #undef GC_HAVE_BUILTIN_BACKTRACE - -diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h -index 0009b7b..7d98313 100644 ---- a/include/gc_config_macros.h -+++ b/include/gc_config_macros.h -@@ -68,7 +68,8 @@ - || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \ - || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \ - || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \ -- || defined(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS) -+ || defined(GC_WIN32_THREADS) || defined(GC_RTEMS_PTHREADS) \ -+ || defined(GC_HAIKU_THREADS) - # ifndef GC_THREADS - # define GC_THREADS - # endif -@@ -321,7 +322,7 @@ - /* retrieve the call chain. */ - #if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) \ - || defined(__FreeBSD__) || defined(__DragonFly__) \ -- || defined(PLATFORM_ANDROID) || defined(__ANDROID__)) \ -+ || defined(PLATFORM_ANDROID) || defined(__ANDROID__)) || defined(__HAIKU__)\ - && !defined(GC_CAN_SAVE_CALL_STACKS) - # define GC_ADD_CALLER - # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) -diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h -index 59216ed..f8fdad6 100644 ---- a/include/private/gcconfig.h -+++ b/include/private/gcconfig.h -@@ -282,6 +282,16 @@ - # define BEOS - # define mach_type_known - # endif -+# if defined(__HAIKU__) && defined(_X86_) -+# define I386 -+# define HAIKU -+# define mach_type_known -+# endif -+# if defined(__HAIKU__) && defined(__x86_64__) -+# define X86_64 -+# define HAIKU -+# define mach_type_known -+# endif - # if defined(OPENBSD) && defined(__amd64__) - # define X86_64 - # define mach_type_known -@@ -1252,6 +1262,13 @@ - extern int etext[]; - # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff)) - # endif -+# ifdef HAIKU -+# define OS_TYPE "HAIKU" -+# include -+# define GETPAGESIZE() B_PAGE_SIZE -+ extern int etext[]; -+# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) -+# endif - # ifdef SOLARIS - # define OS_TYPE "SOLARIS" - extern int _etext[], _end[]; -@@ -2463,6 +2480,19 @@ - # define NO_DYLD_BIND_FULLY_IMAGE - # endif - # endif -+# ifdef HAIKU -+# define OS_TYPE "HAIKU" -+# include -+# define GETPAGESIZE() B_PAGE_SIZE -+ extern int etext[]; -+# define SEARCH_FOR_DATA_START -+# define HEURISTIC2 -+# ifndef USE_MMAP -+# define USE_MMAP -+# endif -+# define DYNAMIC_LOADING -+# define MPROTECT_VDB -+# endif - # ifdef FREEBSD - # define OS_TYPE "FREEBSD" - # ifndef GC_FREEBSD_THREADS -@@ -2779,7 +2809,7 @@ - #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) -+ || defined(AIX) || defined(DARWIN) || defined(OSF1) || defined(HAIKU) - # define UNIX_LIKE /* Basic Unix-like system calls work. */ - #endif - -@@ -2880,7 +2910,7 @@ - - #if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HURD) \ - || defined(OPENBSD) || defined(ARM32) \ -- || defined(MIPS) || defined(AVR32) \ -+ || defined(MIPS) || defined(AVR32) || defined(HAIKU) \ - || defined(OR1K) || defined(NIOS2))) \ - || (defined(LINUX) && !defined(__gnu_linux__)) \ - || (defined(RTEMS) && defined(I386)) || defined(PLATFORM_ANDROID)) \ -@@ -3221,6 +3251,9 @@ - # elif defined(SN_TARGET_PS3) - void *ps3_get_mem(size_t bytes); - # define GET_MEM(bytes) (struct hblk*)ps3_get_mem(bytes) -+# elif defined(HAIKU) -+ ptr_t GC_haiku_get_mem(GC_word bytes); -+# define GET_MEM(bytes) (struct hblk*)GC_haiku_get_mem(bytes) - # else - ptr_t GC_unix_get_mem(GC_word bytes); - # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes) -diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h -index 3b44a1e..9096013 100644 ---- a/include/private/thread_local_alloc.h -+++ b/include/private/thread_local_alloc.h -@@ -59,7 +59,7 @@ - # elif defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) \ - || defined(GC_AIX_THREADS) || defined(GC_DARWIN_THREADS) \ - || defined(GC_FREEBSD_THREADS) || defined(GC_NETBSD_THREADS) \ -- || defined(GC_LINUX_THREADS) || defined(GC_RTEMS_PTHREADS) -+ || defined(GC_LINUX_THREADS) || defined(GC_RTEMS_PTHREADS) || defined(GC_HAIKU_THREADS) - # define USE_PTHREAD_SPECIFIC - # elif defined(GC_HPUX_THREADS) - # ifdef __GNUC__ -diff --git a/os_dep.c b/os_dep.c -index 41ca5fb..62a3ba6 100644 ---- a/os_dep.c -+++ b/os_dep.c -@@ -798,7 +798,7 @@ GC_INNER word GC_page_size = 0; - } - #endif /* !MSWIN32 */ - --#ifdef BEOS -+#if defined(BEOS) || defined(HAIKU) - # include - - GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb) -@@ -809,7 +809,7 @@ GC_INNER word GC_page_size = 0; - return GC_SUCCESS; - } - # define HAVE_GET_STACK_BASE --#endif /* BEOS */ -+#endif /* BEOS || HAIKU */ - - #ifdef OS2 - GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb) -@@ -1152,9 +1152,9 @@ GC_INNER word GC_page_size = 0; - return (ptr_t)GC_get_main_symbian_stack_base(); - } - # define GET_MAIN_STACKBASE_SPECIAL --#elif !defined(BEOS) && !defined(AMIGA) && !defined(OS2) \ -+#elif !defined(BEOS) && !defined(__HAIKU__) && !defined(AMIGA) && !defined(OS2) \ - && !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) \ -- && !defined(GC_OPENBSD_THREADS) \ -+ && !defined(GC_OPENBSD_THREADS) && !defined(HAIKU) \ - && (!defined(GC_SOLARIS_THREADS) || defined(_STRICT_STDC)) - - # if defined(LINUX) && defined(USE_GET_STACKBASE_FOR_MAIN) -@@ -1242,6 +1242,15 @@ GC_INNER word GC_page_size = 0; - # define GET_MAIN_STACKBASE_SPECIAL - #endif /* !AMIGA, !BEOS, !OPENBSD, !OS2, !Windows */ - -+# ifdef HAIKU -+# include -+ptr_t GC_get_main_stack_base(void){ -+ thread_info th; -+ get_thread_info(find_thread(NULL),&th); -+ return th.stack_end; -+} -+ -+# endif /* HAIKU */ - #if (defined(GC_LINUX_THREADS) || defined(PLATFORM_ANDROID)) \ - && !defined(NO_PTHREAD_GETATTR_NP) - -@@ -1433,15 +1442,15 @@ GC_INNER word GC_page_size = 0; - - #ifndef GET_MAIN_STACKBASE_SPECIAL - /* This is always called from the main thread. Default implementation. */ -- ptr_t GC_get_main_stack_base(void) -- { -- struct GC_stack_base sb; -- -- if (GC_get_stack_base(&sb) != GC_SUCCESS) -- ABORT("GC_get_stack_base failed"); -- GC_ASSERT((word)GC_approx_sp() HOTTER_THAN (word)sb.mem_base); -- return (ptr_t)sb.mem_base; -- } -+// ptr_t GC_get_main_stack_base(void) -+// { -+// struct GC_stack_base sb; -+ -+// if (GC_get_stack_base(&sb) != GC_SUCCESS) -+// ABORT("GC_get_stack_base failed"); -+// GC_ASSERT((word)GC_approx_sp() HOTTER_THAN (word)sb.mem_base); -+// return (ptr_t)sb.mem_base; -+// } - #endif /* !GET_MAIN_STACKBASE_SPECIAL */ - - /* Register static data segment(s) as roots. If more data segments are */ -@@ -1990,7 +1999,7 @@ void GC_register_data_segments(void) - # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \ - && !defined(USE_WINALLOC) && !defined(MACOS) && !defined(DOS4GW) \ - && !defined(NONSTOP) && !defined(SN_TARGET_PS3) && !defined(RTEMS) \ -- && !defined(__CC_ARM) -+ && !defined(__CC_ARM) && !defined(HAIKU) - - # define SBRK_ARG_T ptrdiff_t - -@@ -2333,6 +2342,19 @@ void * os2_alloc(size_t bytes) - # undef GC_AMIGA_AM - #endif - -+#ifdef HAIKU -+#include -+ -+ptr_t GC_haiku_get_mem(word bytes) -+{ -+ void* mem; -+ if (posix_memalign(&mem, GC_page_size, bytes) == 0) -+ return mem; -+ else -+ return NULL; -+} -+#endif -+ - #ifdef USE_MUNMAP - - /* For now, this only works on Win32/WinCE and some Unix-like */ -@@ -2929,7 +2951,9 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) - # elif !defined(USE_WINALLOC) - # include - # include --# include -+# if !defined(HAIKU) -+# include -+# endif - - # define PROTECT(addr, len) \ - if (mprotect((caddr_t)(addr), (size_t)(len), \ -@@ -3096,6 +3120,8 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) - /* Empirically c.trapno == 14, on IA32, but is that useful? */ - /* Should probably consider alignment issues on other */ - /* architectures. */ -+# elif defined(HAIKU) -+# define CODE_OK TRUE - # elif defined(HPUX) - # define CODE_OK (si -> si_code == SEGV_ACCERR \ - || si -> si_code == BUS_ADRERR \ -diff --git a/pthread_stop_world.c b/pthread_stop_world.c -index dad1fdc..a1f77fc 100644 ---- a/pthread_stop_world.c -+++ b/pthread_stop_world.c -@@ -46,7 +46,7 @@ - #include - #include - #include "atomic_ops.h" -- -+# include - /* It's safe to call original pthread_sigmask() here. */ - #undef pthread_sigmask - -diff --git a/pthread_support.c b/pthread_support.c -index fe89790..a8720af 100644 ---- a/pthread_support.c -+++ b/pthread_support.c -@@ -842,7 +842,7 @@ STATIC void GC_remove_all_threads_but_me(void) - - #elif defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) \ - || defined(GC_SOLARIS_THREADS) || defined(GC_GNU_THREADS) \ -- || defined(PLATFORM_ANDROID) || defined(NACL) -+ || defined(PLATFORM_ANDROID) || defined(NACL) || defined(GC_HAIKU_THREADS) - GC_INLINE int GC_get_nprocs(void) - { - int nprocs = (int)sysconf(_SC_NPROCESSORS_ONLN); --- -2.11.0 - diff --git a/dev-libs/boehm_gc/patches/boehm_gc-7.6.4.patchset b/dev-libs/boehm_gc/patches/boehm_gc-7.6.4.patchset deleted file mode 100644 index 7ed3d8213..000000000 --- a/dev-libs/boehm_gc/patches/boehm_gc-7.6.4.patchset +++ /dev/null @@ -1,393 +0,0 @@ -From 82f5e61273486a041abc72991fe0cdf8441efbdc Mon Sep 17 00:00:00 2001 -From: "Joseph C, Hill" -Date: Fri, 16 Feb 2018 11:08:51 +0300 -Subject: [PATCH 1/2] Haiku patches for x86_64 - ---- - configure.ac | 5 +++++ - dyn_load.c | 18 +++++++++++++++++- - include/gc_config_macros.h | 7 +++++-- - include/private/gcconfig.h | 37 +++++++++++++++++++++++++++++------- - include/private/thread_local_alloc.h | 3 ++- - os_dep.c | 36 ++++++++++++++++++++++++++--------- - pthread_support.c | 4 ++-- - 7 files changed, 88 insertions(+), 22 deletions(-) - -diff --git a/configure.ac b/configure.ac -index da9cded0..67d9a6f3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -140,6 +140,7 @@ AH_TEMPLATE([GC_AIX_THREADS], [Define to support IBM AIX threads.]) - AH_TEMPLATE([GC_DARWIN_THREADS], [Define to support Darwin pthreads.]) - AH_TEMPLATE([GC_FREEBSD_THREADS], [Define to support FreeBSD pthreads.]) - AH_TEMPLATE([GC_GNU_THREADS], [Define to support GNU pthreads.]) -+AH_TEMPLATE([GC_HAIKU_THREADS], [Define to support Haiku pthreads.]) - AH_TEMPLATE([GC_HPUX_THREADS], [Define to support HP/UX 11 pthreads.]) - AH_TEMPLATE([GC_IRIX_THREADS], [Define to support Irix pthreads.]) - AH_TEMPLATE([GC_LINUX_THREADS], [Define to support pthreads on Linux.]) -@@ -201,6 +202,10 @@ case "$THREADS" in - AC_DEFINE(GC_AIX_THREADS) - AC_DEFINE(_REENTRANT) - ;; -+ *-*-haiku*) -+ AC_DEFINE(GC_HAIKU_THREADS) -+ AC_DEFINE(_REENTRANT) -+ ;; - *-*-hpux11*) - AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.") - AC_DEFINE(GC_HPUX_THREADS) -diff --git a/dyn_load.c b/dyn_load.c -index 0f36f777..b83dcb71 100644 ---- a/dyn_load.c -+++ b/dyn_load.c -@@ -58,7 +58,8 @@ STATIC GC_has_static_roots_func GC_has_static_roots = 0; - && !(defined(ALPHA) && defined(OSF1)) \ - && !(defined(FREEBSD) && defined(__ELF__)) \ - && !((defined(LINUX) || defined(NACL)) && defined(__ELF__)) \ -- && !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) \ -+ && !(defined(NETBSD) && defined(__ELF__)) \ -+ && !defined(HAIKU) && !defined(HURD) \ - && !(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) \ - && !defined(CPPCHECK) - # error We only know how to find data segments of dynamic libraries for above. -@@ -1490,6 +1491,21 @@ GC_INNER GC_bool GC_register_main_static_data(void) - - #endif /* DARWIN */ - -+#if defined(HAIKU) -+# include -+ -+ GC_INNER void GC_register_dynamic_libraries(void) -+ { -+ image_info info; -+ int32 cookie = 0; -+ -+ while (get_next_image_info(0, &cookie, &info) == B_OK) { -+ ptr_t data = (ptr_t)info.data; -+ GC_add_roots_inner(data, data + info.data_size, TRUE); -+ } -+ } -+#endif /* HAIKU */ -+ - #elif defined(PCR) - - # include "il/PCR_IL.h" -diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h -index e8748f5d..2c76f4a9 100644 ---- a/include/gc_config_macros.h -+++ b/include/gc_config_macros.h -@@ -64,7 +64,8 @@ - - #if defined(GC_AIX_THREADS) || defined(GC_DARWIN_THREADS) \ - || defined(GC_DGUX386_THREADS) || defined(GC_FREEBSD_THREADS) \ -- || defined(GC_GNU_THREADS) || defined(GC_HPUX_THREADS) \ -+ || defined(GC_GNU_THREADS) \ -+ || defined(GC_HAIKU_THREADS) || defined(GC_HPUX_THREADS) \ - || defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \ - || defined(GC_NETBSD_THREADS) || defined(GC_OPENBSD_THREADS) \ - || defined(GC_OSF1_THREADS) || defined(GC_SOLARIS_THREADS) \ -@@ -94,6 +95,8 @@ - # define GC_SOLARIS_THREADS - # elif defined(__APPLE__) && defined(__MACH__) - # define GC_DARWIN_THREADS -+# elif defined(__HAIKU__) -+# define GC_HAIKU_THREADS - # elif defined(__OpenBSD__) - # define GC_OPENBSD_THREADS - # elif !defined(GC_LINUX_THREADS) && !defined(GC_HPUX_THREADS) \ -@@ -321,7 +324,7 @@ - /* 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(__DragonFly__) \ -+ || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__HAIKU__) \ - || defined(PLATFORM_ANDROID) || defined(__ANDROID__)) \ - && !defined(GC_CAN_SAVE_CALL_STACKS) - # define GC_ADD_CALLER -diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h -index ffbdc142..7b05f4ee 100644 ---- a/include/private/gcconfig.h -+++ b/include/private/gcconfig.h -@@ -288,9 +288,14 @@ - # endif - # define mach_type_known - # endif --# if defined(__BEOS__) && defined(_X86_) -+# if (defined(__BEOS__) || defined(__HAIKU__)) && defined(_X86_) - # define I386 --# define BEOS -+# define HAIKU -+# define mach_type_known -+# endif -+# if defined(__HAIKU__) && (defined(__amd64__) || defined(__x86_64__)) -+# define X86_64 -+# define HAIKU - # define mach_type_known - # endif - # if defined(OPENBSD) && defined(__amd64__) -@@ -1268,12 +1273,14 @@ - # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff)) - # define STACKBOTTOM ((ptr_t)0x3ffff000) - # endif --# ifdef BEOS --# define OS_TYPE "BEOS" -+# ifdef HAIKU -+# define OS_TYPE "HAIKU" - # include - # define GETPAGESIZE() (unsigned)B_PAGE_SIZE - extern int etext[]; - # define DATASTART ((ptr_t)((((word)(etext)) + 0xfff) & ~0xfff)) -+# define DYNAMIC_LOADING -+# define MPROTECT_VDB - # endif - # ifdef SOLARIS - # define OS_TYPE "SOLARIS" -@@ -2532,6 +2539,18 @@ - # define SEARCH_FOR_DATA_START - # endif - # endif -+# ifdef HAIKU -+# define OS_TYPE "HAIKU" -+# include -+# define GETPAGESIZE() (unsigned)B_PAGE_SIZE -+# define SEARCH_FOR_DATA_START -+# define HEURISTIC2 -+# ifndef USE_MMAP -+# define USE_MMAP -+# endif -+# define DYNAMIC_LOADING -+# define MPROTECT_VDB -+# endif - # ifdef SOLARIS - # define OS_TYPE "SOLARIS" - # define ELF_CLASS ELFCLASS64 -@@ -2796,7 +2815,7 @@ - - #if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \ - || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \ -- || defined(DGUX) || defined(BSD) || defined(HURD) \ -+ || defined(DGUX) || defined(BSD) || defined(HAIKU) || defined(HURD) \ - || defined(AIX) || defined(DARWIN) || defined(OSF1) - # define UNIX_LIKE /* Basic Unix-like system calls work. */ - #endif -@@ -2906,9 +2925,10 @@ - # define DEFAULT_VDB - #endif - --#if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HURD) \ -+#if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HAIKU) \ -+ || defined(HURD) \ - || defined(OPENBSD) || defined(ARM32) \ -- || defined(MIPS) || defined(AVR32) \ -+ || defined(AVR32) || defined(MIPS) \ - || defined(OR1K) || defined(NIOS2))) \ - || (defined(LINUX) && !defined(__gnu_linux__)) \ - || (defined(RTEMS) && defined(I386)) || defined(PLATFORM_ANDROID)) \ -@@ -3330,6 +3350,9 @@ - # elif defined(SN_TARGET_PS3) - void *ps3_get_mem(size_t bytes); - # define GET_MEM(bytes) (struct hblk*)ps3_get_mem(bytes) -+# elif defined(HAIKU) -+ ptr_t GC_haiku_get_mem(size_t bytes); -+# define GET_MEM(bytes) (struct hblk*)GC_haiku_get_mem(bytes) - # else - ptr_t GC_unix_get_mem(size_t bytes); - # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes) -diff --git a/include/private/thread_local_alloc.h b/include/private/thread_local_alloc.h -index 7e7627c7..36e8c6d7 100644 ---- a/include/private/thread_local_alloc.h -+++ b/include/private/thread_local_alloc.h -@@ -59,7 +59,8 @@ - # elif defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) \ - || defined(GC_AIX_THREADS) || defined(GC_DARWIN_THREADS) \ - || defined(GC_FREEBSD_THREADS) || defined(GC_NETBSD_THREADS) \ -- || defined(GC_LINUX_THREADS) || defined(GC_RTEMS_PTHREADS) -+ || defined(GC_LINUX_THREADS) || defined(GC_HAIKU_THREADS) \ -+ || defined(GC_RTEMS_PTHREADS) - # define USE_PTHREAD_SPECIFIC - # elif defined(GC_HPUX_THREADS) - # ifdef __GNUC__ -diff --git a/os_dep.c b/os_dep.c -index d3429d04..28c2773c 100644 ---- a/os_dep.c -+++ b/os_dep.c -@@ -829,7 +829,7 @@ GC_INNER size_t GC_page_size = 0; - } - #endif /* !MSWIN32 */ - --#ifdef BEOS -+#ifdef HAIKU - # include - - GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb) -@@ -840,7 +840,7 @@ GC_INNER size_t GC_page_size = 0; - return GC_SUCCESS; - } - # define HAVE_GET_STACK_BASE --#endif /* BEOS */ -+#endif /* HAIKU */ - - #ifdef OS2 - GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb) -@@ -869,7 +869,8 @@ GC_INNER size_t GC_page_size = 0; - typedef void (*GC_fault_handler_t)(int); - - # if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \ -- || defined(HURD) || defined(FREEBSD) || defined(NETBSD) -+ || defined(HAIKU) || defined(HURD) || defined(FREEBSD) \ -+ || defined(NETBSD) - static struct sigaction old_segv_act; - # if defined(_sigargs) /* !Irix6.x */ \ - || defined(HURD) || defined(NETBSD) || defined(FREEBSD) -@@ -885,7 +886,8 @@ GC_INNER size_t GC_page_size = 0; - GC_INNER void GC_set_and_save_fault_handler(GC_fault_handler_t h) - { - # if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \ -- || defined(HURD) || defined(FREEBSD) || defined(NETBSD) -+ || defined(HAIKU) || defined(HURD) || defined(FREEBSD) \ -+ || defined(NETBSD) - struct sigaction act; - - act.sa_handler = h; -@@ -949,7 +951,8 @@ GC_INNER size_t GC_page_size = 0; - GC_INNER void GC_reset_fault_handler(void) - { - # if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \ -- || defined(HURD) || defined(FREEBSD) || defined(NETBSD) -+ || defined(HAIKU) || defined(HURD) || defined(FREEBSD) \ -+ || defined(NETBSD) - (void) sigaction(SIGSEGV, &old_segv_act, 0); - # if defined(IRIX5) && defined(_sigargs) /* Irix 5.x, not 6.x */ \ - || defined(HURD) || defined(NETBSD) -@@ -1190,7 +1193,7 @@ GC_INNER size_t GC_page_size = 0; - return (ptr_t)GC_get_main_symbian_stack_base(); - } - # define GET_MAIN_STACKBASE_SPECIAL --#elif !defined(BEOS) && !defined(AMIGA) && !defined(OS2) \ -+#elif !defined(AMIGA) && !defined(HAIKU) && !defined(OS2) \ - && !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) \ - && !defined(GC_OPENBSD_THREADS) \ - && (!defined(GC_SOLARIS_THREADS) || defined(_STRICT_STDC)) -@@ -1291,7 +1294,7 @@ GC_INNER size_t GC_page_size = 0; - return(result); - } - # define GET_MAIN_STACKBASE_SPECIAL --#endif /* !AMIGA, !BEOS, !OPENBSD, !OS2, !Windows */ -+#endif /* !AMIGA, !HAIKU, !OPENBSD, !OS2, !Windows */ - - #if (defined(HAVE_PTHREAD_ATTR_GET_NP) || defined(HAVE_PTHREAD_GETATTR_NP)) \ - && defined(THREADS) && !defined(HAVE_GET_STACK_BASE) -@@ -2425,6 +2428,19 @@ void * os2_alloc(size_t bytes) - # undef GC_AMIGA_AM - #endif - -+#if defined(HAIKU) -+# include -+ ptr_t GC_haiku_get_mem(size_t bytes) -+ { -+ void* mem; -+ -+ GC_ASSERT(GC_page_size != 0); -+ if (posix_memalign(&mem, GC_page_size, bytes) == 0) -+ return mem; -+ return NULL; -+ } -+#endif /* HAIKU */ -+ - #ifdef USE_MUNMAP - - /* For now, this only works on Win32/WinCE and some Unix-like */ -@@ -3021,7 +3037,9 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) - # elif !defined(USE_WINALLOC) - # include - # include --# include -+# if !defined(HAIKU) -+# include -+# endif - - # define PROTECT(addr, len) \ - if (mprotect((caddr_t)(addr), (size_t)(len), \ -@@ -3181,7 +3199,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) - # define CODE_OK (si -> si_code == 2 /* experimentally determined */) - # elif defined(IRIX5) - # define CODE_OK (si -> si_code == EACCES) --# elif defined(HURD) -+# elif defined(HAIKU) || defined(HURD) - # define CODE_OK TRUE - # elif defined(LINUX) - # define CODE_OK TRUE -diff --git a/pthread_support.c b/pthread_support.c -index 335e6ebb..48e8b418 100644 ---- a/pthread_support.c -+++ b/pthread_support.c -@@ -873,8 +873,8 @@ STATIC void GC_remove_all_threads_but_me(void) - # define GC_get_nprocs() pthread_num_processors_np() - - #elif defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) \ -- || defined(GC_SOLARIS_THREADS) || defined(GC_GNU_THREADS) \ -- || defined(PLATFORM_ANDROID) || defined(NACL) -+ || defined(GC_HAIKU_THREADS) || defined(GC_SOLARIS_THREADS) \ -+ || defined(GC_GNU_THREADS) || defined(PLATFORM_ANDROID) || defined(NACL) - GC_INLINE int GC_get_nprocs(void) - { - int nprocs = (int)sysconf(_SC_NPROCESSORS_ONLN); --- -2.16.1 - -From 0057c5d11ee910704aa4fa76ab2c028fe06c8699 Mon Sep 17 00:00:00 2001 -From: Ivan Maidanski -Date: Tue, 6 Mar 2018 23:55:33 +0300 -Subject: [PATCH 2/2] Haiku workarounds for EACCES returned by sem_wait and for - ESRCH returned by pthread_join - ---- - pthread_support.c | 4 ++++ - tests/subthread_create.c | 9 +++++++++ - 2 files changed, 13 insertions(+) - -diff --git a/pthread_support.c b/pthread_support.c -index 48e8b418..7fda8fa1 100644 ---- a/pthread_support.c -+++ b/pthread_support.c -@@ -1870,6 +1870,10 @@ GC_API int WRAP_FUNC(pthread_create)(pthread_t *new_thread, - DISABLE_CANCEL(cancel_state); - /* pthread_create is not a cancellation point. */ - while (0 != sem_wait(&(si -> registered))) { -+# if defined(GC_HAIKU_THREADS) -+ /* To workaround some bug in Haiku semaphores. */ -+ if (EACCES == errno) continue; -+# endif - if (EINTR != errno) ABORT("sem_wait failed"); - } - RESTORE_CANCEL(cancel_state); -diff --git a/tests/subthread_create.c b/tests/subthread_create.c -index e30eae53..b60912ad 100644 ---- a/tests/subthread_create.c -+++ b/tests/subthread_create.c -@@ -24,6 +24,10 @@ - # include - #endif - -+#if defined(__HAIKU__) -+# include -+#endif -+ - #include - #include - -@@ -125,6 +129,11 @@ int main(void) - err = pthread_join(th[i], &res); - if (err) { - fprintf(stderr, "Failed to join thread: %s\n", strerror(err)); -+# if defined(__HAIKU__) -+ /* The error is just ignored (and the test is ended) to */ -+ /* workaround some bug in Haiku pthread_join. */ -+ if (ESRCH == err) break; -+# endif - exit(1); - } - # else --- -2.16.1 -