diff options
author | hboehm <hboehm> | 2006-03-10 05:24:07 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 21:06:36 +0400 |
commit | 65c2804e5bea35c0e3158c063644994d9239a8ab (patch) | |
tree | 894ec2e3323aa9ac0113b72ea0c13d6f886f1dad /pthread_support.c | |
parent | 541151996c2ec4b2168538796f3516a31279b806 (diff) | |
download | bdwgc-65c2804e5bea35c0e3158c063644994d9239a8ab.tar.gz |
2006-03-09 Hans Boehm <Hans.Boehm@hp.com>
Merge various gc6.7 changes (see doc/README.changes for contributors):
* configure.ac, pthread_stop_world.c, pthread_support.c,
threadlibs.c, include/gc_config_macros.h,
include/gc_pthread_redirects.h, include/leak_detector.h,
include/private/gcconfig.h, include/private/thread_local_alloc.h:
Add NetBSD threads support.
* dbg_mlc.c, malloc.c, include/gc.h: add GC_debug_str_dup, GC_str_dup.
* os_dep.c (GC_init_win32),
dyn_load.c (win32 GC_register_dynamic_libraries): accept
MEM_PRIVATE for Windows 98 etc.
* doc/gcinterface.html: Add warnings about thread locals and
in-flight exceptions.
* tests/tests.am: Add EXE extensions.
* Makefile.in, configure: rebuild
Diffstat (limited to 'pthread_support.c')
-rw-r--r-- | pthread_support.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pthread_support.c b/pthread_support.c index a8c3c6b8..4a283fb0 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -80,6 +80,11 @@ # include <sys/sysctl.h> #endif /* GC_DARWIN_THREADS */ +#if defined(GC_NETBSD_THREADS) +# include <sys/param.h> +# include <sys/sysctl.h> +#endif /* GC_NETBSD_THREADS */ + /* Allocator lock definitions. */ #if defined(USE_SPIN_LOCK) pthread_t GC_lock_holder = NO_THREAD; @@ -652,6 +657,18 @@ int GC_get_nprocs(void) } #endif /* GC_DGUX386_THREADS */ +#if defined(GC_NETBSD_THREADS) +static int get_ncpu(void) +{ + int mib[] = {CTL_HW,HW_NCPU}; + int res; + size_t len = sizeof(res); + + sysctl(mib, sizeof(mib)/sizeof(int), &res, &len, NULL, 0); + return res; +} +#endif /* GC_NETBSD_THREADS */ + /* We hold the allocation lock. */ void GC_thr_init(void) { @@ -698,6 +715,9 @@ void GC_thr_init(void) GC_nprocs = sysconf(_SC_NPROC_ONLN); if (GC_nprocs <= 0) GC_nprocs = 1; # endif +# if defined(GC_NETBSD_THREADS) + GC_nprocs = get_ncpu(); +# endif # if defined(GC_DARWIN_THREADS) || defined(GC_FREEBSD_THREADS) int ncpus = 1; size_t len = sizeof(ncpus); |