From nobody Sun Apr 28 00:22:24 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VRnGS4qLqz5K9K6; Sun, 28 Apr 2024 00:22:24 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VRnGS4HTHz4Q1N; Sun, 28 Apr 2024 00:22:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714263744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HKwT01NpraHMvYqMi0CeMUYh6SG5eEGi0cqVflTDb58=; b=RFkFK3t/KWPWZrIJ+pYXZRgbl8qFF123VeLeU0zroafpjYssCbdpYf/TVdLrXxw72EfjlO eA+MLmKb4k/3Y37AuRFRHE4HE8LWhh5msIvzpC0xA2MCRBzmDMdWKfKNTbaQF1bDEd2bMn 2j8RbFXkMEA+Tb7Vvev644Xu6EflYsM7x90c6zJppTi0+mr0bGDxpWt29lOoINohIuflyC tksdbEM5GEY/0XspcMeFJB7oAsZbI2uq3P9SNPtnPkvAwhc6G9/V6hyL/BrKZOIZgt+Zp9 /xFVLkMwsDHC02td4rFrKZg8YeI1hkY8fngcVcUv2T05fx9jOtW0GwSG8WFmAw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714263744; a=rsa-sha256; cv=none; b=ZFBqH6AuBbKWf/syR3EY2DIJryVpM1uWuXN8KjShLG8LaHLH9S7YPs6TdwrouImJhS5vHB 0yZhNW2cjJI2LJ+3giz8smbKweWZJZpdfrX5+P7vjKmI4YUYZdLqTAmi33ep10/O910hfM 6tEa6x/1lC6puUAp/6SPuTp9yOB4BfSjGeyoMl2crHpqucA7/zjN0GU1MlFbVYXngYFqeU 1V6hIm9ZFaeciyfoyVAwfIvcPgBeibfYLfHJzlF+MZP/iIUfMMvc1wQ7pT6Yy0mDlNF9oI SLPSEXPQPakp1UotIbeKVcPwW1YNI/r3rBCJR1qWR/UCLU3f4OyGZkEN4SK/vw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714263744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HKwT01NpraHMvYqMi0CeMUYh6SG5eEGi0cqVflTDb58=; b=VxtbV+PJpQNflBpZJnb0WOCY5aHATzjT0MNGCGPcULJ+BavOss3dZ9gcKlHsndxeRhuxIS HerRa1/NG+m3CHEhMGgRAsXI1fwlOtyxKgeFkBX7yFG4kxlqucqoSftarIJDbpYdsTocm3 B7QRmb5cpYOthIVNnUbNx8Yi5JuPGhXvBvK6JSBHukPFMJ12pmHONdQthgYCJwZJpCcrsL o27XSnqmsWpvmgRBeJhOBUJosDMZjGd6KFJjj+C1C2PM7oJlZUAM+IkFygpGgu6mkoKaU4 Sq1rXn+kJLieyCrBmQDPAC1v4vIE+Yo0MXRohalwjWeZrglB4ktiLE8moH9Zxw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VRnGS3tsWz131b; Sun, 28 Apr 2024 00:22:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43S0MOB5095624; Sun, 28 Apr 2024 00:22:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43S0MOvf095621; Sun, 28 Apr 2024 00:22:24 GMT (envelope-from git) Date: Sun, 28 Apr 2024 00:22:24 GMT Message-Id: <202404280022.43S0MOvf095621@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jake Freeland Subject: git: cd4bd9750c1b - main - bitset: Add ORNOT macros List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jfree X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd4bd9750c1b194ba22fbbc333d6166556a26577 Auto-Submitted: auto-generated The branch main has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=cd4bd9750c1b194ba22fbbc333d6166556a26577 commit cd4bd9750c1b194ba22fbbc333d6166556a26577 Author: Jake Freeland AuthorDate: 2024-04-28 00:20:34 +0000 Commit: Jake Freeland CommitDate: 2024-04-28 00:20:34 +0000 bitset: Add ORNOT macros Macros to ANDNOT a bitset currently exist, but there are no ORNOT equivalents. Introduce ORNOT macros for bitset(9), cpuset(9), and domainset(9). Approved by: markj (mentor) Reviewed by: markj MFC after: 1 week Sponsored by: NIKSUN, Inc. Differential Revision: https://reviews.freebsd.org/D44976 --- share/man/man9/Makefile | 3 +++ share/man/man9/bitset.9 | 39 +++++++++++++++++++++++++++++++++++++++ share/man/man9/cpuset.9 | 15 +++++++++++++++ sys/sys/bitset.h | 14 ++++++++++++++ sys/sys/cpuset.h | 1 + sys/sys/domainset.h | 1 + 6 files changed, 73 insertions(+) diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index a5fa777d037c..dfc9bd996504 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -635,6 +635,8 @@ MLINKS+=bitset.9 BITSET_DEFINE.9 \ bitset.9 BIT_CMP.9 \ bitset.9 BIT_OR.9 \ bitset.9 BIT_OR2.9 \ + bitset.9 BIT_ORNOT.9 \ + bitset.9 BIT_ORNOT2.9 \ bitset.9 BIT_AND.9 \ bitset.9 BIT_AND2.9 \ bitset.9 BIT_ANDNOT.9 \ @@ -924,6 +926,7 @@ MLINKS+=cpuset.9 CPUSET_T_INITIALIZER.9 \ cpuset.9 CPU_OVERLAP.9 \ cpuset.9 CPU_CMP.9 \ cpuset.9 CPU_OR.9 \ + cpuset.9 CPU_ORNOT.9 \ cpuset.9 CPU_AND.9 \ cpuset.9 CPU_ANDNOT.9 \ cpuset.9 CPU_CLR_ATOMIC.9 \ diff --git a/share/man/man9/bitset.9 b/share/man/man9/bitset.9 index 1bdfdeb7484c..a4e360a678d7 100644 --- a/share/man/man9/bitset.9 +++ b/share/man/man9/bitset.9 @@ -51,6 +51,8 @@ .Nm BIT_CMP , .Nm BIT_OR , .Nm BIT_OR2 , +.Nm BIT_ORNOT , +.Nm BIT_ORNOT2 , .Nm BIT_AND , .Nm BIT_AND2 , .Nm BIT_ANDNOT , @@ -123,6 +125,13 @@ .Fa "struct STRUCTNAME *src1" .Fa "struct STRUCTNAME *src2" .Fc +.Fn BIT_ORNOT "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src" +.Fo BIT_ORNOT2 +.Fa "const SETSIZE" +.Fa "struct STRUCTNAME *dst" +.Fa "struct STRUCTNAME *src1" +.Fa "struct STRUCTNAME *src2" +.Fc .Fn BIT_AND "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src" .Fo BIT_AND2 .Fa "const SETSIZE" @@ -459,6 +468,36 @@ equivalent of the scalar: .Fa src2 . ) .Pp The +.Fn BIT_ORNOT +macro sets bits not in +.Fa src +in +.Fa dst . +(It is the +.Nm +equivalent of the scalar: +.Fa dst +|= +.Fa ~ src . ) +.Pp +The +.Fn BIT_ORNOT2 +macro computes +.Fa src1 +bitwise or not +.Fa src2 +and assigns the result to +.Fa dst . +(It is the +.Nm +equivalent of the scalar: +.Fa dst += +.Fa src1 +| ~ +.Fa src2 . ) +.Pp +The .Fn BIT_AND macro clears bits absent from .Fa src diff --git a/share/man/man9/cpuset.9 b/share/man/man9/cpuset.9 index 974dc55b2c65..20485059a4c8 100644 --- a/share/man/man9/cpuset.9 +++ b/share/man/man9/cpuset.9 @@ -45,6 +45,7 @@ .Nm CPU_OVERLAP , .Nm CPU_CMP , .Nm CPU_OR , +.Nm CPU_ORNOT , .Nm CPU_AND , .Nm CPU_ANDNOT , .Nm CPU_XOR , @@ -86,6 +87,7 @@ .Ft bool .Fn CPU_CMP "cpuset_t *cpuset1" "cpuset_t *cpuset2" .Fn CPU_OR "cpuset_t *dst" "cpuset_t *src1" "cpuset_t *src2" +.Fn CPU_ORNOT "cpuset_t *dst" "cpuset_t *src1" "cpuset_t *src2" .Fn CPU_AND "cpuset_t *dst" "cpuset_t *src1" "cpuset_t *src2" .Fn CPU_ANDNOT "cpuset_t *dst" "cpuset_t *src1" "cpuset_t *src2" .Fn CPU_XOR "cpuset_t *dst" "cpuset_t *src1" "cpuset_t *src2" @@ -296,6 +298,19 @@ is composed of multiple machine words, performs multiple individually atomic operations.) .Pp The +.Fn CPU_ORNOT +macro add CPUs not in +.Fa src +to +.Fa dst . +(It is the +.Nm +equivalent of the scalar: +.Fa dst +|= +.Fa ~ src . ) +.Pp +The .Fn CPU_AND macro removes CPUs absent from .Fa src diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h index 5ff2bb76a4ab..4afac9b172e8 100644 --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -135,6 +135,18 @@ (d)->__bits[__i] = (s1)->__bits[__i] | (s2)->__bits[__i];\ } while (0) +#define __BIT_ORNOT(_s, d, s) do { \ + __size_t __i; \ + for (__i = 0; __i < __bitset_words((_s)); __i++) \ + (d)->__bits[__i] |= ~(s)->__bits[__i]; \ +} while (0) + +#define __BIT_ORNOT2(_s, d, s1, s2) do { \ + __size_t __i; \ + for (__i = 0; __i < __bitset_words((_s)); __i++) \ + (d)->__bits[__i] = (s1)->__bits[__i] | ~(s2)->__bits[__i];\ +} while (0) + #define __BIT_AND(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ @@ -330,6 +342,8 @@ #define BIT_ISSET(_s, n, p) __BIT_ISSET(_s, n, p) #define BIT_OR(_s, d, s) __BIT_OR(_s, d, s) #define BIT_OR2(_s, d, s1, s2) __BIT_OR2(_s, d, s1, s2) +#define BIT_ORNOT(_s, d, s) __BIT_ORNOT(_s, d, s) +#define BIT_ORNOT2(_s, d, s1, s2) __BIT_ORNOT2(_s, d, s1, s2) #define BIT_OR_ATOMIC(_s, d, s) __BIT_OR_ATOMIC(_s, d, s) #define BIT_OVERLAP(_s, p, c) __BIT_OVERLAP(_s, p, c) #define BIT_SET(_s, n, p) __BIT_SET(_s, n, p) diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h index 219e190f0b37..b036b45da283 100644 --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -56,6 +56,7 @@ #define CPU_OVERLAP(p, c) __BIT_OVERLAP(CPU_SETSIZE, p, c) #define CPU_CMP(p, c) __BIT_CMP(CPU_SETSIZE, p, c) #define CPU_OR(d, s1, s2) __BIT_OR2(CPU_SETSIZE, d, s1, s2) +#define CPU_ORNOT(d, s1, s2) __BIT_ORNOT2(CPU_SETSIZE, d, s1, s2) #define CPU_AND(d, s1, s2) __BIT_AND2(CPU_SETSIZE, d, s1, s2) #define CPU_ANDNOT(d, s1, s2) __BIT_ANDNOT2(CPU_SETSIZE, d, s1, s2) #define CPU_XOR(d, s1, s2) __BIT_XOR2(CPU_SETSIZE, d, s1, s2) diff --git a/sys/sys/domainset.h b/sys/sys/domainset.h index 42891263b81b..f98b175e9bc8 100644 --- a/sys/sys/domainset.h +++ b/sys/sys/domainset.h @@ -54,6 +54,7 @@ #define DOMAINSET_OVERLAP(p, c) __BIT_OVERLAP(DOMAINSET_SETSIZE, p, c) #define DOMAINSET_CMP(p, c) __BIT_CMP(DOMAINSET_SETSIZE, p, c) #define DOMAINSET_OR(d, s) __BIT_OR(DOMAINSET_SETSIZE, d, s) +#define DOMAINSET_ORNOT(d, s) __BIT_ORNOT(DOMAINSET_SETSIZE, d, s) #define DOMAINSET_AND(d, s) __BIT_AND(DOMAINSET_SETSIZE, d, s) #define DOMAINSET_ANDNOT(d, s) __BIT_ANDNOT(DOMAINSET_SETSIZE, d, s) #define DOMAINSET_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p)