summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_mutex.c
diff options
context:
space:
mode:
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 e6be6de..9f92de9 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);
OpenPOWER on IntegriCloud