From 7f0d33a7b0bbeae0bcf6a0e3f9c7f0909d68f84d Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Sun, 16 Nov 2014 13:42:23 +1300 Subject: [PATCH] haiku: platform support --- src/engine/Jambase | 12 ++++++++++++ src/engine/boehm_gc/dyn_load.c | 9 +++++++-- src/engine/boehm_gc/include/gc.h | 2 +- src/engine/boehm_gc/include/gc_config_macros.h | 5 +++-- src/engine/boehm_gc/include/private/gcconfig.h | 11 +++++++++++ src/engine/boehm_gc/os_dep.c | 15 +++++++++++++-- src/engine/fileunix.c | 5 ++++- src/engine/jam.h | 5 +++++ src/engine/jambase.c | 12 ++++++++++++ src/tools/builtin.jam | 5 +++-- src/tools/builtin.py | 1 + src/tools/common.py | 3 ++- src/tools/gcc.jam | 1 + src/tools/gcc.py | 3 +++ src/tools/python.jam | 1 + src/util/os.jam | 2 ++ 16 files changed, 81 insertions(+), 11 deletions(-) diff --git a/src/engine/Jambase b/src/engine/Jambase index 94f8fbde5..6e7b7a2be 100644 --- a/src/engine/Jambase +++ b/src/engine/Jambase @@ -855,6 +855,18 @@ else if $(OS) = BEOS NOARSCAN ?= true ; STDHDRS ?= /boot/develop/headers/posix ; } +else if $(OS) = HAIKU +{ + BINDIR ?= /boot/system/non-packaged/bin ; + CC ?= gcc ; + C++ ?= $(CC) ; + FORTRAN ?= "" ; + LIBDIR ?= /boot/system/non-packaged/lib ; + LINK ?= gcc ; + LINKLIBS ?= -lnetwork ; + NOARSCAN ?= true ; + STDHDRS ?= /boot/system/develop/headers/posix ; +} else if $(UNIX) { switch $(OS) diff --git a/src/engine/boehm_gc/dyn_load.c b/src/engine/boehm_gc/dyn_load.c index 36968ba5d..eed9253e3 100644 --- a/src/engine/boehm_gc/dyn_load.c +++ b/src/engine/boehm_gc/dyn_load.c @@ -64,7 +64,7 @@ static int (*GC_has_static_roots)(const char *, void *, size_t); !defined(AIX) && !defined(SCO_ELF) && !defined(DGUX) && \ !(defined(FREEBSD) && defined(__ELF__)) && \ !(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. @@ -82,6 +82,10 @@ static int (*GC_has_static_roots)(const char *, void *, size_t); # define ELFSIZE ARCH_ELFSIZE #endif +#if defined(HAIKU) +// purposefully empty +#endif + #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) @@ -216,7 +220,8 @@ void GC_register_dynamic_libraries() #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ (defined(FREEBSD) && defined(__ELF__)) || defined(DGUX) || \ - (defined(NETBSD) && defined(__ELF__)) || defined(HURD) + (defined(NETBSD) && defined(__ELF__)) || defined(HURD) \ + defined(HAIKU) #ifdef USE_PROC_FOR_LIBRARIES diff --git a/src/engine/boehm_gc/include/gc.h b/src/engine/boehm_gc/include/gc.h index cc950888f..590a868d6 100644 --- a/src/engine/boehm_gc/include/gc.h +++ b/src/engine/boehm_gc/include/gc.h @@ -494,7 +494,7 @@ GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb); /* of compilers. */ /* This may also be desirable if it is possible but expensive to */ /* retrieve the call chain. */ -#if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) \ +#if (defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) \ || defined(__FreeBSD__) || defined(__DragonFly__)) & !defined(GC_CAN_SAVE_CALL_STACKS) # define GC_ADD_CALLER # if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) diff --git a/src/engine/boehm_gc/include/gc_config_macros.h b/src/engine/boehm_gc/include/gc_config_macros.h index 66abf0b1e..762162a34 100644 --- a/src/engine/boehm_gc/include/gc_config_macros.h +++ b/src/engine/boehm_gc/include/gc_config_macros.h @@ -45,7 +45,8 @@ || defined(GC_AIX_THREADS) \ || defined(GC_LINUX_THREADS) \ || defined(GC_NETBSD_THREADS) \ - || defined(GC_GNU_THREADS)) + || defined(GC_GNU_THREADS) \ + || defined(GC_HAIKU_THREADS)) # define _REENTRANT /* Better late than never. This fails if system headers that */ /* depend on this were previously included. */ @@ -65,7 +66,7 @@ defined(GC_DGUX386_THREADS) || defined(GC_DARWIN_THREADS) || \ defined(GC_AIX_THREADS) || defined(GC_NETBSD_THREADS) || \ (defined(GC_WIN32_THREADS) && defined(__CYGWIN32__)) || \ - defined(GC_GNU_THREADS) + defined(GC_GNU_THREADS) || defined(GC_HAIKU_THREADS) # define GC_PTHREADS # endif diff --git a/src/engine/boehm_gc/include/private/gcconfig.h b/src/engine/boehm_gc/include/private/gcconfig.h index 20f35bc3a..61cf9eacb 100644 --- a/src/engine/boehm_gc/include/private/gcconfig.h +++ b/src/engine/boehm_gc/include/private/gcconfig.h @@ -215,6 +215,10 @@ # define BEOS # define mach_type_known # endif +# if defined(__HAIKU__) && defined(_X86_) +# define I386 +# define HAIKU +# define mach_type_known # if defined(LINUX) && (defined(i386) || defined(__i386__)) # define I386 # define mach_type_known @@ -1014,6 +1018,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[]; diff --git a/src/engine/boehm_gc/os_dep.c b/src/engine/boehm_gc/os_dep.c index bb8fa08f6..2dd087fbe 100644 --- a/src/engine/boehm_gc/os_dep.c +++ b/src/engine/boehm_gc/os_dep.c @@ -777,6 +777,17 @@ ptr_t GC_get_main_stack_base(void){ # endif /* BEOS */ +# 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 + + # ifdef OS2 ptr_t GC_get_main_stack_base(void) @@ -1097,7 +1108,7 @@ ptr_t GC_get_main_stack_base(void) #if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \ && !defined(MSWINCE) && !defined(OS2) && !defined(NOSYS) && !defined(ECOS) \ - && !defined(CYGWIN32) + && !defined(CYGWIN32) && !defined(HAIKU) ptr_t GC_get_main_stack_base(void) { @@ -1154,7 +1165,7 @@ ptr_t GC_get_main_stack_base(void) # endif /* STACKBOTTOM */ } -# endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS */ +# endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS, !HAIKU */ #if defined(GC_LINUX_THREADS) && !defined(HAVE_GET_STACK_BASE) diff --git a/src/engine/fileunix.c b/src/engine/fileunix.c index bff3a42f5..e8ea51507 100644 --- a/src/engine/fileunix.c +++ b/src/engine/fileunix.c @@ -80,7 +80,10 @@ struct ar_hdr /* archive file member header - printable ascii */ }; #endif -#if defined( OS_QNX ) || defined( OS_BEOS ) || defined( OS_MPEIX ) +#if defined( OS_QNX ) || \ + defined( OS_BEOS ) || \ + defined( OS_HAIKU ) || \ + defined( OS_MPEIX ) # define NO_AR # define HAVE_AR #endif diff --git a/src/engine/jam.h b/src/engine/jam.h index 497a5bfb1..875187fc8 100644 --- a/src/engine/jam.h +++ b/src/engine/jam.h @@ -154,6 +154,11 @@ #define OSMINOR "OS=HPUX" #define OS_HPUX #endif +#ifdef __HAIKU__ + #define unix + #define OSMINOR "OS=HAIKU" + #define OS_HAIKU +#endif #ifdef __OPENNT #define unix #define OSMINOR "OS=INTERIX" diff --git a/src/engine/jambase.c b/src/engine/jambase.c index b15282bc3..323ba1564 100644 --- a/src/engine/jambase.c +++ b/src/engine/jambase.c @@ -560,6 +560,18 @@ char *jambase[] = { "NOARSCAN ?= true ;\n", "STDHDRS ?= /boot/develop/headers/posix ;\n", "}\n", +"else if $(OS) = HAIKU\n", +"{\n", +"BINDIR ?= /boot/system/non-packaged/bin ;\n", +"CC ?= gcc ;\n", +"C++ ?= $(CC) ;\n", +"FORTRAN ?= \"\" ;\n", +"LIBDIR ?= /boot/system/non-packaged/lib ;\n", +"LINK ?= gcc ;\n", +"LINKLIBS ?= -lnetwork ;\n", +"NOARSCAN ?= true ;\n", +"STDHDRS ?= /boot/system/develop/headers/posix ;\n", +"}\n", "else if $(UNIX)\n", "{\n", "switch $(OS)\n", diff --git a/src/tools/builtin.jam b/src/tools/builtin.jam index 69bf61e65..92959afc0 100644 --- a/src/tools/builtin.jam +++ b/src/tools/builtin.jam @@ -40,8 +40,8 @@ import convert ; import generate ; -.os-names = aix android bsd cygwin darwin freebsd hpux iphone linux netbsd openbsd osf - qnx qnxnto sgi solaris unix unixware windows +.os-names = aix android bsd cygwin darwin freebsd haiku hpux iphone linux netbsd + openbsd osf qnx qnxnto sgi solaris unix unixware windows elf # Not actually an OS -- used for targeting bare metal where object # format is ELF. This catches both -elf and -eabi gcc targets and well # as other compilers targeting ELF. It is not clear how often we need @@ -76,6 +76,7 @@ local rule default-host-os ( ) case COHERENT : host-os = unix ; case DRAGONFLYBSD : host-os = bsd ; case IRIX : host-os = sgi ; + case HAIKU : host-os = haiku ; case MACOSX : host-os = darwin ; case KFREEBSD : host-os = freebsd ; case LINUX : host-os = linux ; diff --git a/src/tools/builtin.py b/src/tools/builtin.py index 68ddfed4b..14a883e1b 100644 --- a/src/tools/builtin.py +++ b/src/tools/builtin.py @@ -103,6 +103,7 @@ def default_host_os(): elif host_os == 'MACOSX': host_os = 'darwin' elif host_os == 'KFREEBSD': host_os = 'freebsd' elif host_os == 'LINUX': host_os = 'linux' + elif host_os == 'HAIKU': host_os = 'haiku' else: host_os = 'unix' return host_os.lower() diff --git a/src/tools/common.py b/src/tools/common.py index 63c65e4c0..443b3e92d 100644 --- a/src/tools/common.py +++ b/src/tools/common.py @@ -66,7 +66,8 @@ def reset (): m = {"NT": __executable_path_variable, "CYGWIN": "PATH", "MACOSX": "DYLD_LIBRARY_PATH", - "AIX": "LIBPATH"} + "AIX": "LIBPATH", + "HAIKU": "LIBRARY_PATH"} global __shared_library_path_variable __shared_library_path_variable = m.get(OS, "LD_LIBRARY_PATH") diff --git a/src/tools/gcc.jam b/src/tools/gcc.jam index ce9be9d6d..db0453461 100644 --- a/src/tools/gcc.jam +++ b/src/tools/gcc.jam @@ -1034,6 +1034,7 @@ rule setup-threading ( targets * : sources * : properties * ) case cygwin : option = -mthreads ; case solaris : option = -pthreads ; libs = rt ; case beos : # No threading options. + case haiku : option = ; case *bsd : option = -pthread ; # There is no -lrt on BSD. case sgi : # gcc on IRIX does not support multi-threading. case darwin : # No threading options. diff --git a/src/tools/gcc.py b/src/tools/gcc.py index 97f1e79d4..a13ce7ad2 100644 --- a/src/tools/gcc.py +++ b/src/tools/gcc.py @@ -686,6 +686,9 @@ elif bjam.variable('UNIX'): elif host_os_name == 'BeOS': # BeOS has no threading options, don't set anything here. pass + elif host_os_name == 'Haiku': + flags('gcc', 'OPTIONS', ['multi'], ['-lroot']) + # there is no -lrt on Haiku, and -pthread is implicit elif host_os_name.endswith('BSD'): flags('gcc', 'OPTIONS', ['multi'], ['-pthread']) # there is no -lrt on BSD diff --git a/src/tools/python.jam b/src/tools/python.jam index 783b9cee8..1a41a1e86 100644 --- a/src/tools/python.jam +++ b/src/tools/python.jam @@ -639,6 +639,7 @@ local rule system-library-dependencies ( target-os ) case qnx* : return ; case darwin : return ; case windows : return ; + case haiku : return ; case hpux : return rt ; case *bsd : return pthread gcc:util ; diff --git a/src/util/os.jam b/src/util/os.jam index daef27f77..818b0b423 100644 --- a/src/util/os.jam +++ b/src/util/os.jam @@ -75,6 +75,8 @@ if $(.name) = NT .shared-library-path-variable-AIX = LIBPATH ; +.shared-library-path-variable-HAIKU = LIBRARY_PATH ; + # Default constants .shared-library-path-variable = LD_LIBRARY_PATH ; .path-separator = ":" ;