From: sashan Date: Wed, 28 Apr 2021 09:42:04 +0000 (+0000) Subject: time to add NET_ASSERT_WLOCKED() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=304bcc79f4833ddf714bd65736b39d9edbec0b77;p=openbsd time to add NET_ASSERT_WLOCKED() with moving towards NET_RLOCK...() we need NET_ASSERT_WLOCKED() to check caller owns netlock exclusively. OK @bluhm --- diff --git a/sys/sys/systm.h b/sys/sys/systm.h index a26d7f98f21..d4d005a1681 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.152 2021/02/08 08:18:45 mpi Exp $ */ +/* $OpenBSD: systm.h,v 1.153 2021/04/28 09:42:04 sashan Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -361,9 +361,17 @@ do { \ splassert_fail(RW_READ, _s, __func__); \ } while (0) +#define NET_ASSERT_WLOCKED() \ +do { \ + int _s = rw_status(&netlock); \ + if ((splassert_ctl > 0) && (_s != RW_WRITE)) \ + splassert_fail(RW_WRITE, _s, __func__); \ +} while (0) + #else /* DIAGNOSTIC */ #define NET_ASSERT_UNLOCKED() do {} while (0) #define NET_ASSERT_LOCKED() do {} while (0) +#define NET_ASSERT_WLOCKED() do {} while (0) #endif /* !DIAGNOSTIC */ __returns_twice int setjmp(label_t *);