diff options
| author | Daniel Eischen <deischen@FreeBSD.org> | 2003-11-04 19:53:32 +0000 |
|---|---|---|
| committer | Daniel Eischen <deischen@FreeBSD.org> | 2003-11-04 19:53:32 +0000 |
| commit | ee574ccc3ea9119e8c85602b930c9d3178cbb2d7 (patch) | |
| tree | 0a81637b0dcb21c20dcc36f406010c7fde859b73 /lib/libpthread/thread/thr_mutex.c | |
| parent | 358702366c7f1153b632164a0ebbbc2e54609c72 (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_mutex.c')
| -rw-r--r-- | lib/libpthread/thread/thr_mutex.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c index 0717768fc0b0..017baebfed9c 100644 --- a/lib/libpthread/thread/thr_mutex.c +++ b/lib/libpthread/thread/thr_mutex.c @@ -65,6 +65,11 @@ #endif #define THR_IN_MUTEXQ(thr) (((thr)->sflags & THR_FLAGS_IN_SYNCQ) != 0) +#define MUTEX_DESTROY(m) do { \ + _lock_destroy(&(m)->m_lock); \ + free(m); \ +} while (0) + /* * Prototypes @@ -192,8 +197,7 @@ _pthread_mutex_init(pthread_mutex_t *mutex, *mutex = pmutex; } else { /* Free the mutex lock structure: */ - _lock_destroy(&pmutex->m_lock); - free(pmutex); + MUTEX_DESTROY(pmutex); *mutex = NULL; } } @@ -202,6 +206,19 @@ _pthread_mutex_init(pthread_mutex_t *mutex, return (ret); } +void +_thr_mutex_reinit(pthread_mutex_t *mutex) +{ + _lock_reinit(&(*mutex)->m_lock, LCK_ADAPTIVE, + _thr_lock_wait, _thr_lock_wakeup); + TAILQ_INIT(&(*mutex)->m_queue); + (*mutex)->m_owner = NULL; + (*mutex)->m_count = 0; + (*mutex)->m_refcount = 0; + (*mutex)->m_prio = 0; + (*mutex)->m_saved_prio = 0; +} + int _pthread_mutex_destroy(pthread_mutex_t *mutex) { @@ -241,11 +258,7 @@ _pthread_mutex_destroy(pthread_mutex_t *mutex) * structure: */ MUTEX_ASSERT_NOT_OWNED(m); - - /* Free the mutex lock structure: */ - _lock_destroy(&m->m_lock); - - free(m); + MUTEX_DESTROY(m); } } |
