From owner-svn-src-head@freebsd.org Sat Feb 15 01:28:06 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF3DD249F4E; Sat, 15 Feb 2020 01:28:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48KCLG4WBVz4YRJ; Sat, 15 Feb 2020 01:28:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 960FC5044; Sat, 15 Feb 2020 01:28:06 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01F1S6ns045541; Sat, 15 Feb 2020 01:28:06 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01F1S6Px045540; Sat, 15 Feb 2020 01:28:06 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202002150128.01F1S6Px045540@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 15 Feb 2020 01:28:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357950 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 357950 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2020 01:28:06 -0000 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