summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/private/gc_priv.h2
-rw-r--r--include/private/gcconfig.h11
-rw-r--r--os_dep.c65
-rw-r--r--pthread_stop_world.c106
-rw-r--r--tests/initfromthread.c2
5 files changed, 40 insertions, 146 deletions
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index c93710be..f3e1b7c3 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -3023,9 +3023,7 @@ GC_INNER void *GC_store_debug_info_inner(void *p, word sz, const char *str,
# define SIG_SUSPEND SIGUSR1
/* SIGTSTP and SIGCONT could be used alternatively on FreeBSD. */
# elif defined(GC_OPENBSD_THREADS) && !defined(GC_USESIGRT_SIGNALS)
-# ifndef GC_OPENBSD_UTHREADS
# define SIG_SUSPEND SIGXFSZ
-# endif
# elif defined(_SIGRTMIN) && !defined(CPPCHECK)
# define SIG_SUSPEND _SIGRTMIN + 6
# else
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index a1fa754e..95b15049 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -2512,11 +2512,6 @@ EXTERN_C_BEGIN
EXTERN_C_END
# include <sys/param.h>
EXTERN_C_BEGIN
- /* Prior to 5.2 release, OpenBSD had user threads and required */
- /* special handling. */
-# if OpenBSD < 201211
-# define GC_OPENBSD_UTHREADS 1
-# endif
#endif /* GC_OPENBSD_THREADS */
#if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
@@ -2745,8 +2740,7 @@ EXTERN_C_BEGIN
|| defined(HPUX_MAIN_STACKBOTTOM) || defined(IA64) \
|| (defined(CYGWIN32) && defined(I386) && defined(USE_MMAP) \
&& !defined(USE_WINALLOC)) \
- || (defined(NETBSD) && defined(__ELF__)) \
- || (defined(OPENBSD) && !defined(GC_OPENBSD_UTHREADS)) \
+ || (defined(NETBSD) && defined(__ELF__)) || defined(OPENBSD) \
|| ((defined(SVR4) || defined(AIX) || defined(DGUX) \
|| defined(DATASTART_USES_BSDGETDATASTART) \
|| (defined(LINUX) && defined(SPARC))) && !defined(PCR))
@@ -2865,8 +2859,7 @@ EXTERN_C_BEGIN
# define PTHREAD_STOP_WORLD_IMPL
#endif
-#if defined(PTHREAD_STOP_WORLD_IMPL) && !defined(NACL) \
- && !defined(GC_OPENBSD_UTHREADS)
+#if defined(PTHREAD_STOP_WORLD_IMPL) && !defined(NACL)
# define SIGNAL_BASED_STOP_WORLD
#endif
diff --git a/os_dep.c b/os_dep.c
index 8e140836..42b0fa06 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -524,60 +524,6 @@ GC_INNER const char * GC_get_maps(void)
LONGJMP(GC_jmp_buf_openbsd, 1);
}
-# ifdef GC_OPENBSD_UTHREADS
-# include <sys/syscall.h>
- EXTERN_C_BEGIN
- extern sigset_t __syscall(quad_t, ...);
- EXTERN_C_END
-
- /* Don't use GC_find_limit() because siglongjmp() outside of the */
- /* signal handler by-passes our userland pthreads lib, leaving */
- /* SIGSEGV and SIGPROF masked. Instead, use this custom one that */
- /* works-around the issues. */
-
- /* Return the first non-addressable location > p or bound. */
- STATIC ptr_t GC_find_limit_openbsd(ptr_t p, ptr_t bound)
- {
- static volatile ptr_t result;
- /* Safer if static, since otherwise it may not be */
- /* preserved across the longjmp. Can safely be */
- /* static since it's only called with the */
- /* allocation lock held. */
-
- struct sigaction act;
- word pgsz = (word)sysconf(_SC_PAGESIZE);
-
- GC_ASSERT((word)bound >= pgsz);
- GC_ASSERT(I_HOLD_LOCK());
-
- act.sa_handler = GC_fault_handler_openbsd;
- sigemptyset(&act.sa_mask);
- act.sa_flags = SA_NODEFER | SA_RESTART;
- /* act.sa_restorer is deprecated and should not be initialized. */
- sigaction(SIGSEGV, &act, &old_segv_act);
-
- if (SETJMP(GC_jmp_buf_openbsd) == 0) {
- result = (ptr_t)((word)p & ~(pgsz-1));
- for (;;) {
- if ((word)result >= (word)bound - pgsz) {
- result = bound;
- break;
- }
- result += pgsz; /* no overflow expected */
- GC_noop1((word)(*result));
- }
- }
-
-# ifdef THREADS
- /* Due to the siglongjump we need to manually unmask SIGPROF. */
- __syscall(SYS_sigprocmask, SIG_UNBLOCK, sigmask(SIGPROF));
-# endif
-
- sigaction(SIGSEGV, &old_segv_act, 0);
- return result;
- }
-# endif /* GC_OPENBSD_UTHREADS */
-
static volatile int firstpass;
/* Return first addressable location > p or bound. */
@@ -995,7 +941,10 @@ GC_INNER size_t GC_page_size = 0;
STATIC ptr_t GC_find_limit_with_bound(ptr_t p, GC_bool up, ptr_t bound)
{
static volatile ptr_t result;
- /* Safer if static, see that in GC_find_limit_openbsd. */
+ /* Safer if static, since otherwise it may not be */
+ /* preserved across the longjmp. Can safely be */
+ /* static since it's only called with the */
+ /* allocation lock held. */
GC_ASSERT(up ? (word)bound >= MIN_PAGE_SIZE
: (word)bound <= ~(word)MIN_PAGE_SIZE);
@@ -2091,11 +2040,7 @@ void GC_register_data_segments(void)
ABORT_ARG2("Wrong DATASTART/END pair",
": %p .. %p", (void *)region_start, (void *)DATAEND);
for (;;) {
-# ifdef GC_OPENBSD_UTHREADS
- ptr_t region_end = GC_find_limit_openbsd(region_start, DATAEND);
-# else
- ptr_t region_end = GC_find_limit_with_bound(region_start, TRUE, DATAEND);
-# endif
+ ptr_t region_end = GC_find_limit_with_bound(region_start, TRUE, DATAEND);
GC_add_roots_inner(region_start, region_end, FALSE);
if ((word)region_end >= (word)DATAEND)
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index f9e78ad7..5cbb6aea 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -23,19 +23,16 @@
#ifdef NACL
# include <unistd.h>
# include <sys/time.h>
-#elif defined(GC_OPENBSD_UTHREADS)
-# include <pthread_np.h>
#else
# include <signal.h>
# include <semaphore.h>
# include <errno.h>
# include <time.h> /* for nanosleep() */
# include <unistd.h>
-#endif /* !GC_OPENBSD_UTHREADS && !NACL */
+#endif /* !NACL */
-#ifndef GC_OPENBSD_UTHREADS
- GC_INLINE void GC_usleep(unsigned us)
- {
+GC_INLINE void GC_usleep(unsigned us)
+{
# if defined(LINT2) || defined(THREAD_SANITIZER)
/* Workaround "waiting while holding a lock" static analyzer warning. */
/* Workaround a rare hang in usleep() trying to acquire TSan Lock. */
@@ -51,8 +48,7 @@
# else
usleep(us);
# endif
- }
-#endif /* !GC_OPENBSD_UTHREADS */
+}
#ifdef NACL
@@ -66,7 +62,7 @@
volatile int GC_nacl_thread_parked[MAX_NACL_GC_THREADS];
int GC_nacl_thread_used[MAX_NACL_GC_THREADS];
-#elif !defined(GC_OPENBSD_UTHREADS)
+#else
#if (!defined(AO_HAVE_load_acquire) || !defined(AO_HAVE_store_release)) \
&& !defined(CPPCHECK)
@@ -769,7 +765,7 @@ STATIC void GC_restart_handler(int sig)
# undef ao_load_async
# undef ao_store_async
# undef ao_store_release_async
-#endif /* !GC_OPENBSD_UTHREADS && !NACL */
+#endif /* !NACL */
/* Should do exactly the right thing if the world is stopped; should */
/* not fail if it is not. */
@@ -923,51 +919,31 @@ STATIC int GC_suspend_all(void)
# ifndef NACL
GC_thread p;
pthread_t self = pthread_self();
-# ifndef GC_OPENBSD_UTHREADS
- int result;
+ int result;
- GC_ASSERT((GC_stop_count & THREAD_RESTARTED) == 0);
-# endif
+ GC_ASSERT((GC_stop_count & THREAD_RESTARTED) == 0);
GC_ASSERT(I_HOLD_LOCK());
for (i = 0; i < THREAD_TABLE_SZ; i++) {
for (p = GC_threads[i]; p != NULL; p = p -> tm.next) {
if (!THREAD_EQUAL(p -> id, self)) {
if ((p -> flags & (FINISHED | DO_BLOCKING)) != 0) continue;
-# ifndef GC_OPENBSD_UTHREADS
-# ifdef GC_ENABLE_SUSPEND_THREAD
+# ifdef GC_ENABLE_SUSPEND_THREAD
if ((p -> ext_suspend_cnt & 1) != 0) continue;
-# endif
- if (AO_load(&(p -> last_stop_count)) == GC_stop_count)
- continue; /* matters only if GC_retry_signals */
- n_live_threads++;
# endif
+ if (AO_load(&(p -> last_stop_count)) == GC_stop_count)
+ continue; /* matters only if GC_retry_signals */
+ n_live_threads++;
# ifdef DEBUG_THREADS
GC_log_printf("Sending suspend signal to %p\n", (void *)p->id);
# endif
-# ifdef GC_OPENBSD_UTHREADS
- {
- stack_t stack;
-
- GC_acquire_dirty_lock();
- if (pthread_suspend_np(p -> id) != 0)
- ABORT("pthread_suspend_np failed");
- GC_release_dirty_lock();
- if (pthread_stackseg_np(p->id, &stack))
- ABORT("pthread_stackseg_np failed");
- p -> stack_ptr = (ptr_t)stack.ss_sp - stack.ss_size;
- if (GC_on_thread_event)
- GC_on_thread_event(GC_EVENT_THREAD_SUSPENDED,
- (void *)p->id);
- }
-# else
/* The synchronization between GC_dirty (based on */
/* test-and-set) and the signal-based thread suspension */
/* is performed in GC_stop_world because */
/* GC_release_dirty_lock cannot be called before */
/* acknowledging the thread is really suspended. */
- result = raise_signal(p, GC_sig_suspend);
- switch(result) {
+ result = raise_signal(p, GC_sig_suspend);
+ switch (result) {
case ESRCH:
/* Not really there anymore. Possible? */
n_live_threads--;
@@ -981,8 +957,7 @@ STATIC int GC_suspend_all(void)
default:
ABORT_ARG1("pthread_kill failed at suspend",
": errcode= %d", result);
- }
-# endif
+ }
}
}
}
@@ -1042,7 +1017,7 @@ STATIC int GC_suspend_all(void)
GC_INNER void GC_stop_world(void)
{
-# if !defined(GC_OPENBSD_UTHREADS) && !defined(NACL)
+# if !defined(NACL)
int n_live_threads;
# endif
GC_ASSERT(I_HOLD_LOCK());
@@ -1065,7 +1040,7 @@ GC_INNER void GC_stop_world(void)
}
# endif /* PARALLEL_MARK */
-# if defined(GC_OPENBSD_UTHREADS) || defined(NACL)
+# if defined(NACL)
(void)GC_suspend_all();
# else
AO_store(&GC_stop_count, GC_stop_count + THREAD_RESTARTED);
@@ -1259,35 +1234,25 @@ GC_INNER void GC_stop_world(void)
int i;
pthread_t self = pthread_self();
GC_thread p;
-# ifndef GC_OPENBSD_UTHREADS
- int result;
+ int result;
- GC_ASSERT((GC_stop_count & THREAD_RESTARTED) != 0);
-# endif
+ GC_ASSERT((GC_stop_count & THREAD_RESTARTED) != 0);
for (i = 0; i < THREAD_TABLE_SZ; i++) {
for (p = GC_threads[i]; p != NULL; p = p -> tm.next) {
if (!THREAD_EQUAL(p -> id, self)) {
if ((p -> flags & (FINISHED | DO_BLOCKING)) != 0) continue;
-# ifndef GC_OPENBSD_UTHREADS
-# ifdef GC_ENABLE_SUSPEND_THREAD
+# ifdef GC_ENABLE_SUSPEND_THREAD
if ((p -> ext_suspend_cnt & 1) != 0) continue;
-# endif
- if (GC_retry_signals
+# endif
+ if (GC_retry_signals
&& AO_load(&(p -> last_stop_count)) == GC_stop_count)
continue; /* The thread has been restarted. */
- n_live_threads++;
-# endif
+ n_live_threads++;
# ifdef DEBUG_THREADS
GC_log_printf("Sending restart signal to %p\n", (void *)p->id);
# endif
-# ifdef GC_OPENBSD_UTHREADS
- if (pthread_resume_np(p -> id) != 0)
- ABORT("pthread_resume_np failed");
- if (GC_on_thread_event)
- GC_on_thread_event(GC_EVENT_THREAD_UNSUSPENDED, (void *)p->id);
-# else
- result = raise_signal(p, GC_sig_thr_restart);
- switch(result) {
+ result = raise_signal(p, GC_sig_thr_restart);
+ switch (result) {
case ESRCH:
/* Not really there anymore. Possible? */
n_live_threads--;
@@ -1300,8 +1265,7 @@ GC_INNER void GC_stop_world(void)
default:
ABORT_ARG1("pthread_kill failed at resume",
": errcode= %d", result);
- }
-# endif
+ }
}
}
}
@@ -1318,27 +1282,21 @@ GC_INNER void GC_start_world(void)
# ifdef DEBUG_THREADS
GC_log_printf("World starting\n");
# endif
-# ifndef GC_OPENBSD_UTHREADS
- AO_store_release(&GC_stop_count, GC_stop_count + THREAD_RESTARTED);
+ AO_store_release(&GC_stop_count, GC_stop_count + THREAD_RESTARTED);
/* The updated value should now be visible to the */
/* signal handler (note that pthread_kill is not on */
/* the list of functions which synchronize memory). */
-# endif
n_live_threads = GC_restart_all();
-# ifdef GC_OPENBSD_UTHREADS
- (void)n_live_threads;
-# else
- if (GC_retry_signals) {
+ if (GC_retry_signals) {
resend_lost_signals_retry(n_live_threads, GC_restart_all);
- } else {
+ } else {
# ifndef GC_NETBSD_THREADS_WORKAROUND
if (GC_sig_suspend == GC_sig_thr_restart)
# endif
{
suspend_restart_barrier(n_live_threads);
}
- }
-# endif
+ }
# ifdef DEBUG_THREADS
GC_log_printf("World started\n");
# endif
@@ -1355,7 +1313,7 @@ GC_INNER void GC_start_world(void)
GC_INNER void GC_stop_init(void)
{
-# if !defined(GC_OPENBSD_UTHREADS) && !defined(NACL)
+# if !defined(NACL)
struct sigaction act;
char *str;
@@ -1433,7 +1391,7 @@ GC_INNER void GC_stop_init(void)
/* Explicitly unblock the signals once before new threads creation. */
GC_unblock_gc_signals();
# endif
-# endif /* !GC_OPENBSD_UTHREADS && !NACL */
+# endif /* !NACL */
}
#endif /* PTHREAD_STOP_WORLD_IMPL */
diff --git a/tests/initfromthread.c b/tests/initfromthread.c
index 1a799e9e..9917309d 100644
--- a/tests/initfromthread.c
+++ b/tests/initfromthread.c
@@ -74,7 +74,7 @@ int main(void)
DWORD thread_id;
# endif
# if !(defined(BEOS) || defined(MSWIN32) || defined(MSWINCE) \
- || defined(CYGWIN32) || defined(GC_OPENBSD_UTHREADS) \
+ || defined(CYGWIN32) \
|| (defined(DARWIN) && !defined(NO_PTHREAD_GET_STACKADDR_NP)) \
|| ((defined(FREEBSD) || defined(LINUX) || defined(NETBSD) \
|| defined(HOST_ANDROID)) && !defined(NO_PTHREAD_GETATTR_NP) \