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
This commit is contained in:
parent
8dbd3d1b6b
commit
5fd410a787
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=175958
@ -53,6 +53,7 @@ int pthread_mutex_getspinloops_np(pthread_mutex_t *mutex, int *count);
|
||||
int pthread_mutex_setspinloops_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);
|
||||
int pthread_single_np(void);
|
||||
void pthread_suspend_all_np(void);
|
||||
int pthread_suspend_np(pthread_t);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user