diff options
author | Calvin <calvin@cmpct.info> | 2017-12-06 16:43:20 -0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-01-22 21:12:32 +0300 |
commit | e52f30024f9e7722a00ac863a3c00ba0de459e4d (patch) | |
tree | 53b2d626812a42759b81d45c124243d6a5d376e2 | |
parent | 5d819c884576d8c5f5f117f010efd49696bd81f8 (diff) | |
download | bdwgc-e52f30024f9e7722a00ac863a3c00ba0de459e4d.tar.gz |
Compile on amd64 Haiku (#4473)
* Compile on amd64 Haiku
Use sigcontext (somewhat like win32, or x86) on Haiku amd64.
On amd64, Haiku doesn't have issues with marshalling 64-bit values,
but it currently does have issues with SGen either causing a stall
or a core dump. As such, while it can compile the stdlib (further
than x86 got), it's still a work in progress.
* Use set_real_time_clock for sys-time.c on Haiku
* Get mono-boehm compiling on Haiku again
It still doesn't work. Initialization will call GC_mark_from, which
will cause a segmentation fault as it decrements pointers. (Mono
will enter an infinite loop in mono_get_hazardous_pointer as a result.)
For now, mono-sgen will continue to be used by default.
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | dyn_load.c | 19 | ||||
-rw-r--r-- | include/gc_config_macros.h | 2 | ||||
-rw-r--r-- | include/private/gcconfig.h | 33 | ||||
-rw-r--r-- | os_dep.c | 40 | ||||
-rw-r--r-- | pthread_support.c | 2 |
6 files changed, 87 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac index 7f5aa031..628144d3 100644 --- a/configure.ac +++ b/configure.ac @@ -104,6 +104,10 @@ case "$THREADS" in AC_DEFINE(GC_AIX_THREADS) AC_DEFINE(_REENTRANT) ;; + *-*-haiku*) + AC_DEFINE(GC_HAIKU_THREADS) + AC_DEFINE(_REENTRANT) + ;; *-*-hpux*) AC_MSG_WARN("Only HP/UX 11 threads are supported.") AC_DEFINE(GC_HPUX_THREADS) @@ -59,7 +59,7 @@ !(defined(FREEBSD) && defined(__ELF__)) && \ !(defined(OPENBSD) && (defined(__ELF__) || defined(M68K))) && \ !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) && \ - !defined(DARWIN) + !defined(DARWIN) && !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. @@ -1258,6 +1258,23 @@ GC_bool GC_register_main_static_data() #endif /* DARWIN */ +#if defined(HAIKU) + +#include <kernel/image.h> + +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 */ + #else /* !DYNAMIC_LOADING */ #ifdef PCR diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index caf8de52..55519b8c 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -57,7 +57,7 @@ defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) || \ defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \ defined(GC_AIX_THREADS) || defined(GC_NETBSD_THREADS) || \ - defined(GC_OPENBSD_THREADS) || \ + defined(GC_OPENBSD_THREADS) || defined(GC_HAIKU_THREADS) ||\ (defined(GC_WIN32_THREADS) && defined(__CYGWIN32__)) # define GC_PTHREADS # endif diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 03305b61..e2bdf13a 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -238,6 +238,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(__amd64__) +# define X86_64 +# define HAIKU +# define mach_type_known +# endif # if defined(LINUX) && (defined(i386) || defined(__i386__)) # define I386 # define mach_type_known @@ -1164,6 +1174,15 @@ extern int etext[]; # define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) # endif +# ifdef HAIKU +# define OS_TYPE "HAIKU" +# include <OS.h> +# define GETPAGESIZE() B_PAGE_SIZE + extern int etext[]; +# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) +# define DYNAMIC_LOADING +# define MPROTECT_VDB +# endif # ifdef SUNOS5 # define OS_TYPE "SUNOS5" extern int _etext[], _end[]; @@ -2134,6 +2153,15 @@ /* There seems to be some issues with trylock hanging on darwin. This should be looked into some more */ # endif +# ifdef HAIKU +# define OS_TYPE "HAIKU" +# include <OS.h> +# define GETPAGESIZE() B_PAGE_SIZE + extern int etext[]; +# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) +# define DYNAMIC_LOADING +# define MPROTECT_VDB +# endif # ifdef FREEBSD # define OS_TYPE "FREEBSD" # ifndef GC_FREEBSD_THREADS @@ -2251,7 +2279,7 @@ # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \ || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \ || defined(DGUX) || defined(BSD) || defined(SUNOS4) \ - || defined(_AIX) || defined(DARWIN) || defined(OSF1) + || defined(_AIX) || defined(DARWIN) || defined(OSF1) || defined(HAIKU) # define UNIX_LIKE /* Basic Unix-like system calls work. */ # endif @@ -2507,6 +2535,9 @@ # if defined(SN_TARGET_PS3) extern 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 extern ptr_t GC_unix_get_mem(word size); # define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes) @@ -609,7 +609,7 @@ void GC_enable_signals(void) && !defined(MACOS) && !defined(DJGPP) && !defined(DOS4GW) \ && !defined(NOSYS) && !defined(ECOS) && !defined(SN_TARGET_PS3) -# if defined(sigmask) && !defined(UTS4) && !defined(HURD) +# if defined(sigmask) && !defined(UTS4) && !defined(HURD) && !defined(HAIKU) /* Use the traditional BSD interface */ # define SIGSET_T int # define SIG_DEL(set, signal) (set) &= ~(sigmask(signal)) @@ -764,14 +764,14 @@ ptr_t GC_get_stack_base() # endif /* MS Windows */ -# ifdef BEOS +# ifdef HAIKU # include <kernel/OS.h> ptr_t GC_get_stack_base(){ thread_info th; get_thread_info(find_thread(NULL),&th); return th.stack_end; } -# endif /* BEOS */ +# endif /* HAIKU */ # ifdef OS2 @@ -1122,7 +1122,7 @@ void *GC_set_stackbottom = NULL; #endif /* FREEBSD_STACKBOTTOM */ -#if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \ +#if !defined(HAIKU) && !defined(AMIGA) && !defined(MSWIN32) \ && !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS) \ && !defined(GC_OPENBSD_THREADS) @@ -1182,7 +1182,7 @@ ptr_t GC_get_stack_base() # endif /* STACKBOTTOM */ } -# endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS */ +# endif /* ! AMIGA, !OS 2, ! MS Windows, !HAIKU, !NOSYS, !ECOS */ #if defined(GC_OPENBSD_THREADS) @@ -1957,6 +1957,19 @@ word bytes; } # endif +#if defined(HAIKU) +#include <stdlib.h> + +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 */ @@ -2393,7 +2406,9 @@ GC_bool is_ptrfree; # 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), \ @@ -2450,13 +2465,13 @@ GC_bool is_ptrfree; #endif /* SUNOS4 || (FREEBSD && !SUNOS5SIGS) */ #if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX) \ - || defined(HURD) + || defined(HURD) || defined(HAIKU) # ifdef __STDC__ typedef void (* SIG_PF)(int); # else typedef void (* SIG_PF)(); # endif -#endif /* SUNOS5SIGS || OSF1 || LINUX || HURD */ +#endif /* SUNOS5SIGS || OSF1 || LINUX || HURD || HAIKU */ #if defined(MSWIN32) typedef LPTOP_LEVEL_EXCEPTION_FILTER SIG_PF; @@ -2634,6 +2649,13 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */ /* architectures. */ # endif /* LINUX */ +# if defined(HAIKU) +# include <errno.h> +# define CODE_OK TRUE +# define SIG_OK (sig == SIGSEGV) + void GC_write_failt_handler(int sig, siginfo_t *scp, void * context) +#endif /* HAIKU */ + # if defined(SUNOS5SIGS) # ifdef __STDC__ void GC_write_fault_handler(int sig, SIGINFO_T *scp, void * context) @@ -2679,7 +2701,7 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */ # if defined(OSF1) && defined(ALPHA) char * addr = (char *) (scp -> sc_traparg_a0); # endif -# ifdef SUNOS5SIGS +# if defined(SUNOS5SIGS) || defined(HAIKU) char * addr = (char *) (scp -> si_addr); # endif # ifdef LINUX diff --git a/pthread_support.c b/pthread_support.c index 097d588a..6d240f65 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -1135,7 +1135,7 @@ void GC_thr_init() # if defined(GC_HPUX_THREADS) GC_nprocs = pthread_num_processors_np(); # endif -# if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) +# if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) || defined(GC_HAIKU_THREADS) GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN); if (GC_nprocs <= 0) GC_nprocs = 1; # endif |