diff options
author | jb <jb@FreeBSD.org> | 1998-04-04 11:33:01 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1998-04-04 11:33:01 +0000 |
commit | ddcbf85eb29fd2d50ce1afa0243be370d4893370 (patch) | |
tree | 6098bb7060d793dec64ddd28bc6d9cda781d96ed /lib/libc_r/uthread/uthread_mutex.c | |
parent | 43c228762029d6d4e7c66cfd6c4d1e88d807dba1 (diff) | |
download | FreeBSD-src-ddcbf85eb29fd2d50ce1afa0243be370d4893370.zip FreeBSD-src-ddcbf85eb29fd2d50ce1afa0243be370d4893370.tar.gz |
Enable static initialisation of mutexes and condition variables.
Diffstat (limited to 'lib/libc_r/uthread/uthread_mutex.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_mutex.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c index e6be6de..9f92de9 100644 --- a/lib/libc_r/uthread/uthread_mutex.c +++ b/lib/libc_r/uthread/uthread_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); |