Port boehm-gc rthread support from boehm-gc port. Tested in bulk by espie@
This commit is contained in:
parent
17110c98ef
commit
1805bc8d2b
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.74 2012/01/23 22:20:34 espie Exp $
|
||||
# $OpenBSD: Makefile,v 1.75 2012/02/22 12:40:04 kurt Exp $
|
||||
|
||||
ONLY_FOR_ARCHS = alpha i386 m68k sparc sparc64 powerpc vax amd64
|
||||
#BROKEN=adjust for types changes
|
||||
@ -23,7 +23,7 @@ REVISION-main = 7
|
||||
REVISION-c++ = 10
|
||||
REVISION-estdc = 1
|
||||
REVISION-f95 = 9
|
||||
REVISION-java = 7
|
||||
REVISION-java = 8
|
||||
REVISION-objc = 8
|
||||
REVISION-ada = 7
|
||||
EPOCH = 0
|
||||
|
@ -1,30 +0,0 @@
|
||||
$OpenBSD: patch-boehm-gc_Makefile_in,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
--- boehm-gc/Makefile.in.orig Mon May 19 10:28:07 2008
|
||||
+++ boehm-gc/Makefile.in Tue Apr 21 17:22:04 2009
|
||||
@@ -82,6 +82,7 @@ CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 =
|
||||
@POWERPC_DARWIN_TRUE@am__objects_1 = powerpc_darwin_mach_dep.lo
|
||||
+@OPENBSD_THREADS_TRUE@am__objects_1 = openbsd_stop_world.lo
|
||||
am_libgcjgc_la_OBJECTS = allchblk.lo alloc.lo blacklst.lo checksums.lo \
|
||||
dbg_mlc.lo dyn_load.lo finalize.lo gc_dlopen.lo gcj_mlc.lo \
|
||||
headers.lo malloc.lo mallocx.lo mark.lo mark_rts.lo misc.lo \
|
||||
@@ -189,6 +190,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
POWERPC_DARWIN_FALSE = @POWERPC_DARWIN_FALSE@
|
||||
POWERPC_DARWIN_TRUE = @POWERPC_DARWIN_TRUE@
|
||||
+OPENBSD_THREADS_FALSE = @OPENBSD_THREADS_FALSE@
|
||||
+OPENBSD_THREADS_TRUE = @OPENBSD_THREADS_TRUE@
|
||||
RANLIB = @RANLIB@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
@@ -257,8 +260,8 @@ AUTOMAKE_OPTIONS = cygnus subdir-objects
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
SUBDIRS = include
|
||||
noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
|
||||
-@POWERPC_DARWIN_FALSE@asm_libgcjgc_sources =
|
||||
@POWERPC_DARWIN_TRUE@asm_libgcjgc_sources = powerpc_darwin_mach_dep.s
|
||||
+@OPENBSD_THREADS_TRUE@asm_libgcjgc_sources = openbsd_stop_world.c.s
|
||||
libgcjgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
|
||||
dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c \
|
||||
malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
|
@ -1,16 +1,7 @@
|
||||
$OpenBSD: patch-boehm-gc_configure,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
$OpenBSD: patch-boehm-gc_configure,v 1.2 2012/02/22 12:40:04 kurt Exp $
|
||||
--- boehm-gc/configure.orig Mon May 19 10:28:07 2008
|
||||
+++ boehm-gc/configure Tue Apr 21 17:28:23 2009
|
||||
@@ -309,7 +309,7 @@ ac_includes_default="\
|
||||
# include <unistd.h>
|
||||
#endif"
|
||||
|
||||
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical mkinstalldirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CFLAGS CXXFLAGS CCAS CCASFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GC_CFLAGS LN_S LIBTOOL CXXCPP CPPFLAGS THREADLIBS POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE extra_ldflags_libgc EXTRA_TEST_LIBS target_all CPLUSPLUS_TRUE CPLUSPLUS_FALSE AM_CPPFLAGS addobjs addincludes addlibs addtests CPP EGREP MY_CFLAGS toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
|
||||
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical mkinstalldirs INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CXX ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CFLAGS CXXFLAGS CCAS CCASFLAGS AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GC_CFLAGS LN_S LIBTOOL CXXCPP CPPFLAGS THREADLIBS POWERPC_DARWIN_TRUE POWERPC_DARWIN_FALSE OPENBSD_THREADS_TRUE OPENBSD_THREADS_FALSE extra_ldflags_libgc EXTRA_TEST_LIBS target_all CPLUSPLUS_TRUE CPLUSPLUS_FALSE AM_CPPFLAGS addobjs addincludes addlibs addtests CPP EGREP MY_CFLAGS toolexecdir toolexeclibdir LIBOBJS LTLIBOBJS'
|
||||
ac_subst_files=''
|
||||
|
||||
# Initialize some variables set by options.
|
||||
@@ -5451,6 +5451,15 @@ _ACEOF
|
||||
+++ boehm-gc/configure Mon Feb 20 13:13:23 2012
|
||||
@@ -5451,6 +5451,14 @@ _ACEOF
|
||||
{ echo "$as_me:$LINENO: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&5
|
||||
echo "$as_me: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&2;}
|
||||
;;
|
||||
@ -21,43 +12,17 @@ $OpenBSD: patch-boehm-gc_configure,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
+
|
||||
+ THREADDLLIBS=-pthread
|
||||
+ INCLUDES="$INCLUDES -pthread"
|
||||
+ openbsd_threads=true
|
||||
+ ;;
|
||||
*-*-kfreebsd*-gnu)
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define GC_FREEBSD_THREADS 1
|
||||
@@ -5630,7 +5639,15 @@ else
|
||||
POWERPC_DARWIN_FALSE=
|
||||
fi
|
||||
|
||||
+if test x$openbsd_threads = xtrue; then
|
||||
+ OPENBSD_THREADS_TRUE=
|
||||
+ OPENBSD_THREADS_FALSE='#'
|
||||
+else
|
||||
+ OPENBSD_THREADS_TRUE='#'
|
||||
+ OPENBSD_THREADS_FALSE=
|
||||
+fi
|
||||
|
||||
+
|
||||
# Darwin needs a few extra special tests to deal with variation in the
|
||||
# system headers.
|
||||
case "$host" in
|
||||
@@ -6887,6 +6904,9 @@ _ACEOF
|
||||
@@ -6886,6 +6894,9 @@ _ACEOF
|
||||
;;
|
||||
sparc-*-netbsd*)
|
||||
machdep="sparc_netbsd_mach_dep.lo"
|
||||
;;
|
||||
+ ;;
|
||||
+ sparc*-*-openbsd*)
|
||||
+ machdep="sparc_mach_dep.lo"
|
||||
+ ;;
|
||||
;;
|
||||
sparc-sun-solaris2.3)
|
||||
machdep="sparc_mach_dep.lo"
|
||||
|
||||
@@ -8482,6 +8502,8 @@ s,@CPPFLAGS@,$CPPFLAGS,;t t
|
||||
s,@THREADLIBS@,$THREADLIBS,;t t
|
||||
s,@POWERPC_DARWIN_TRUE@,$POWERPC_DARWIN_TRUE,;t t
|
||||
s,@POWERPC_DARWIN_FALSE@,$POWERPC_DARWIN_FALSE,;t t
|
||||
+s,@OPENBSD_THREADS_TRUE@,$OPENBSD_THREADS_TRUE,;t t
|
||||
+s,@OPENBSD_THREADS_FALSE@,$OPENBSD_THREADS_FALSE,;t t
|
||||
s,@extra_ldflags_libgc@,$extra_ldflags_libgc,;t t
|
||||
s,@EXTRA_TEST_LIBS@,$EXTRA_TEST_LIBS,;t t
|
||||
s,@target_all@,$target_all,;t t
|
||||
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 kurt Exp $
|
||||
$OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.3 2012/02/22 12:40:04 kurt Exp $
|
||||
--- boehm-gc/include/private/gcconfig.h.orig Mon Jul 2 10:59:47 2007
|
||||
+++ boehm-gc/include/private/gcconfig.h Sun Oct 31 13:36:53 2010
|
||||
+++ boehm-gc/include/private/gcconfig.h Mon Feb 20 13:18:13 2012
|
||||
@@ -62,7 +62,7 @@
|
||||
/* Determine the machine type: */
|
||||
# if defined(__arm__) || defined(__thumb__)
|
||||
@ -109,9 +109,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
+# ifdef OPENBSD
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# define ALIGNMENT 4
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 268
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -134,9 +134,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
-# define STACKBOTTOM ((ptr_t) 0xf8000000)
|
||||
- extern int etext[];
|
||||
-# define DATASTART ((ptr_t)(etext))
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 232
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -155,9 +155,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
# endif
|
||||
# ifdef OPENBSD
|
||||
# define OS_TYPE "OPENBSD"
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 192
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -188,9 +188,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
+# ifdef OPENBSD
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# define ALIGNMENT 4
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 808
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -223,9 +223,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
# endif /* LINUX */
|
||||
+# ifdef OPENBSD
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 520
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -255,9 +255,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
-# define DATASTART ((ptr_t) 0x140000000)
|
||||
-# endif
|
||||
+# define ELF_CLASS ELFCLASS64
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 816
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -287,9 +287,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
+# ifdef OPENBSD
|
||||
+# define ALIGNMENT 4
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 176
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -311,9 +311,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
# endif
|
||||
+# ifdef OPENBSD
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 332
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
@ -337,9 +337,9 @@ $OpenBSD: patch-boehm-gc_include_private_gcconfig_h,v 1.2 2010/10/31 22:38:42 ku
|
||||
+# ifdef OPENBSD
|
||||
+# define OS_TYPE "OPENBSD"
|
||||
+# define ELF_CLASS ELFCLASS64
|
||||
+# ifdef GC_OPENBSD_THREADS
|
||||
+# define UTHREAD_SP_OFFSET 400
|
||||
+# else
|
||||
+# define SIG_SUSPEND SIGUSR1
|
||||
+# define SIG_THR_RESTART SIGUSR2
|
||||
+# ifndef GC_OPENBSD_THREADS
|
||||
+# include <sys/param.h>
|
||||
+# include <uvm/uvm_extern.h>
|
||||
+# define STACKBOTTOM USRSTACK
|
||||
|
@ -1,16 +0,0 @@
|
||||
$OpenBSD: patch-boehm-gc_include_private_openbsd_stop_world_h,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
--- boehm-gc/include/private/openbsd_stop_world.h.orig Thu Mar 5 17:44:00 2009
|
||||
+++ boehm-gc/include/private/openbsd_stop_world.h Thu Mar 5 17:44:00 2009
|
||||
@@ -0,0 +1,12 @@
|
||||
+#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
|
@ -1,188 +0,0 @@
|
||||
$OpenBSD: patch-boehm-gc_openbsd_stop_world_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
--- boehm-gc/openbsd_stop_world.c.orig Thu Mar 12 15:07:24 2009
|
||||
+++ boehm-gc/openbsd_stop_world.c Thu Mar 12 18:07:50 2009
|
||||
@@ -0,0 +1,184 @@
|
||||
+#include "private/pthread_support.h"
|
||||
+
|
||||
+/* derived from pthread_stop_world.c */
|
||||
+
|
||||
+# if defined(GC_OPENBSD_THREADS)
|
||||
+
|
||||
+/* 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_printf1("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 (pthread_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_printf3("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 (GC_print_stats) {
|
||||
+ GC_printf1("Pushed %d thread stacks\n", nthreads);
|
||||
+ }
|
||||
+ 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 (!pthread_equal(p -> id, my_thread)) {
|
||||
+ if (p -> flags & FINISHED) continue;
|
||||
+ if (p -> thread_blocked) /* Will wait */ continue;
|
||||
+# if DEBUG_THREADS
|
||||
+ GC_printf1("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_printf1("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_printf1("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_printf0("World starting\n");
|
||||
+# endif
|
||||
+
|
||||
+ for (i = 0; i < THREAD_TABLE_SZ; i++) {
|
||||
+ for (p = GC_threads[i]; p != 0; p = p -> next) {
|
||||
+ if (!pthread_equal(p -> id, my_thread)) {
|
||||
+ if (p -> flags & FINISHED) continue;
|
||||
+ if (p -> thread_blocked) continue;
|
||||
+ #if DEBUG_THREADS
|
||||
+ GC_printf1("Resuming thread 0x%x\n",
|
||||
+ (unsigned)(p -> id));
|
||||
+ #endif
|
||||
+
|
||||
+ if (pthread_resume_np(p -> id) != 0)
|
||||
+ ABORT("pthread_kill failed");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+# if DEBUG_THREADS
|
||||
+ GC_printf0("World started\n");
|
||||
+# endif
|
||||
+}
|
||||
+
|
||||
+void GC_stop_init() {
|
||||
+}
|
||||
+
|
||||
+void GC_suspend_thread(pthread_t thread) {
|
||||
+ if (thread == pthread_self()) {
|
||||
+ ABORT("attempting to suspend self");
|
||||
+ } else {
|
||||
+ GC_thread t = GC_lookup_thread(thread);
|
||||
+ if (t == NULL)
|
||||
+ ABORT("attempting to suspend unknown thread");
|
||||
+
|
||||
+ if (pthread_suspend_np(t -> id) != 0)
|
||||
+ ABORT("pthread_suspend_np failed");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void GC_resume_thread(pthread_t thread) {
|
||||
+ GC_thread t = GC_lookup_thread(thread);
|
||||
+ if (t == NULL)
|
||||
+ ABORT("attempting to resume unknown thread");
|
||||
+
|
||||
+ if (pthread_resume_np(t -> id) != 0)
|
||||
+ ABORT("pthread_resume_np failed");
|
||||
+}
|
||||
+
|
||||
+#endif
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
--- boehm-gc/os_dep.c.orig Tue Jan 16 14:44:17 2007
|
||||
+++ boehm-gc/os_dep.c Thu Mar 5 17:11:21 2009
|
||||
$OpenBSD: patch-boehm-gc_os_dep_c,v 1.2 2012/02/22 12:40:04 kurt Exp $
|
||||
--- boehm-gc/os_dep.c.orig Sat May 19 08:18:32 2007
|
||||
+++ boehm-gc/os_dep.c Mon Feb 20 13:21:24 2012
|
||||
@@ -380,7 +380,7 @@ static void *tiny_sbrk(ptrdiff_t increment)
|
||||
#define sbrk tiny_sbrk
|
||||
# endif /* ECOS */
|
||||
@ -10,7 +10,7 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
ptr_t GC_data_start;
|
||||
|
||||
void GC_init_netbsd_elf()
|
||||
@@ -393,6 +393,103 @@ static void *tiny_sbrk(ptrdiff_t increment)
|
||||
@@ -393,6 +393,86 @@ static void *tiny_sbrk(ptrdiff_t increment)
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -18,18 +18,6 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
+ static struct sigaction old_segv_act;
|
||||
+ sigjmp_buf GC_jmp_buf_openbsd;
|
||||
+
|
||||
+# if defined(GC_OPENBSD_THREADS)
|
||||
+# include <sys/syscall.h>
|
||||
+ sigset_t __syscall(quad_t, ...);
|
||||
+# endif
|
||||
+
|
||||
+ /*
|
||||
+ * Dont use GC_find_limit() because siglongjmp out 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.
|
||||
+ */
|
||||
+
|
||||
+ /*ARGSUSED*/
|
||||
+ void GC_fault_handler_openbsd(int sig)
|
||||
+ {
|
||||
@ -67,11 +55,6 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+# if defined(GC_OPENBSD_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);
|
||||
@ -114,7 +97,7 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
# ifdef OS2
|
||||
|
||||
# include <stddef.h>
|
||||
@@ -1007,7 +1104,8 @@ ptr_t GC_get_stack_base()
|
||||
@@ -1007,7 +1087,8 @@ ptr_t GC_get_stack_base()
|
||||
#endif /* FREEBSD_STACKBOTTOM */
|
||||
|
||||
#if !defined(BEOS) && !defined(AMIGA) && !defined(MSWIN32) \
|
||||
@ -124,7 +107,7 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
|
||||
ptr_t GC_get_stack_base()
|
||||
{
|
||||
@@ -1067,6 +1165,23 @@ ptr_t GC_get_stack_base()
|
||||
@@ -1067,6 +1148,23 @@ ptr_t GC_get_stack_base()
|
||||
|
||||
# endif /* ! AMIGA, !OS 2, ! MS Windows, !BEOS, !NOSYS, !ECOS */
|
||||
|
||||
@ -148,7 +131,7 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
/*
|
||||
* Register static data segment(s) as roots.
|
||||
* If more data segments are added later then they need to be registered
|
||||
@@ -1434,6 +1549,31 @@ int * etext_addr;
|
||||
@@ -1434,6 +1532,31 @@ int * etext_addr;
|
||||
|
||||
#else /* !OS2 && !Windows && !AMIGA */
|
||||
|
||||
@ -180,7 +163,7 @@ $OpenBSD: patch-boehm-gc_os_dep_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
void GC_register_data_segments()
|
||||
{
|
||||
# if !defined(PCR) && !defined(SRC_M3) && !defined(MACOS)
|
||||
@@ -1491,6 +1631,7 @@ void GC_register_data_segments()
|
||||
@@ -1491,6 +1614,7 @@ void GC_register_data_segments()
|
||||
/* change. */
|
||||
}
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
$OpenBSD: patch-boehm-gc_pthread_stop_world_c,v 1.1 2009/06/04 18:24:20 kurt Exp $
|
||||
--- boehm-gc/pthread_stop_world.c.orig Thu Mar 5 17:50:41 2009
|
||||
+++ boehm-gc/pthread_stop_world.c Thu Mar 5 17:51:12 2009
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "private/pthread_support.h"
|
||||
|
||||
#if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
|
||||
- && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS)
|
||||
+ && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS) \
|
||||
+ && !defined(GC_OPENBSD_THREADS)
|
||||
|
||||
#include <signal.h>
|
||||
#include <semaphore.h>
|
Loading…
Reference in New Issue
Block a user