diff --git a/dev-libs/boehm_gc/boehm_gc-7.2d.recipe b/dev-libs/boehm_gc/boehm_gc-7.6.0.recipe similarity index 56% rename from dev-libs/boehm_gc/boehm_gc-7.2d.recipe rename to dev-libs/boehm_gc/boehm_gc-7.6.0.recipe index 7ea008620..f7be613b1 100644 --- a/dev-libs/boehm_gc/boehm_gc-7.2d.recipe +++ b/dev-libs/boehm_gc/boehm_gc-7.6.0.recipe @@ -1,24 +1,24 @@ SUMMARY="The Boehm-Demers-Weiser conservative garbage collector" -DESCRIPTION=" -The Boehm-Demers-Weiser conservative garbage collector can be used as a \ -garbage collecting replacement for C malloc or C++ new. It allows you to \ -allocate memory basically as you normally would, without explicitly \ +DESCRIPTION="The Boehm-Demers-Weiser conservative garbage collector can be \ +used as a garbage collecting replacement for C malloc or C++ new. It allows \ +you to allocate memory basically as you normally would, without explicitly \ deallocating memory that is no longer useful. The collector automatically \ -recycles memory when it determines that it can no longer be otherwise accessed." +recycles memory when it determines that it can no longer be otherwise \ +accessed." HOMEPAGE="http://www.hboehm.info/gc/" COPYRIGHT="1988, 1989 Hans-J. Boehm, Alan J. Demers 1991-1996 Xerox Corporation. 1996-1999 Silicon Graphics. 1999-2011 Hewlett-Packard Development Company, L.P." LICENSE="BOEHM" -REVISION="3" -SOURCE_URI="http://www.hboehm.info/gc/gc_source/gc-7.2d.tar.gz" -CHECKSUM_SHA256="d9fe0ae8650d43746a48bfb394cab01a319f3809cee19f8ebd16aa985b511c5e" -SOURCE_DIR="gc-7.2" -PATCHES="boehm_gc-7.2d.patch" +REVISION="1" +SOURCE_URI="http://www.hboehm.info/gc/gc_source/gc-$portVersion.tar.gz" +CHECKSUM_SHA256="a14a28b1129be90e55cd6f71127ffc5594e1091d5d54131528c24cd0c03b7d90" +SOURCE_DIR="gc-$portVersion" +PATCHES="boehm_gc-$portVersion.patchset" -ARCHITECTURES="x86 x86_gcc2 x86_64" -SECONDARY_ARCHITECTURES="x86 x86_gcc2" +ARCHITECTURES="?x86 ?x86_gcc2 x86_64" +SECONDARY_ARCHITECTURES="?x86 ?x86_gcc2" PROVIDES=" boehm_gc$secondaryArchSuffix = $portVersion compat >= 7 @@ -27,6 +27,7 @@ PROVIDES=" " REQUIRES=" haiku$secondaryArchSuffix + lib:libatomic_ops${secondaryArchSuffix} " PROVIDES_devel=" @@ -38,7 +39,10 @@ REQUIRES_devel=" boehm_gc${secondaryArchSuffix} == $portVersion base " -BUILD_REQUIRES="" +BUILD_REQUIRES=" + haiku${secondaryArchSuffix}_devel + devel:libatomic_ops$secondaryArchSuffix + " BUILD_PREREQUIRES=" haiku${secondaryArchSuffix}_devel cmd:libtoolize$secondaryArchSuffix @@ -46,15 +50,19 @@ BUILD_PREREQUIRES=" cmd:make cmd:gcc$secondaryArchSuffix cmd:ld$secondaryArchSuffix + cmd:pkg_config$secondaryArchSuffix " BUILD() { - libtoolize --force --copy --install + libtoolize -fci autoconf -f - runConfigure ./configure --enable-threads=posix \ - --enable-thread-local-alloc --enable-parallel-mark - make + runConfigure ./configure --enable-large-config \ + --enable-threads=posix \ + --enable-thread-local-alloc \ + --enable-parallel-mark \ + --disable-debug + make $jobArgs } INSTALL() @@ -67,5 +75,5 @@ INSTALL() TEST() { - make check + make check -e CFLAGS+="-fPIC" } diff --git a/dev-libs/boehm_gc/patches/boehm_gc-7.2d.patch b/dev-libs/boehm_gc/patches/boehm_gc-7.2d.patch deleted file mode 100644 index 4d2b35488..000000000 --- a/dev-libs/boehm_gc/patches/boehm_gc-7.2d.patch +++ /dev/null @@ -1,248 +0,0 @@ -diff -urN gc-7.2/configure.ac gc-7.2-haiku/configure.ac ---- gc-7.2/configure.ac 2012-08-09 13:25:13.047185920 -0700 -+++ gc-7.2-haiku/configure.ac 2013-03-27 00:43:42.665321472 -0700 -@@ -89,6 +89,7 @@ - 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.]) -@@ -140,6 +141,10 @@ - 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 -urN gc-7.2/dyn_load.c gc-7.2-haiku/dyn_load.c ---- gc-7.2/dyn_load.c 2012-08-09 13:25:13.034603008 -0700 -+++ gc-7.2-haiku/dyn_load.c 2013-03-27 00:43:42.670564352 -0700 -@@ -63,7 +63,7 @@ - !(defined(FREEBSD) && defined(__ELF__)) && \ - !(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) && \ - !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \ -- !defined(DARWIN) && !defined(CYGWIN32) -+ !defined(DARWIN) && !defined(CYGWIN32) && !defined(HAIKU) - --> We only know how to find data segments of dynamic libraries for the - --> above. Additional SVR4 variants might not be too - --> hard to add. -@@ -1426,6 +1426,22 @@ - - #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 -urN gc-7.2/include/gc_config_macros.h gc-7.2-haiku/include/gc_config_macros.h ---- gc-7.2/include/gc_config_macros.h 2012-08-09 13:25:13.028835840 -0700 -+++ gc-7.2-haiku/include/gc_config_macros.h 2013-03-27 00:51:21.900726784 -0700 -@@ -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 -diff -urN gc-7.2/include/private/config.h.in gc-7.2-haiku/include/private/config.h.in ---- gc-7.2/include/private/config.h.in 2012-08-09 13:25:13.029884416 -0700 -+++ gc-7.2-haiku/include/private/config.h.in 2013-03-27 00:44:56.633602048 -0700 -@@ -48,6 +48,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 -urN gc-7.2/include/private/gcconfig.h gc-7.2-haiku/include/private/gcconfig.h ---- gc-7.2/include/private/gcconfig.h 2012-08-09 13:25:13.030408704 -0700 -+++ gc-7.2-haiku/include/private/gcconfig.h 2013-03-27 00:45:52.350748672 -0700 -@@ -234,6 +234,11 @@ - # define BEOS - # define mach_type_known - # endif -+# if defined(__HAIKU__) && defined(_X86_) -+# define I386 -+# define HAIKU -+# define mach_type_known -+# endif - # if defined(OPENBSD) && defined(__amd64__) - # define X86_64 - # define mach_type_known -@@ -1115,6 +1120,15 @@ - 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)) -+# define DYNAMIC_LOADING -+# define MPROTECT_VDB -+# endif - # ifdef SOLARIS - # define OS_TYPE "SOLARIS" - extern int _etext[], _end[]; -@@ -2404,7 +2418,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 - -@@ -2482,7 +2496,8 @@ - - #if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HURD) \ - || defined(OPENBSD) || defined(ARM32) \ -- || defined(MIPS) || defined(AVR32))) \ -+ || defined(MIPS) || defined(AVR32) \ -+ || defined(HAIKU))) \ - || (defined(LINUX) && (defined(SPARC) || defined(M68K))) \ - || (defined(RTEMS) && defined(I386))) && !defined(NO_GETCONTEXT) - # define NO_GETCONTEXT -@@ -2789,6 +2804,9 @@ - # elif defined(SN_TARGET_PS3) - void *ps3_get_mem(size_t size); - # 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 -urN gc-7.2/include/private/thread_local_alloc.h gc-7.2-haiku/include/private/thread_local_alloc.h ---- gc-7.2/include/private/thread_local_alloc.h 2012-08-09 13:25:13.029884416 -0700 -+++ gc-7.2-haiku/include/private/thread_local_alloc.h 2013-03-27 00:49:11.605290496 -0700 -@@ -47,7 +47,8 @@ - # define USE_COMPILER_TLS - # elif defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) \ - || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS) \ -- || defined(GC_NETBSD_THREADS) || defined(GC_RTEMS_PTHREADS) -+ || defined(GC_NETBSD_THREADS) || defined(GC_RTEMS_PTHREADS) \ -+ || || defined(GC_HAIKU_THREADS) - # define USE_PTHREAD_SPECIFIC - # elif defined(GC_HPUX_THREADS) - # ifdef __GNUC__ -diff -urN gc-7.2/os_dep.c gc-7.2-haiku/os_dep.c ---- gc-7.2/os_dep.c 2012-08-09 13:25:13.034340864 -0700 -+++ gc-7.2-haiku/os_dep.c 2013-03-27 00:46:12.884998144 -0700 -@@ -790,7 +790,7 @@ - } - #endif /* !MSWIN32 */ - --#ifdef BEOS -+#if defined(BEOS) || defined(HAIKU) - # include - - GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb) -@@ -801,7 +801,7 @@ - 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) -@@ -1138,7 +1138,7 @@ - # define GET_MAIN_STACKBASE_SPECIAL - #elif !defined(BEOS) && !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) -@@ -2001,7 +2001,7 @@ - # if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MSWIN32) \ - && !defined(MSWINCE) && !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 - -@@ -2326,6 +2326,19 @@ - } - #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 */ -@@ -2927,7 +2940,9 @@ - # elif !defined(MSWIN32) && !defined(MSWINCE) - # include - # include --# include -+# if !defined(HAIKU) -+# include -+# endif - - # define PROTECT(addr, len) \ - if (mprotect((caddr_t)(addr), (size_t)(len), \ -@@ -3086,6 +3101,8 @@ - /* 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 -urN gc-7.2/pthread_support.c gc-7.2-haiku/pthread_support.c ---- gc-7.2/pthread_support.c 2012-08-09 13:25:13.048234496 -0700 -+++ gc-7.2-haiku/pthread_support.c 2013-03-27 00:46:12.896794624 -0700 -@@ -999,7 +999,8 @@ - GC_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(PLATFORM_ANDROID) || defined(NACL) \ -+ || defined(GC_HAIKU_THREADS) - GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN); - if (GC_nprocs <= 0) GC_nprocs = 1; - # elif defined(GC_IRIX_THREADS) 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 new file mode 100644 index 000000000..fd0a7d06c --- /dev/null +++ b/dev-libs/boehm_gc/patches/boehm_gc-7.6.0.patchset @@ -0,0 +1,362 @@ +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 +