summaryrefslogtreecommitdiff
path: root/lib/libpthread/thread/thr_mutex.c
diff options
context:
space:
mode:
authorJohn Birrell <jb@FreeBSD.org>1998-04-04 11:33:01 +0000
committerJohn Birrell <jb@FreeBSD.org>1998-04-04 11:33:01 +0000
commit883674371ecbe1ce8376f70836be251397ae5327 (patch)
tree1b8ef2058be111839002ca671ab1552c6319d3fb /lib/libpthread/thread/thr_mutex.c
parent5a2f1fed77fef948b36091c15bfcdda586756bc8 (diff)
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_mutex.c')
-rw-r--r--lib/libpthread/thread/thr_mutex.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c
index e6be6def2726..9f92de9eb3e8 100644
--- a/lib/libpthread/thread/thr_mutex.c
+++ b/lib/libpthread/thread/thr_mutex.c
@@ -162,9 +162,15 @@ pthread_mutex_trylock(pthread_mutex_t * mutex)
int ret = 0;
int status;
- if (mutex == NULL || *mutex == NULL) {
+ if (mutex == NULL)
ret = EINVAL;
- } else {
+
+ /*
+ * If the mutex is statically initialized, perform the dynamic
+ * initialization:
+ */
+ else if (*mutex != NULL ||
+ (ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);
@@ -224,9 +230,15 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
int ret = 0;
int status;
- if (mutex == NULL || *mutex == NULL) {
+ if (mutex == NULL)
ret = EINVAL;
- } else {
+
+ /*
+ * If the mutex is statically initialized, perform the dynamic
+ * initialization:
+ */
+ else if (*mutex != NULL ||
+ (ret = pthread_mutex_init(mutex,NULL)) == 0) {
/* Block signals: */
_thread_kern_sig_block(&status);