summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_mutex.c16
-rw-r--r--lib/libpthread/uthread/uthread_mutex.c16
2 files changed, 28 insertions, 4 deletions
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c
index 782808b5831..4fc3962fa83 100644
--- a/lib/libc_r/uthread/uthread_mutex.c
+++ b/lib/libc_r/uthread/uthread_mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_mutex.c,v 1.11 2000/01/06 07:19:35 d Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.12 2001/11/12 02:24:30 marc Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -134,7 +134,7 @@ pthread_mutex_init(pthread_mutex_t * mutex,
/* Check mutex protocol: */
else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) ||
- ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE))
+ ((*mutex_attr)->m_protocol > PTHREAD_PRIO_PROTECT))
/* Return an invalid argument error: */
ret = EINVAL;
@@ -438,6 +438,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Lock the mutex for this thread: */
(*mutex)->m_owner = _thread_run;
+ /* if recursive, increment the lock count */
+ if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
+ (*mutex)->m_data.m_count++;
+
/* Add to the list of owned mutexes: */
_MUTEX_ASSERT_NOT_OWNED(*mutex);
TAILQ_INSERT_TAIL(&_thread_run->mutexq,
@@ -477,6 +481,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Lock the mutex for this thread: */
(*mutex)->m_owner = _thread_run;
+ /* if recursive, increment the lock count */
+ if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
+ (*mutex)->m_data.m_count++;
+
/* Track number of priority mutexes owned: */
_thread_run->priority_mutex_count++;
@@ -541,6 +549,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
(*mutex)->m_owner = _thread_run;
+ /* if recursive, increment the lock count */
+ if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
+ (*mutex)->m_data.m_count++;
+
/* Track number of priority mutexes owned: */
_thread_run->priority_mutex_count++;
diff --git a/lib/libpthread/uthread/uthread_mutex.c b/lib/libpthread/uthread/uthread_mutex.c
index 782808b5831..4fc3962fa83 100644
--- a/lib/libpthread/uthread/uthread_mutex.c
+++ b/lib/libpthread/uthread/uthread_mutex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_mutex.c,v 1.11 2000/01/06 07:19:35 d Exp $ */
+/* $OpenBSD: uthread_mutex.c,v 1.12 2001/11/12 02:24:30 marc Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -134,7 +134,7 @@ pthread_mutex_init(pthread_mutex_t * mutex,
/* Check mutex protocol: */
else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) ||
- ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE))
+ ((*mutex_attr)->m_protocol > PTHREAD_PRIO_PROTECT))
/* Return an invalid argument error: */
ret = EINVAL;
@@ -438,6 +438,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Lock the mutex for this thread: */
(*mutex)->m_owner = _thread_run;
+ /* if recursive, increment the lock count */
+ if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
+ (*mutex)->m_data.m_count++;
+
/* Add to the list of owned mutexes: */
_MUTEX_ASSERT_NOT_OWNED(*mutex);
TAILQ_INSERT_TAIL(&_thread_run->mutexq,
@@ -477,6 +481,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
/* Lock the mutex for this thread: */
(*mutex)->m_owner = _thread_run;
+ /* if recursive, increment the lock count */
+ if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
+ (*mutex)->m_data.m_count++;
+
/* Track number of priority mutexes owned: */
_thread_run->priority_mutex_count++;
@@ -541,6 +549,10 @@ pthread_mutex_lock(pthread_mutex_t * mutex)
*/
(*mutex)->m_owner = _thread_run;
+ /* if recursive, increment the lock count */
+ if ((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE)
+ (*mutex)->m_data.m_count++;
+
/* Track number of priority mutexes owned: */
_thread_run->priority_mutex_count++;