openbsd-ports/devel/boehm-gc/patches/patch-pthread_support_c
kurt fd66a02930 Get GC_nprocs from sysconf _SC_NPROCESSORS_ONLN instead of
hardcoding to 1. From Brad Smith <brad@comstyle.com> tested
in bulk build by naddy@
2012-04-30 15:33:16 +00:00

44 lines
1.6 KiB
Plaintext

$OpenBSD: patch-pthread_support_c,v 1.3 2012/04/30 15:33:16 kurt Exp $
--- pthread_support.c.orig Tue May 15 01:24:46 2007
+++ pthread_support.c Tue Mar 6 10:24:21 2012
@@ -763,7 +763,7 @@ void GC_thr_init(void)
GC_nprocs = pthread_num_processors_np();
# endif
# if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) \
- || defined(GC_SOLARIS_THREADS)
+ || defined(GC_SOLARIS_THREADS) || defined(GC_OPENBSD_THREADS)
GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (GC_nprocs <= 0) GC_nprocs = 1;
# endif
@@ -848,7 +848,7 @@ void GC_init_parallel(void)
}
-#if !defined(GC_DARWIN_THREADS)
+#if !defined(GC_DARWIN_THREADS) && !defined(GC_OPENBSD_THREADS)
int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset)
{
sigset_t fudged_set;
@@ -1103,6 +1103,12 @@ void * GC_start_routine(void * arg)
GC_enable();
# endif
return GC_inner_start_routine(&sb, arg);
+# elif defined(GC_OPENBSD_THREADS)
+ /* On OpenBSD GC_get_stack_base() doesn't cause any allocations */
+ struct GC_stack_base sb;
+ if (GC_get_stack_base(&sb) != GC_SUCCESS)
+ ABORT("Failed to get thread stack base.");
+ return GC_inner_start_routine(&sb, arg);
# else
return GC_call_with_stack_base(GC_inner_start_routine, arg);
# endif
@@ -1297,7 +1303,7 @@ void GC_generic_lock(pthread_mutex_t * lock)
/* as STL alloc.h. This isn't really the right way to do this. */
/* but until the POSIX scheduling mess gets straightened out ... */
-volatile AO_TS_t GC_allocate_lock = 0;
+volatile AO_TS_t GC_allocate_lock = AO_TS_INITIALIZER;
void GC_lock(void)