Date: Sat, 15 Feb 2020 01:28:06 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357950 - head/sys/sys Message-ID: <202002150128.01F1S6Px045540@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Sat Feb 15 01:28:06 2020 New Revision: 357950 URL: https://svnweb.freebsd.org/changeset/base/357950 Log: capsicum: add cap_rights_init_zero, cap_rights_init_one, cap_rights_set_one ... which allow the compiler to generate relevant code in place without resorting to calling to a routine at runtime. Modified: head/sys/sys/capsicum.h Modified: head/sys/sys/capsicum.h ============================================================================== --- head/sys/sys/capsicum.h Sat Feb 15 00:48:44 2020 (r357949) +++ head/sys/sys/capsicum.h Sat Feb 15 01:28:06 2020 (r357950) @@ -351,6 +351,27 @@ void __cap_rights_sysinit(void *arg); _Static_assert(CAP_RIGHTS_VERSION == CAP_RIGHTS_VERSION_00, "unsupported version of capsicum rights"); +#define cap_rights_init_zero(r) ({ \ + cap_rights_t *_r = (r); \ + CAP_NONE(_r); \ + _r; \ +}) + +#define cap_rights_init_one(r, right) ({ \ + CTASSERT(CAPRVER(right) == CAP_RIGHTS_VERSION); \ + cap_rights_t *_r = (r); \ + CAP_NONE(_r); \ + _r->cr_rights[CAPIDXBIT(right) - 1] |= right; \ + _r; \ +}) + +#define cap_rights_set_one(r, right) ({ \ + CTASSERT(CAPRVER(right) == CAP_RIGHTS_VERSION); \ + cap_rights_t *_r = (r); \ + _r->cr_rights[CAPIDXBIT(right) - 1] |= right; \ + _r; \ +}) + /* * Allow checking caps which are possibly getting modified at the same time. * The caller is expected to determine whether the result is legitimate via
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002150128.01F1S6Px045540>
