The branch main has been updated by jfree:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=cd4bd9750c1b194ba22fbbc333d6166556a26577

commit cd4bd9750c1b194ba22fbbc333d6166556a26577
Author:     Jake Freeland <jf...@freebsd.org>
AuthorDate: 2024-04-28 00:20:34 +0000
Commit:     Jake Freeland <jf...@freebsd.org>
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)

Reply via email to