diff options
| author | John Birrell <jb@FreeBSD.org> | 1998-04-04 11:33:01 +0000 |
|---|---|---|
| committer | John Birrell <jb@FreeBSD.org> | 1998-04-04 11:33:01 +0000 |
| commit | 883674371ecbe1ce8376f70836be251397ae5327 (patch) | |
| tree | 1b8ef2058be111839002ca671ab1552c6319d3fb /lib/libpthread/thread/thr_mutex.c | |
| parent | 5a2f1fed77fef948b36091c15bfcdda586756bc8 (diff) | |
Notes
Diffstat (limited to 'lib/libpthread/thread/thr_mutex.c')
| -rw-r--r-- | lib/libpthread/thread/thr_mutex.c | 20 |
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); |
