summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_rwlock.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index 5b52af91e71..b000eb00c86 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -778,6 +778,25 @@ rw_lock_held(krwlock_t *rw)
return (rw->rw_owner & RW_THREAD) != 0;
}
+#ifdef LOCKDOC
+/*
+ * Helper function to get a lock type (backported from NetBSD 10.0-STABLE)
+ * the #ifdef is here just in case.
+ */
+
+ /*
+ * rw_lock_op:
+ *
+ * For a rwlock that is known to be held by the caller, return
+ * RW_READER or RW_WRITER to describe the hold type.
+ */
+krw_t
+rw_lock_op(krwlock_t *rw)
+{
+ return (rw->rw_owner & RW_WRITE_LOCKED) != 0 ? RW_WRITER : RW_READER;
+}
+#endif
+
/*
* rw_owner:
*