Implement mutex_trylock_recursive() in the LinuxKPI.
MFC after: 1 week Submitted by: Johannes Lundberg <johalun0@gmail.com> Sponsored by: Mellanox Technologies
This commit is contained in:
parent
10ee3d3016
commit
f4824a028d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329378
@ -77,6 +77,21 @@ typedef struct mutex {
|
|||||||
!!sx_try_xlock(&(_m)->sx); \
|
!!sx_try_xlock(&(_m)->sx); \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
enum mutex_trylock_recursive_enum {
|
||||||
|
MUTEX_TRYLOCK_FAILED = 0,
|
||||||
|
MUTEX_TRYLOCK_SUCCESS = 1,
|
||||||
|
MUTEX_TRYLOCK_RECURSIVE = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline __must_check enum mutex_trylock_recursive_enum
|
||||||
|
mutex_trylock_recursive(struct mutex *lock)
|
||||||
|
{
|
||||||
|
if (unlikely(sx_xholder(&lock->sx) == curthread))
|
||||||
|
return (MUTEX_TRYLOCK_RECURSIVE);
|
||||||
|
|
||||||
|
return (mutex_trylock(lock));
|
||||||
|
}
|
||||||
|
|
||||||
#define mutex_init(_m) \
|
#define mutex_init(_m) \
|
||||||
linux_mutex_init(_m, mutex_name(#_m), SX_NOWITNESS)
|
linux_mutex_init(_m, mutex_name(#_m), SX_NOWITNESS)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user