diff --git a/sys/sys/sx.h b/sys/sys/sx.h index 0612b7bf37b7..43f89fba5099 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