diff options
author | 2017-08-12 23:27:44 +0000 | |
---|---|---|
committer | 2017-08-12 23:27:44 +0000 | |
commit | d76a93a21d3879fd9ecbcc093fc7748802dde094 (patch) | |
tree | f119c6c71db8c9177574d645a9e39c0b4651a32f /sys/kern | |
parent | Minimize #includes, particularly to avoid thread_private.h (diff) | |
download | wireguard-openbsd-d76a93a21d3879fd9ecbcc093fc7748802dde094.tar.xz wireguard-openbsd-d76a93a21d3879fd9ecbcc093fc7748802dde094.zip |
Add rw_assert_anylock(), for assering you have it either read or write locked
ok tedu@ mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_rwlock.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 1028c26a7da..e2c3caed0ab 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_rwlock.c,v 1.29 2017/08/10 19:19:18 mpi Exp $ */ +/* $OpenBSD: kern_rwlock.c,v 1.30 2017/08/12 23:27:44 guenther Exp $ */ /* * Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org> @@ -342,6 +342,17 @@ rw_assert_rdlock(struct rwlock *rwl) } void +rw_assert_anylock(struct rwlock *rwl) +{ + switch (rw_status(rwl)) { + case RW_WRITE_OTHER: + panic("%s: lock held by different process", rwl->rwl_name); + case 0: + panic("%s: lock not held", rwl->rwl_name); + } +} + +void rw_assert_unlocked(struct rwlock *rwl) { if (rwl->rwl_owner != 0L) |