(back-port of commits
847927f,
2396ce1 from 'master')
* configure.ac (GC_HAIKU_THREADS): New AH_TEMPLATE.
* configure.ac [THREADS=posix && host=*-*-haiku*] (GC_THREADS,
_REENTRANT): Define macro.
* include/gc_config_macros.h [!GC_THREADS && GC_HAIKU_THREADS]
(GC_THREADS): Likewise.
* include/gc_config_macros.h [GC_THREADS && __HAIKU__]
(GC_HAIKU_THREADS): Likewise.
* include/gc_config_macros.h [__HAIKU__ && !GC_CAN_SAVE_CALL_STACKS]
(GC_ADD_CALLER): Define macro.
* include/private/gcconfig.h [__HAIKU__ && _X86_] (I386, HAIKU,
mach_type_known): Likewise.
* include/private/gcconfig.h [__HAIKU__ && (__amd64__ || __x86_64__)]
(X86_64, HAIKU, mach_type_known): Likewise.
* include/private/gcconfig.h [I386 && HAIKU] (DYNAMIC_LOADING,
MPROTECT_VDB): Likewise.
* include/private/gcconfig.h [X86_64 && HAIKU] (OS_TYPE, GETPAGESIZE,
DYNAMIC_LOADING, MPROTECT_VDB, HEURISTIC2, SEARCH_FOR_DATA_START):
Likewise.
* include/private/gcconfig.h [HAIKU] (UNIX_LIKE, GET_MEM): Likewise.
* os_dep.c [MPROTECT_VDB && !DARWIN && !MSWIN32 && !MSWINCE
&& HAIKU] (CODE_OK): Likewise.
* include/private/gcconfig.h [UNIX_LIKE && HAIKU] (NO_GETCONTEXT):
Likewise.
* dyn_load.c [HAIKU] (GC_register_dynamic_libraries): Implement.
* os_dep.c [HAIKU] (GC_haiku_get_mem): Likewise.
* include/private/gcconfig.h (BEOS): Rename to HAIKU.
* os_dep.c (BEOS): Likewise.
* include/private/gcconfig.h [I386 && HAIKU] (OS_TYPE): Change value
to "HAIKU".
* include/private/gcconfig.h [X86_64 && HAIKU]: Include OS.h.
* include/private/gcconfig.h [HAIKU] (GC_haiku_get_mem): Declare
prototype.
* include/private/thread_local_alloc.h [GC_HAIKU_THREADS]
(USE_PTHREAD_SPECIFIC): Likewise.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU] (old_segv_act):
Define static variable.
* os_dep.c [(NEED_FIND_LIMIT || UNIX_LIKE) && HAIKU]
(GC_set_and_save_fault_handler): Use old_segv_act; call
sigaction(SIGSEGV).
* os_dep.c [NEED_FIND_LIMIT || (USE_PROC_FOR_LIBRARIES && THREADS)]
(GC_reset_fault_handler): Likewise.
* os_dep.c [MPROTECT_VDB && !DARWIN && !USE_WINALLOC && HAIKU]: Do not
include sys/syscall.h.
* pthread_support.c [GC_HAIKU_THREADS] (GC_get_nprocs): Define function.
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.])
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)
&& !(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.
#endif /* DARWIN */
+#if defined(HAIKU)
+# include <kernel/image.h>
+
+ 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"
#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) \
# 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) \
/* 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(__FreeBSD_kernel__) \
|| defined(PLATFORM_ANDROID) || defined(__ANDROID__)) \
&& !defined(GC_CAN_SAVE_CALL_STACKS)
# 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__)
# 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 <OS.h>
# 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"
# define SEARCH_FOR_DATA_START
# endif
# endif
+# ifdef HAIKU
+# define OS_TYPE "HAIKU"
+# include <OS.h>
+# define GETPAGESIZE() (unsigned)B_PAGE_SIZE
+# define HEURISTIC2
+# define SEARCH_FOR_DATA_START
+# define DYNAMIC_LOADING
+# define MPROTECT_VDB
+# endif
# ifdef SOLARIS
# define OS_TYPE "SOLARIS"
# define ELF_CLASS ELFCLASS64
#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
# define DEFAULT_VDB
#endif
-#if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HURD) \
- || defined(OPENBSD) || defined(ARM32) \
- || defined(MIPS) || defined(AVR32) \
- || defined(OR1K) || defined(NIOS2))) \
+#if ((defined(UNIX_LIKE) && (defined(DARWIN) || defined(HAIKU) \
+ || defined(HURD) || defined(OPENBSD) \
+ || defined(ARM32) \
+ || defined(AVR32) || defined(MIPS) \
+ || defined(NIOS2) || defined(OR1K))) \
|| (defined(LINUX) && !defined(__gnu_linux__)) \
|| (defined(RTEMS) && defined(I386)) || defined(PLATFORM_ANDROID)) \
&& !defined(NO_GETCONTEXT)
# 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)
# 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__
}
#endif /* !MSWIN32 */
-#ifdef BEOS
+#ifdef HAIKU
# include <kernel/OS.h>
GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb)
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)
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)
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;
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)
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))
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)
# undef GC_AMIGA_AM
#endif
+#if defined(HAIKU)
+# include <stdlib.h>
+ 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 */
# elif !defined(USE_WINALLOC)
# include <sys/mman.h>
# include <signal.h>
-# include <sys/syscall.h>
+# if !defined(HAIKU)
+# include <sys/syscall.h>
+# endif
# define PROTECT(addr, len) \
if (mprotect((caddr_t)(addr), (size_t)(len), \
# 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
# 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(GC_HAIKU_THREADS) || defined(GC_SOLARIS_THREADS) \
+ || defined(GC_GNU_THREADS) \
|| defined(PLATFORM_ANDROID) || defined(NACL)
GC_INLINE int GC_get_nprocs(void)
{