diff options
author | darrenr <darrenr@FreeBSD.org> | 2004-07-11 16:07:07 +0000 |
---|---|---|
committer | darrenr <darrenr@FreeBSD.org> | 2004-07-11 16:07:07 +0000 |
commit | 210d568a00115cf67bdb5a1f5cf391778b4e5493 (patch) | |
tree | 3e9f181364314261bd9f281962030e9e2b723c9f /sys | |
parent | a6214e1123749e421e2322eec9f3ddde71b041f3 (diff) | |
download | FreeBSD-src-210d568a00115cf67bdb5a1f5cf391778b4e5493.zip FreeBSD-src-210d568a00115cf67bdb5a1f5cf391778b4e5493.tar.gz |
Add sx_unlock() macro as a frontend to both sx_sunlock() and sx_xunlock(),
using sx_cnt to determine what state the lock is in and call the respective
function appropriately.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/sys/sx.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/sys/sx.h b/sys/sys/sx.h index 0612b7b..43f89fb 100644 --- a/sys/sys/sx.h +++ b/sys/sys/sx.h @@ -82,6 +82,13 @@ struct sx_args { #define sx_xunlock(sx) _sx_xunlock((sx), LOCK_FILE, LOCK_LINE) #define sx_try_upgrade(sx) _sx_try_upgrade((sx), LOCK_FILE, LOCK_LINE) #define sx_downgrade(sx) _sx_downgrade((sx), LOCK_FILE, LOCK_LINE) +#define sx_unlock(sx) \ + do { \ + if ((sx)->sx_cnt < 0) \ + sx_xunlock(sx); \ + else \ + sx_sunlock(sx); \ + } while (0) #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) #define SX_LOCKED LA_LOCKED |