diff options
author | wtc%netscape.com <devnull@localhost> | 1999-02-01 20:01:36 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 1999-02-01 20:01:36 +0000 |
commit | 0dba64a94f19d567ba61041f3da999c00dc84958 (patch) | |
tree | 749da7938d4d96024a6f07e65bef0b9a082ef7ca | |
parent | eb6ddec1aaedd5a9c64ee6b1890bb6bcbc6c2c00 (diff) | |
download | nspr-hg-0dba64a94f19d567ba61041f3da999c00dc84958.tar.gz |
In _PR_InitThreads, call pthread_init to explicitly initialize the
pthread subsystem on BSD/OS because pthread_self() fails to initialize
pthreads implicitly. This patch is contributed by Bert Driehuis
<bert_driehuis@nl.compuware.com>.
-rw-r--r-- | config/BSD_OS.mk | 1 | ||||
-rw-r--r-- | pr/src/pthreads/ptthread.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/config/BSD_OS.mk b/config/BSD_OS.mk index 0a20d6b5..02156a8f 100644 --- a/config/BSD_OS.mk +++ b/config/BSD_OS.mk @@ -32,6 +32,7 @@ RANLIB = ranlib ifeq ($(USE_PTHREADS),1) IMPL_STRATEGY = _PTH +DEFINES += -D_PR_NEED_PTHREAD_INIT else IMPL_STRATEGY = _EMU DEFINES += -D_PR_LOCAL_THREADS_ONLY diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c index d69220c6..ba17c61b 100644 --- a/pr/src/pthreads/ptthread.c +++ b/pr/src/pthreads/ptthread.c @@ -745,6 +745,17 @@ void _PR_InitThreads( int rv; PRThread *thred; +#ifdef _PR_NEED_PTHREAD_INIT + /* + * On BSD/OS (3.1 and 4.0), the pthread subsystem is lazily + * initialized, but pthread_self() fails to initialize + * pthreads and hence returns a null thread ID if invoked + * by the primordial thread before any other pthread call. + * So we explicitly initialize pthreads here. + */ + pthread_init(); +#endif + #if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING) /* ** These might be function evaluations |