Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac8
-rw-r--r--libgc/Makefile.am2
-rw-r--r--libgc/include/private/gc_priv.h2
-rw-r--r--libgc/include/private/openbsd_stop_world.h12
-rw-r--r--libgc/include/private/pthread_support.h2
-rw-r--r--libgc/openbsd_stop_world.c161
-rw-r--r--libgc/pthread_stop_world.c3
-rw-r--r--mono/metadata/mono-route.h1
-rw-r--r--mono/metadata/w32process-unix-bsd.c1
-rw-r--r--mono/profiler/mprof-report.c2
-rw-r--r--mono/utils/mono-threads-openbsd.c14
-rw-r--r--mono/utils/networking-posix.c3
12 files changed, 20 insertions, 191 deletions
diff --git a/configure.ac b/configure.ac
index 97fe3e07b29..631685fff34 100644
--- a/configure.ac
+++ b/configure.ac
@@ -207,6 +207,7 @@ case "$host" in
;;
*-*-*openbsd*)
CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE -DGC_OPENBSD_THREADS -DHOST_BSD -D_REENTRANT -DUSE_MMAP"
+ LDFLAGS="${LDFLAGS} -Wl,-zwxneeded"
if test "x$disable_munmap" != "xyes"; then
CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
fi
@@ -216,6 +217,7 @@ case "$host" in
AC_DEFINE(PTHREAD_POINTER_ID)
libdl=
libgc_threads=pthreads
+ with_tls=pthread
with_sigaltstack=no
use_sigposix=yes
with_sgen_default_concurrent=yes
@@ -3316,6 +3318,9 @@ case "$host" in
BTLS_PLATFORM=i386
;;
openbsd*|freebsd*|kfreebsd-gnu*)
+ AOT_SUPPORTED="yes"
+ BTLS_SUPPORTED=yes
+ BTLS_PLATFORM=i386
;;
esac
;;
@@ -3340,6 +3345,9 @@ case "$host" in
boehm_supported=false
;;
openbsd*|freebsd*|kfreebsd-gnu*)
+ AOT_SUPPORTED="yes"
+ BTLS_SUPPORTED=yes
+ BTLS_PLATFORM=x86_64
;;
mingw*)
;;
diff --git a/libgc/Makefile.am b/libgc/Makefile.am
index 55cced5f570..807a32d628f 100644
--- a/libgc/Makefile.am
+++ b/libgc/Makefile.am
@@ -49,7 +49,7 @@ obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \
backgraph.c win32_threads.c \
pthread_support.c pthread_stop_world.c darwin_stop_world.c \
-openbsd_stop_world.c mach_dep.c $(asm_libgc_sources)
+mach_dep.c $(asm_libgc_sources)
# Include THREADDLLIBS here to ensure that the correct versions of
# linuxthread semaphore functions get linked:
diff --git a/libgc/include/private/gc_priv.h b/libgc/include/private/gc_priv.h
index ab77402e4cd..53afd7828d1 100644
--- a/libgc/include/private/gc_priv.h
+++ b/libgc/include/private/gc_priv.h
@@ -1979,6 +1979,8 @@ void GC_err_puts GC_PROTO((GC_CONST char *s));
/* Linuxthreads itself uses SIGUSR1 and SIGUSR2. */
# define SIG_SUSPEND SIGPWR
# endif
+# elif defined(GC_OPENBSD_THREADS)
+# define SIG_SUSPEND SIGXFSZ
# else /* !GC_LINUX_THREADS */
# if defined(_SIGRTMIN)
# define SIG_SUSPEND _SIGRTMIN + 6
diff --git a/libgc/include/private/openbsd_stop_world.h b/libgc/include/private/openbsd_stop_world.h
deleted file mode 100644
index 7f423ad5728..00000000000
--- a/libgc/include/private/openbsd_stop_world.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef GC_OPENBSD_STOP_WORLD_H
-#define GC_OPENBSD_STOP_WORLD_H
-
-#if !defined(GC_OPENBSD_THREADS)
-#error openbsd_stop_world.h included without GC_OPENBSD_THREADS defined
-#endif
-
-struct thread_stop_info {
- ptr_t stack_ptr; /* Valid only when stopped. */
-};
-
-#endif
diff --git a/libgc/include/private/pthread_support.h b/libgc/include/private/pthread_support.h
index 0abbd242a85..d8ca758edc3 100644
--- a/libgc/include/private/pthread_support.h
+++ b/libgc/include/private/pthread_support.h
@@ -8,8 +8,6 @@
#if defined(GC_DARWIN_THREADS)
# include "private/darwin_stop_world.h"
-#elif defined(GC_OPENBSD_THREADS)
-# include "private/openbsd_stop_world.h"
#else
# include "private/pthread_stop_world.h"
#endif
diff --git a/libgc/openbsd_stop_world.c b/libgc/openbsd_stop_world.c
deleted file mode 100644
index a4c927e6a3c..00000000000
--- a/libgc/openbsd_stop_world.c
+++ /dev/null
@@ -1,161 +0,0 @@
-#include "private/pthread_support.h"
-
-/* derived from pthread_stop_world.c */
-
-# if defined(GC_OPENBSD_THREADS)
-
-#define THREAD_EQUAL(id1, id2) pthread_equal(id1, id2)
-
-/* We hold allocation lock. Should do exactly the right thing if the */
-/* world is stopped. Should not fail if it isn't. */
-void GC_push_all_stacks()
-{
- GC_bool found_me = FALSE;
- size_t nthreads = 0;
- int i;
- GC_thread p;
- ptr_t lo, hi;
- pthread_t me = pthread_self();
-
- if (!GC_thr_initialized) GC_thr_init();
-# if DEBUG_THREADS
- GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me);
-# endif
- for (i = 0; i < THREAD_TABLE_SZ; i++) {
- for (p = GC_threads[i]; p != 0; p = p -> next) {
- if (p -> flags & FINISHED) continue;
- ++nthreads;
- if (THREAD_EQUAL(p -> id, me)) {
-# ifdef SPARC
- lo = (ptr_t)GC_save_regs_in_stack();
-# else
- lo = GC_approx_sp();
-# endif
- found_me = TRUE;
- } else {
- lo = p -> stop_info.stack_ptr;
- }
- if ((p -> flags & MAIN_THREAD) == 0) {
- hi = p -> stack_end;
- } else {
- /* The original stack. */
- hi = GC_stackbottom;
- }
-# if DEBUG_THREADS
- GC_printf("Stack for thread 0x%x = [%p,%p)\n",
- (unsigned)(p -> id), lo, hi);
-# endif
- if (0 == lo) ABORT("GC_push_all_stacks: sp not set!\n");
-# ifdef STACK_GROWS_UP
- /* We got them backwards! */
- GC_push_all_stack(hi, lo);
-# else
- GC_push_all_stack(lo, hi);
-# endif
- }
- }
- if (!found_me && !GC_in_thread_creation)
- ABORT("Collecting from unknown thread.");
-}
-
-/* We hold the allocation lock. Suspend all threads that might */
-/* still be running. */
-void GC_suspend_all()
-{
- int i;
- GC_thread p;
- int result;
- pthread_t my_thread = pthread_self();
-
- for (i = 0; i < THREAD_TABLE_SZ; i++) {
- for (p = GC_threads[i]; p != 0; p = p -> next) {
- if (!THREAD_EQUAL(p -> id, my_thread)) {
- if (p -> flags & FINISHED) continue;
- if (p -> thread_blocked) /* Will wait */ continue;
-# if DEBUG_THREADS
- GC_printf("Suspending thread 0x%x\n",
- (unsigned)(p -> id));
-# endif
-
- if (pthread_suspend_np(p -> id) != 0)
- ABORT("pthread_suspend_np failed");
-
- /*
- * This will only work for userland pthreads. It will
- * fail badly on rthreads. Perhaps we should consider
- * a pthread_sp_np() function that returns the stack
- * pointer for a suspended thread and implement in
- * both pthreads and rthreads.
- */
- p -> stop_info.stack_ptr = *(ptr_t*)((char *)p -> id + UTHREAD_SP_OFFSET);
- }
- }
- }
-}
-
-void GC_stop_world()
-{
- int i;
-
- GC_ASSERT(I_HOLD_LOCK());
-# if DEBUG_THREADS
- GC_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self());
-# endif
-
- /* Make sure all free list construction has stopped before we start. */
- /* No new construction can start, since free list construction is */
- /* required to acquire and release the GC lock before it starts, */
- /* and we have the lock. */
-# ifdef PARALLEL_MARK
- GC_acquire_mark_lock();
- GC_ASSERT(GC_fl_builder_count == 0);
- /* We should have previously waited for it to become zero. */
-# endif /* PARALLEL_MARK */
-
- GC_suspend_all();
-
-# ifdef PARALLEL_MARK
- GC_release_mark_lock();
-# endif
- #if DEBUG_THREADS
- GC_printf("World stopped from 0x%x\n", (unsigned)pthread_self());
- #endif
-}
-
-/* Caller holds allocation lock, and has held it continuously since */
-/* the world stopped. */
-void GC_start_world()
-{
- pthread_t my_thread = pthread_self();
- register int i;
- register GC_thread p;
- register int result;
-
-# if DEBUG_THREADS
- GC_printf("World starting\n");
-# endif
-
- for (i = 0; i < THREAD_TABLE_SZ; i++) {
- for (p = GC_threads[i]; p != 0; p = p -> next) {
- if (!THREAD_EQUAL(p -> id, my_thread)) {
- if (p -> flags & FINISHED) continue;
- if (p -> thread_blocked) continue;
- #if DEBUG_THREADS
- GC_printf("Resuming thread 0x%x\n",
- (unsigned)(p -> id));
- #endif
-
- if (pthread_resume_np(p -> id) != 0)
- ABORT("pthread_kill failed");
- }
- }
- }
-# if DEBUG_THREADS
- GC_printf("World started\n");
-# endif
-}
-
-void GC_stop_init() {
-}
-
-#endif
diff --git a/libgc/pthread_stop_world.c b/libgc/pthread_stop_world.c
index afa77dadfab..f93ce26b562 100644
--- a/libgc/pthread_stop_world.c
+++ b/libgc/pthread_stop_world.c
@@ -2,8 +2,7 @@
#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
&& !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS) \
- && !defined(GC_DARWIN_THREADS) && !defined(GC_AIX_THREADS) \
- && !defined(GC_OPENBSD_THREADS)
+ && !defined(GC_DARWIN_THREADS) && !defined(GC_AIX_THREADS)
#include <signal.h>
#include <semaphore.h>
diff --git a/mono/metadata/mono-route.h b/mono/metadata/mono-route.h
index 03d179d71c6..26d729aaeda 100644
--- a/mono/metadata/mono-route.h
+++ b/mono/metadata/mono-route.h
@@ -8,6 +8,7 @@
#if defined(HOST_DARWIN) || defined(HOST_BSD)
#include <sys/socket.h>
+#include <netinet/in.h> /* in_addr_t */
#if defined (HOST_IOS) || defined (HOST_WATCHOS) || defined (HOST_APPLETVOS)
// The iOS SDK does not provide the net/route.h header but using the Darwin version works fine.
diff --git a/mono/metadata/w32process-unix-bsd.c b/mono/metadata/w32process-unix-bsd.c
index 34eac0459e6..7cd859c7aa5 100644
--- a/mono/metadata/w32process-unix-bsd.c
+++ b/mono/metadata/w32process-unix-bsd.c
@@ -8,6 +8,7 @@
#ifdef USE_BSD_BACKEND
#include <errno.h>
+#include <signal.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#if !defined(__OpenBSD__)
diff --git a/mono/profiler/mprof-report.c b/mono/profiler/mprof-report.c
index 97265da0a30..bca403abe16 100644
--- a/mono/profiler/mprof-report.c
+++ b/mono/profiler/mprof-report.c
@@ -59,7 +59,7 @@
#include <assert.h>
#include <stdio.h>
#include <time.h>
-#if !defined(__APPLE__) && !defined(__FreeBSD__)
+#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
#include <malloc.h>
#endif
#include <unistd.h>
diff --git a/mono/utils/mono-threads-openbsd.c b/mono/utils/mono-threads-openbsd.c
index 117e22108f6..b6790592a67 100644
--- a/mono/utils/mono-threads-openbsd.c
+++ b/mono/utils/mono-threads-openbsd.c
@@ -6,31 +6,21 @@
#if defined(__OpenBSD__)
+#include <mono/utils/mono-threads.h>
#include <pthread.h>
#include <pthread_np.h>
void
mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
{
- /* TODO : Determine if this code is actually still needed. It may already be covered by the case above. */
- pthread_attr_t attr;
- guint8 *current = (guint8*)&attr;
-
- *staddr = NULL;
- *stsize = (size_t)-1;
-
- pthread_attr_init (&attr);
-
stack_t ss;
int rslt;
rslt = pthread_stackseg_np (pthread_self (), &ss);
g_assert (rslt == 0);
- *staddr = (guint8*)((size_t)ss.ss_sp - ss.ss_size);
+ *staddr = (void*)((size_t)ss.ss_sp - ss.ss_size);
*stsize = ss.ss_size;
-
- pthread_attr_destroy (&attr);
}
#endif
diff --git a/mono/utils/networking-posix.c b/mono/utils/networking-posix.c
index caa2073a539..95e3d7df58b 100644
--- a/mono/utils/networking-posix.c
+++ b/mono/utils/networking-posix.c
@@ -17,6 +17,9 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif