summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_mutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libkse/thread/thr_mutex.c')
-rw-r--r--lib/libkse/thread/thr_mutex.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c
index 0717768..017baeb 100644
--- a/lib/libkse/thread/thr_mutex.c
+++ b/lib/libkse/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);
}
}
OpenPOWER on IntegriCloud