aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/sx.h
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2001-10-23 22:39:11 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2001-10-23 22:39:11 +0000
commit4e5e677bc09b04779ca78ed11e8dcb5e8bca692b (patch)
tree01dcac73fae7ff5bfe14b5b70a3438318b77a47d /sys/sys/sx.h
parente5e5b51f9f11601c89829a05ae2cdd02cdbbc648 (diff)
downloadsrc-4e5e677bc09b04779ca78ed11e8dcb5e8bca692b.tar.gz
src-4e5e677bc09b04779ca78ed11e8dcb5e8bca692b.zip
Change the sx(9) assertion API to use a sx_assert() function similar to
mtx_assert(9) rather than several SX_ASSERT_* macros.
Notes
Notes: svn path=/head/; revision=85388
Diffstat (limited to 'sys/sys/sx.h')
-rw-r--r--sys/sys/sx.h45
1 files changed, 8 insertions, 37 deletions
diff --git a/sys/sys/sx.h b/sys/sys/sx.h
index e27366ccae15..ba6b8b7bee00 100644
--- a/sys/sys/sx.h
+++ b/sys/sys/sx.h
@@ -57,6 +57,9 @@ void _sx_sunlock(struct sx *sx, const char *file, int line);
void _sx_xunlock(struct sx *sx, const char *file, int line);
int _sx_try_upgrade(struct sx *sx, const char *file, int line);
void _sx_downgrade(struct sx *sx, const char *file, int line);
+#ifdef INVARIANT_SUPPORT
+void _sx_assert(struct sx *sx, int what, const char *file, int line);
+#endif
#define sx_slock(sx) _sx_slock((sx), LOCK_FILE, LOCK_LINE)
#define sx_xlock(sx) _sx_xlock((sx), LOCK_FILE, LOCK_LINE)
@@ -68,45 +71,13 @@ void _sx_downgrade(struct sx *sx, const char *file, int line);
#define sx_downgrade(sx) _sx_downgrade((sx), LOCK_FILE, LOCK_LINE)
#ifdef INVARIANTS
-/*
- * In the non-WITNESS case, SX_ASSERT_LOCKED() and SX_ASSERT_SLOCKED()
- * can only detect that at least *some* thread owns an slock, but it cannot
- * guarantee that *this* thread owns an slock.
- */
-#ifdef WITNESS
-#define _SX_ASSERT_LOCKED(sx, file, line) \
- witness_assert(&(sx)->sx_object, LA_LOCKED, file, line)
-#define _SX_ASSERT_SLOCKED(sx, file, line) \
- witness_assert(&(sx)->sx_object, LA_SLOCKED, file, line)
-#else
-#define _SX_ASSERT_LOCKED(sx, file, line) do { \
- KASSERT(((sx)->sx_cnt > 0 || (sx)->sx_xholder == curthread), \
- ("Lock %s not locked @ %s:%d", (sx)->sx_object.lo_name, \
- file, line)); \
-} while (0)
-#define _SX_ASSERT_SLOCKED(sx, file, line) do { \
- KASSERT(((sx)->sx_cnt > 0), ("Lock %s not share locked @ %s:%d",\
- (sx)->sx_object.lo_name, file, line)); \
-} while (0)
-#endif
-#define SX_ASSERT_LOCKED(sx) _SX_ASSERT_LOCKED((sx), LOCK_FILE, LOCK_LINE)
-#define SX_ASSERT_SLOCKED(sx) _SX_ASSERT_SLOCKED((sx), LOCK_FILE, LOCK_LINE)
-
-/*
- * SX_ASSERT_XLOCKED() detects and guarantees that *we* own the xlock.
- */
-#define _SX_ASSERT_XLOCKED(sx, file, line) do { \
- KASSERT(((sx)->sx_xholder == curthread), \
- ("Lock %s not exclusively locked @ %s:%d", \
- (sx)->sx_object.lo_name, file, line)); \
-} while (0)
-#define SX_ASSERT_XLOCKED(sx) _SX_ASSERT_XLOCKED((sx), LOCK_FILE, LOCK_LINE)
+#define SX_LOCKED LA_LOCKED
+#define SX_SLOCKED LA_SLOCKED
+#define SX_XLOCKED LA_XLOCKED
+#define sx_assert(sx, what) _sx_assert((sx), (what), LOCK_FILE, LOCK_LINE)
#else /* INVARIANTS */
-#define SX_ASSERT_SLOCKED(sx)
-#define SX_ASSERT_XLOCKED(sx)
-#define _SX_ASSERT_SLOCKED(sx, file, line)
-#define _SX_ASSERT_XLOCKED(sx, file, line)
+#define sx_assert(sx, what)
#endif /* INVARIANTS */
#endif /* _KERNEL */