diff options
author | Rodrigo Kumpera <kumpera@users.noreply.github.com> | 2017-03-01 20:08:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-01 20:08:38 +0300 |
commit | 8b671a8c31368e2046aa9546c46f01b99c5c8008 (patch) | |
tree | f1bd68914b6a764a7cb07bd9d8d7d40be1af62cb | |
parent | f9dcaa74a99e1000b28ae89ab56ece6727bd28c0 (diff) | |
parent | 530ad57bc96414984e211053910dc8735b0557d0 (diff) |
Merge pull request #4373 from NattyNarwhal/haiku
Restore Haiku support
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | eglib/configure.ac | 3 | ||||
-rw-r--r-- | mono/metadata/w32file-unix.c | 2 | ||||
-rw-r--r-- | mono/metadata/w32process-unix-haiku.c | 3 | ||||
-rw-r--r-- | mono/metadata/w32process-unix-internals.h | 2 | ||||
-rw-r--r-- | mono/mini/mini-x86.h | 6 | ||||
-rw-r--r-- | mono/utils/Makefile.am | 1 | ||||
-rw-r--r-- | mono/utils/mono-context.h | 13 | ||||
-rw-r--r-- | mono/utils/mono-proclib.c | 22 | ||||
-rw-r--r-- | mono/utils/mono-threads-haiku.c | 25 | ||||
-rw-r--r-- | mono/utils/mono-threads-posix.c | 8 | ||||
-rw-r--r-- | mono/utils/mono-threads.h | 7 | ||||
-rw-r--r-- | support/serial.c | 5 | ||||
-rw-r--r-- | support/sys-mman.c | 12 | ||||
-rw-r--r-- | support/sys-time.c | 6 |
15 files changed, 111 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac index a8dcb129243..71f242d6fc7 100644 --- a/configure.ac +++ b/configure.ac @@ -334,9 +334,13 @@ case "$host" in CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE" libmono_cflags="-D_REENTRANT -D_THREAD_SAFE" libdl= - LIBS="$LIBS -lnetwork" + LIBS="$LIBS -lnetwork -ltextencoding" need_link_unlink=yes AC_DEFINE(PTHREAD_POINTER_ID) + dnl Haiku does not support static TLS with __thread + with_tls=pthread + dnl Boehm is too much work to backport Haiku support for + support_boehm=no libgc_threads=pthreads use_sigposix=yes ;; @@ -1913,6 +1917,10 @@ if test x$host_win32 = xno; then # and libpthread does not exist # case "${host}" in + *-*-*haiku*) + dnl Haiku has pthread in libroot (libc equiv) + AC_CHECK_LIB(pthread, main, LIBS="$LIBS") + ;; *-*-*freebsd*) AC_CHECK_LIB(pthread, main, LIBS="$LIBS -pthread") ;; @@ -2323,6 +2331,10 @@ if test x$host_win32 = xno; then ]) dnl ********************************** + dnl *** Checks for proclib *** + dnl ********************************** + AC_CHECK_HEADER(sys/errno.h, [AC_DEFINE(HAVE_SYS_ERRNO_H, 1, Define to 1 if you have the <sys/errno.h> header file.)]) + dnl ********************************** dnl *** Checks for MonoPosixHelper *** dnl ********************************** AC_CHECK_HEADERS(checklist.h) diff --git a/eglib/configure.ac b/eglib/configure.ac index 89f85d18e59..92cd6156f94 100644 --- a/eglib/configure.ac +++ b/eglib/configure.ac @@ -94,6 +94,9 @@ arm*-darwin*|aarch64*-*) i*86-*-darwin*) ORDER=G_LITTLE_ENDIAN ;; +*-*-haiku*) + LDFLAGS="$LDFLAGS -ltextencoding" + ;; *-*-openbsd*) CFLAGS="$CFLAGS -pthread" LDFLAGS="$LDFLAGS -pthread" diff --git a/mono/metadata/w32file-unix.c b/mono/metadata/w32file-unix.c index 9666cb67d9d..cda335d25a6 100644 --- a/mono/metadata/w32file-unix.c +++ b/mono/metadata/w32file-unix.c @@ -4928,7 +4928,7 @@ mono_w32file_get_drive_type(const gunichar2 *root_path_name) return (drive_type); } -#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__) +#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__) || defined(__HAIKU__) static gchar* get_fstypename (gchar *utfpath) { diff --git a/mono/metadata/w32process-unix-haiku.c b/mono/metadata/w32process-unix-haiku.c index 4311993bb10..3dfee3c6078 100644 --- a/mono/metadata/w32process-unix-haiku.c +++ b/mono/metadata/w32process-unix-haiku.c @@ -4,7 +4,8 @@ #ifdef USE_HAIKU_BACKEND -#include <KernelKit.h> +/* KernelKit.h doesn't include the right headers? */ +#include <os/kernel/image.h> gchar* mono_w32process_get_name (pid_t pid) diff --git a/mono/metadata/w32process-unix-internals.h b/mono/metadata/w32process-unix-internals.h index 71226c3109d..72fd6088860 100644 --- a/mono/metadata/w32process-unix-internals.h +++ b/mono/metadata/w32process-unix-internals.h @@ -15,6 +15,8 @@ #define USE_BSD_BACKEND #elif defined(__HAIKU__) #define USE_HAIKU_BACKEND +/* Define header for team_info */ +#include <os/kernel/OS.h> #else #define USE_DEFAULT_BACKEND #endif diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h index 6e04f7d3758..edc0bb19ecc 100644 --- a/mono/mini/mini-x86.h +++ b/mono/mini/mini-x86.h @@ -34,12 +34,6 @@ LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep); #endif /* HOST_WIN32 */ -#ifdef __HAIKU__ -struct sigcontext { - vregs regs; -}; -#endif /* __HAIKU__ */ - #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \ defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) #define MONO_ARCH_USE_SIGACTION diff --git a/mono/utils/Makefile.am b/mono/utils/Makefile.am index 2172b996ba0..4b051613420 100644 --- a/mono/utils/Makefile.am +++ b/mono/utils/Makefile.am @@ -134,6 +134,7 @@ monoutils_sources = \ mono-threads-netbsd.c \ mono-threads-openbsd.c \ mono-threads-android.c \ + mono-threads-haiku.c \ mono-threads.h \ mono-threads-debug.h \ mono-threads-api.h \ diff --git a/mono/utils/mono-context.h b/mono/utils/mono-context.h index 3a6f44636c8..6e7cf7bd442 100644 --- a/mono/utils/mono-context.h +++ b/mono/utils/mono-context.h @@ -47,6 +47,13 @@ typedef struct __darwin_xmm_reg MonoContextSimdReg; #undef MONO_SIGNAL_USE_UCONTEXT_T #endif +#ifdef __HAIKU__ +/* sigcontext surrogate */ +struct sigcontext { + vregs regs; +}; +#endif + #ifdef HOST_WIN32 /* sigcontext surrogate */ struct sigcontext { @@ -74,14 +81,14 @@ struct sigcontext { # define SC_ESI sc_esi #elif defined(__HAIKU__) # define SC_EAX regs.eax -# define SC_EBX regs._reserved_2[2] +# define SC_EBX regs.ebx # define SC_ECX regs.ecx # define SC_EDX regs.edx # define SC_EBP regs.ebp # define SC_EIP regs.eip # define SC_ESP regs.esp -# define SC_EDI regs._reserved_2[0] -# define SC_ESI regs._reserved_2[1] +# define SC_EDI regs.edi +# define SC_ESI regs.esi #else # define SC_EAX eax # define SC_EBX ebx diff --git a/mono/utils/mono-proclib.c b/mono/utils/mono-proclib.c index 515104efaf6..5f6d145b6da 100644 --- a/mono/utils/mono-proclib.c +++ b/mono/utils/mono-proclib.c @@ -20,7 +20,9 @@ #endif #if defined(_POSIX_VERSION) +#ifdef HAVE_SYS_ERRNO_H #include <sys/errno.h> +#endif #include <sys/param.h> #include <errno.h> #ifdef HAVE_SYS_TYPES_H @@ -31,6 +33,9 @@ #endif #include <sys/resource.h> #endif +#if defined(__HAIKU__) +#include <os/kernel/OS.h> +#endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #include <sys/proc.h> #if defined(__APPLE__) @@ -155,9 +160,20 @@ mono_process_list (int *size) *size = res; return buf; #elif defined(__HAIKU__) - /* FIXME: Add back the code from 9185fcc305e43428d0f40f3ee37c8a405d41c9ae */ - g_assert_not_reached (); - return NULL; + int32 cookie = 0; + int32 i = 0; + team_info ti; + system_info si; + + get_system_info(&si); + void **buf = g_calloc(si.used_teams, sizeof(void*)); + + while (get_next_team_info(&cookie, &ti) == B_OK && i < si.used_teams) { + buf[i++] = GINT_TO_POINTER (ti.team); + } + *size = i; + + return buf; #else const char *name; void **buf = NULL; diff --git a/mono/utils/mono-threads-haiku.c b/mono/utils/mono-threads-haiku.c new file mode 100644 index 00000000000..231ff3be8f4 --- /dev/null +++ b/mono/utils/mono-threads-haiku.c @@ -0,0 +1,25 @@ +#include <config.h> + +#if defined(__HAIKU__) + +#include <mono/utils/mono-threads.h> +#include <pthread.h> +#include <os/kernel/OS.h> + +void +mono_threads_platform_reset_priority(pthread_attr_t *attr) +{ + /* FIXME: Implement this on Haiku */ +} + +void +mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize) +{ + thread_info ti; + get_thread_info(get_pthread_thread_id(pthread_self()), &ti); + + *staddr = ti.stack_base; + *stsize = ti.stack_end - ti.stack_base; +} + +#endif diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index dcb7e27d2a1..2b48be021d9 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -35,8 +35,9 @@ extern int tkill (pid_t tid, int signal); #include <sys/resource.h> -static void -reset_priority (pthread_attr_t *attr) +#ifdef MONO_THREADS_PLATFORM_HAS_ATTR_SETSCHED +void +mono_threads_platform_reset_priority (pthread_attr_t *attr) { struct sched_param param; gint res; @@ -82,6 +83,7 @@ reset_priority (pthread_attr_t *attr) if (res != 0) g_error ("%s: pthread_attr_setschedparam failed, error: \"%s\" (%d)", __func__, g_strerror (res), res); } +#endif int mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *out_tid) @@ -121,7 +123,7 @@ mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_ g_assert (!res); #endif /* HAVE_PTHREAD_ATTR_SETSTACKSIZE */ - reset_priority (&attr); + mono_threads_platform_reset_priority (&attr); if (stack_size) { res = pthread_attr_getstacksize (&attr, &min_stack_size); diff --git a/mono/utils/mono-threads.h b/mono/utils/mono-threads.h index 0e77e395663..344fbdec3c8 100644 --- a/mono/utils/mono-threads.h +++ b/mono/utils/mono-threads.h @@ -62,6 +62,10 @@ typedef gsize mono_thread_start_return_t; typedef gsize (*MonoThreadStart)(gpointer); +#if !defined(__HAIKU__) +#define MONO_THREADS_PLATFORM_HAS_ATTR_SETSCHED +#endif /* !defined(__HAIKU__) */ + #endif /* #ifdef HOST_WIN32 */ #ifndef MONO_INFINITE_WAIT @@ -478,6 +482,9 @@ gint mono_threads_suspend_get_suspend_signal (void); gint mono_threads_suspend_get_restart_signal (void); gint mono_threads_suspend_get_abort_signal (void); +#if defined(USE_POSIX_BACKEND) +void mono_threads_platform_reset_priority (pthread_attr_t *attr); +#endif /* defined(USE_POSIX_BACKEND) */ int mono_threads_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *out_tid); void mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize); void mono_threads_platform_init (void); diff --git a/support/serial.c b/support/serial.c index ec02e48b5e8..5e3d732c005 100644 --- a/support/serial.c +++ b/support/serial.c @@ -175,6 +175,11 @@ discard_buffer (int fd, gboolean input) gint32 get_bytes_in_buffer (int fd, gboolean input) { +#if defined(__HAIKU__) + /* FIXME: Haiku doesn't support TIOCOUTQ nor FIONREAD on fds */ + return -1; +#define TIOCOUTQ 0 +#endif gint32 retval; if (ioctl (fd, input ? FIONREAD : TIOCOUTQ, &retval) == -1) { diff --git a/support/sys-mman.c b/support/sys-mman.c index 1dd61bc372b..afbe4662444 100644 --- a/support/sys-mman.c +++ b/support/sys-mman.c @@ -88,17 +88,25 @@ Mono_Posix_Syscall_msync (void *start, mph_size_t len, int flags) int Mono_Posix_Syscall_mlock (void *start, mph_size_t len) { +#if !defined(HAVE_MINCORE) + return ENOSYS; +#else mph_return_if_size_t_overflow (len); return mlock (start, (size_t) len); +#endif } int Mono_Posix_Syscall_munlock (void *start, mph_size_t len) { +#if defined(__HAIKU__) + return ENOSYS; +#else mph_return_if_size_t_overflow (len); return munlock (start, (size_t) len); +#endif } #ifdef HAVE_MREMAP @@ -129,9 +137,13 @@ Mono_Posix_Syscall_mremap (void *old_address, mph_size_t old_size, int Mono_Posix_Syscall_mincore (void *start, mph_size_t length, unsigned char *vec) { +#if defined(__HAIKU__) + return ENOSYS; +#else mph_return_if_size_t_overflow (length); return mincore (start, (size_t) length, (void*)vec); +#endif } #ifdef HAVE_POSIX_MADVISE diff --git a/support/sys-time.c b/support/sys-time.c index a1c0ba0b184..83afa0c8466 100644 --- a/support/sys-time.c +++ b/support/sys-time.c @@ -47,6 +47,11 @@ Mono_Posix_Syscall_settimeofday ( struct Mono_Posix_Timeval *tv, struct Mono_Posix_Timezone *tz) { +#if defined(__HAIKU__) + /* FIXME: Haiku doesn't support this either, consider + using set_real_time_clock instead? */ + return -1; +#else struct timeval _tv = {0}; struct timeval *ptv = NULL; struct timezone _tz = {0}; @@ -67,6 +72,7 @@ Mono_Posix_Syscall_settimeofday ( r = settimeofday (ptv, ptz); return r; +#endif } static inline struct timeval* |