rwlock: add __rw_try_{r,w}lock_int

This commit is contained in:
Mateusz Guzik 2017-11-25 20:22:51 +00:00
parent cec1747322
commit c1e1a7ec30

View File

@ -284,9 +284,8 @@ _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line)
}
int
__rw_try_wlock(volatile uintptr_t *c, const char *file, int line)
__rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
{
struct rwlock *rw;
struct thread *td;
uintptr_t tid, v;
int rval;
@ -297,8 +296,6 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file, int line)
if (SCHEDULER_STOPPED_TD(td))
return (1);
rw = rwlock2rw(c);
KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(td),
("rw_try_wlock() by idle thread %p on rwlock %s @ %s:%d",
curthread, rw->lock_object.lo_name, file, line));
@ -334,6 +331,15 @@ __rw_try_wlock(volatile uintptr_t *c, const char *file, int line)
return (rval);
}
int
__rw_try_wlock(volatile uintptr_t *c, const char *file, int line)
{
struct rwlock *rw;
rw = rwlock2rw(c);
return (__rw_try_wlock_int(rw, LOCK_FILE_LINE_ARG));
}
void
_rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line)
{
@ -656,16 +662,13 @@ __rw_rlock(volatile uintptr_t *c, const char *file, int line)
}
int
__rw_try_rlock(volatile uintptr_t *c, const char *file, int line)
__rw_try_rlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF)
{
struct rwlock *rw;
uintptr_t x;
if (SCHEDULER_STOPPED())
return (1);
rw = rwlock2rw(c);
KASSERT(kdb_active != 0 || !TD_IS_IDLETHREAD(curthread),
("rw_try_rlock() by idle thread %p on rwlock %s @ %s:%d",
curthread, rw->lock_object.lo_name, file, line));
@ -692,6 +695,15 @@ __rw_try_rlock(volatile uintptr_t *c, const char *file, int line)
return (0);
}
int
__rw_try_rlock(volatile uintptr_t *c, const char *file, int line)
{
struct rwlock *rw;
rw = rwlock2rw(c);
return (__rw_try_rlock_int(rw, LOCK_FILE_LINE_ARG));
}
static bool __always_inline
__rw_runlock_try(struct rwlock *rw, struct thread *td, uintptr_t *vp)
{