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 _______________________________________________ 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"