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
path: root/libgc
diff options
context:
space:
mode:
authorRobert Nagy <robert@openbsd.org>2018-01-08 12:25:19 +0300
committerLudovic Henry <luhenry@microsoft.com>2018-01-08 12:25:19 +0300
commite31ecb3b41989ab1252708c3f5622049a3af26ef (patch)
tree90018ca81672b7e60d6404e1a340a5e51184c3c2 /libgc
parent3277e2be43031d1e03e934b9334ec811ee851e04 (diff)
openbsd related patches (#6358)
* include netinet/in.h for in_addr_t * there is no need for an openbsd specific implementation anymore so you use the generic pthread one * signal.h is required for sigaltstack * add missing mono/utils/mono-threads.h include * there is no malloc.h on OpenBSD either * sys/socket.h is required for struct sockaddr * add support for btls on openbsd and default to with_tls=pthread as there is only emultls support which is not enough for mono * there is no need for pthread_attr_init/destroy anymore * add -Wl,-zwxneeded to LDFLAGS on OpenBSD W^X is strictly enforced by default on OpenBSD; a program can only violate it if it is located on a filesystem mounted with the wxallowed mount(8) option and has been linked with the above flag
Diffstat (limited to 'libgc')
-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
6 files changed, 4 insertions, 178 deletions
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>