summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2008-02-03 22:38:10 +0000
committerdes <des@FreeBSD.org>2008-02-03 22:38:10 +0000
commit72d185548f88b6924d5a926aa9b6877ebe113169 (patch)
tree79362381794d659312db4ce0c9cff22878c851bf /lib/libthr
parentd645bec45a695d4bcad9263c30977af43db44b19 (diff)
downloadFreeBSD-src-72d185548f88b6924d5a926aa9b6877ebe113169.zip
FreeBSD-src-72d185548f88b6924d5a926aa9b6877ebe113169.tar.gz
Add pthread_mutex_islocked_np(), a cheap way to verify that a mutex is
locked. This is intended primarily to support the userland equivalent of the various *_ASSERT_LOCKED() macros we have in the kernel. MFC after: 2 weeks
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/pthread.map15
-rw-r--r--lib/libthr/thread/thr_mutex.c16
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map
index c6e146b..dfd6c00 100644
--- a/lib/libthr/pthread.map
+++ b/lib/libthr/pthread.map
@@ -395,3 +395,18 @@ global:
local:
*;
};
+
+FBSD_1.1 {
+global:
+ pthread_mutex_islocked_np;
+local:
+ *;
+} FBSD_1.0;
+
+FBSDprivate_1.1 {
+global:
+ _pthread_mutex_islocked_np;
+local:
+ *;
+} FBSDprivate_1.0;
+
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 6a97761..032f2e3 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -87,6 +87,7 @@ int __pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count);
int _pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count);
int _pthread_mutex_getyieldloops_np(pthread_mutex_t *mutex, int *count);
int __pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count);
+int _pthread_mutex_islocked_np(pthread_mutex_t *mutex);
static int mutex_self_trylock(pthread_mutex_t);
static int mutex_self_lock(pthread_mutex_t,
@@ -111,6 +112,7 @@ __weak_reference(_pthread_mutex_getspinloops_np, pthread_mutex_getspinloops_np);
__weak_reference(__pthread_mutex_setyieldloops_np, pthread_mutex_setyieldloops_np);
__weak_reference(_pthread_mutex_getyieldloops_np, pthread_mutex_getyieldloops_np);
+__weak_reference(_pthread_mutex_islocked_np, pthread_mutex_islocked_np);
static int
mutex_init(pthread_mutex_t *mutex,
@@ -863,3 +865,17 @@ __pthread_mutex_setyieldloops_np(pthread_mutex_t *mutex, int count)
(*mutex)->m_yieldloops = count;
return (0);
}
+
+int
+_pthread_mutex_islocked_np(pthread_mutex_t *mutex)
+{
+ struct pthread *curthread = _get_curthread();
+ int ret;
+
+ if (__predict_false(*mutex == NULL)) {
+ ret = init_static(curthread, mutex);
+ if (__predict_false(ret))
+ return (ret);
+ }
+ return ((*mutex)->m_qe.tqe_prev != NULL);
+}
OpenPOWER on IntegriCloud