Add an assertion macro for lockmgr locks, LOCKMGR_ASSERT(lkp, what, p).

The what argument is the hold type that assertion acts on.  LK_SHARED
to assert that the process holds a shared, LK_EXCLUSIVE to assert that
the process holds _either_ a shared lock or an exclusive lock.
This commit is contained in:
Jake Burkholder
2000-12-18 05:50:31 +00:00
parent 41155d57bc
commit 8b5fb980d1
2 changed files with 44 additions and 0 deletions
+22
View File
@@ -175,6 +175,28 @@ struct lock {
#define LK_KERNPROC ((pid_t) -2)
#define LK_NOPROC ((pid_t) -1)
#ifdef INVARIANTS
#define LOCKMGR_ASSERT(lkp, what, p) do { \
switch ((what)) { \
case LK_SHARED: \
if (lockstatus((lkp), (p)) == LK_SHARED) \
break; \
/* fall into exclusive */ \
case LK_EXCLUSIVE: \
if (lockstatus((lkp), (p)) != LK_EXCLUSIVE) \
panic("lock %s %s not held at %s:%d", \
(lkp)->lk_wmesg, #what, __FILE__, \
__LINE__); \
break; \
default: \
panic("unknown LOCKMGR_ASSERT at %s:%d", __FILE__, \
__LINE__); \
} \
} while (0)
#else /* INVARIANTS */
#define LOCKMGR_ASSERT(lkp, p, what)
#endif /* INVARIANTS */
void dumplockinfo(struct lock *lkp);
struct proc;
+22
View File
@@ -175,6 +175,28 @@ struct lock {
#define LK_KERNPROC ((pid_t) -2)
#define LK_NOPROC ((pid_t) -1)
#ifdef INVARIANTS
#define LOCKMGR_ASSERT(lkp, what, p) do { \
switch ((what)) { \
case LK_SHARED: \
if (lockstatus((lkp), (p)) == LK_SHARED) \
break; \
/* fall into exclusive */ \
case LK_EXCLUSIVE: \
if (lockstatus((lkp), (p)) != LK_EXCLUSIVE) \
panic("lock %s %s not held at %s:%d", \
(lkp)->lk_wmesg, #what, __FILE__, \
__LINE__); \
break; \
default: \
panic("unknown LOCKMGR_ASSERT at %s:%d", __FILE__, \
__LINE__); \
} \
} while (0)
#else /* INVARIANTS */
#define LOCKMGR_ASSERT(lkp, p, what)
#endif /* INVARIANTS */
void dumplockinfo(struct lock *lkp);
struct proc;