diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-02-15 23:05:03 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-02-15 23:05:03 +0000 |
commit | 70ea4e132359aaa66ab3c49f65cd52862e567a25 (patch) | |
tree | 4667ae22d4df766567efd53444eaef98d821d6c9 | |
parent | ad011f6a36d4d13210e325ce8c3e5930c94dff78 (diff) | |
download | FreeBSD-src-70ea4e132359aaa66ab3c49f65cd52862e567a25.zip FreeBSD-src-70ea4e132359aaa66ab3c49f65cd52862e567a25.tar.gz |
Rework last change of pthread_once, create a function _thr_once_init to
reinitialize its internal locks.
-rw-r--r-- | lib/libthr/thread/thr_init.c | 3 | ||||
-rw-r--r-- | lib/libthr/thread/thr_once.c | 10 | ||||
-rw-r--r-- | lib/libthr/thread/thr_private.h | 3 |
3 files changed, 10 insertions, 6 deletions
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 61621dc..026f73c 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -412,8 +412,7 @@ init_private(void) _thr_umtx_init(&_keytable_lock); _thr_umtx_init(&_thr_atfork_lock); _thr_umtx_init(&_thr_event_lock); - _thr_once_lock = PTHREAD_MUTEX_INITIALIZER; - _thr_once_cv = PTHREAD_COND_INITIALIZER; + _thr_once_init(); _thr_spinlock_init(); _thr_list_init(); diff --git a/lib/libthr/thread/thr_once.c b/lib/libthr/thread/thr_once.c index 98360f2..4fe392c 100644 --- a/lib/libthr/thread/thr_once.c +++ b/lib/libthr/thread/thr_once.c @@ -40,8 +40,8 @@ __weak_reference(_pthread_once, pthread_once); #define ONCE_IN_PROGRESS 0x02 #define ONCE_MASK 0x03 -pthread_mutex_t _thr_once_lock = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t _thr_once_cv = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t _thr_once_lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_cond_t _thr_once_cv = PTHREAD_COND_INITIALIZER; /* * POSIX: @@ -91,3 +91,9 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine) (void)) return (0); } +void +_thr_once_init() +{ + _thr_once_lock = PTHREAD_MUTEX_INITIALIZER; + _thr_once_cv = PTHREAD_COND_INITIALIZER; +} diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index c6c9d22..60be095 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -649,8 +649,6 @@ extern umtx_t _rwlock_static_lock __hidden; extern umtx_t _keytable_lock __hidden; extern umtx_t _thr_list_lock __hidden; extern umtx_t _thr_event_lock __hidden; -extern pthread_mutex_t _thr_once_lock __hidden; -extern pthread_cond_t _thr_once_cv __hidden; /* * Function prototype definitions. @@ -727,6 +725,7 @@ void _thr_suspend_check(struct pthread *) __hidden; void _thr_assert_lock_level(void) __hidden __dead2; void _thr_ast(struct pthread *) __hidden; void _thr_timer_init(void) __hidden; +void _thr_once_init(void) __hidden; void _thr_report_creation(struct pthread *curthread, struct pthread *newthread) __hidden; void _thr_report_death(struct pthread *curthread) __hidden; |