Hi Pawel, I don't think the (notyet) static assertion is quite right.
On Thu, Feb 6, 2020 at 4:46 AM Pawel Biernacki <kak...@freebsd.org> wrote: > > Author: kaktus > Date: Thu Feb 6 12:45:58 2020 > New Revision: 357614 > URL: https://svnweb.freebsd.org/changeset/base/357614 > > Log: > sysctl(9): add CTLFLAG_NEEDGIANT flag > ... > Modified: head/sys/sys/sysctl.h > ============================================================================== > --- head/sys/sys/sysctl.h Thu Feb 6 10:11:41 2020 (r357613) > +++ head/sys/sys/sysctl.h Thu Feb 6 12:45:58 2020 (r357614) > @@ -105,6 +105,13 @@ struct ctlname { > ... > + * One, and only one of CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT is required > + * for SYSCTL_PROC and SYSCTL_NODE. > ... > @@ -263,6 +270,14 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); > #define __DESCR(d) "" > #endif > > +#ifdef notyet > +#define SYSCTL_ENFORCE_FLAGS(x) > \ > + _Static_assert(((CTLFLAG_MPSAFE ^ CTLFLAG_NEEDGIANT) & (x)), \ > + "Has to be either CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT") The current (notyet) assertion checks for one or both flags being set, but you want to disallow both being set. The XOR operator here is meaningless; it is the same as OR for different bit flags. That would be something like: #define _CTLFLAG_MUTUALLY_EXCLUSIVE (CTLFLAG_MPSAFE | CTLFLAG_NEEDGIANT); #define SYSCTL_ENFORCE_FLAGS(x) do { \ _Static_assert(((x) & _CTLFLAG_MUTUALLY_EXCLUSIVE) != 0 && \ ((x) & _CTLFLAG_MUTUALLY_EXCLUSIVE) != _CTLFLAG_MUTUALLY_EXCLUSIVE, \ "Must set exactly one of CTLFLAG_MPSAFE, CTLFLAG_NEEDGIANT"); \ } while (0) Best, Conrad _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"