svn commit: r319650 - in stable/11: share/man/man9 sys/sys

Konstantin Belousov kib at FreeBSD.org
Wed Jun 7 11:30:30 UTC 2017


Author: kib
Date: Wed Jun  7 11:30:28 2017
New Revision: 319650
URL: https://svnweb.freebsd.org/changeset/base/319650

Log:
  MFC r318781:
  Add BIT_OR2(), BIT_AND2(), BIT_NAND2(), BIT_XOR() and BIT_XOR2().
  
  Approved by:	re (marius)

Modified:
  stable/11/share/man/man9/bitset.9
  stable/11/sys/sys/bitset.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man9/bitset.9
==============================================================================
--- stable/11/share/man/man9/bitset.9	Wed Jun  7 09:10:24 2017	(r319649)
+++ stable/11/share/man/man9/bitset.9	Wed Jun  7 11:30:28 2017	(r319650)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 1, 2016
+.Dd May 24, 2017
 .Dt BITSET 9
 .Os
 .Sh NAME
@@ -48,8 +48,13 @@
 .Nm BIT_OVERLAP ,
 .Nm BIT_CMP ,
 .Nm BIT_OR ,
+.Nm BIT_OR2 ,
 .Nm BIT_AND ,
+.Nm BIT_AND2 ,
 .Nm BIT_NAND ,
+.Nm BIT_NAND2 ,
+.Nm BIT_XOR ,
+.Nm BIT_XOR2 ,
 .Nm BIT_CLR_ATOMIC ,
 .Nm BIT_SET_ATOMIC ,
 .Nm BIT_SET_ATOMIC_ACQ ,
@@ -95,8 +100,33 @@
 .Fa "const SETSIZE" "struct STRUCTNAME *bitset1" "struct STRUCTNAME *bitset2"
 .Fc
 .Fn BIT_OR "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src"
+.Fo BIT_OR2
+.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"
+.Fa "struct STRUCTNAME *dst"
+.Fa "struct STRUCTNAME *src1"
+.Fa "struct STRUCTNAME *src2"
+.Fc
 .Fn BIT_NAND "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src"
+.Fo BIT_NAND2
+.Fa "const SETSIZE"
+.Fa "struct STRUCTNAME *dst"
+.Fa "struct STRUCTNAME *src1"
+.Fa "struct STRUCTNAME *src2"
+.Fc
+.Fn BIT_XOR "const SETSIZE" "struct STRUCTNAME *dst" "struct STRUCTNAME *src"
+.Fo BIT_XOR2
+.Fa "const SETSIZE"
+.Fa "struct STRUCTNAME *dst"
+.Fa "struct STRUCTNAME *src1"
+.Fa "struct STRUCTNAME *src2"
+.Fc
 .\"
 .Fn BIT_CLR_ATOMIC "const SETSIZE" "size_t bit" "struct STRUCTNAME *bitset"
 .Fn BIT_SET_ATOMIC "const SETSIZE" "size_t bit" "struct STRUCTNAME *bitset"
@@ -312,6 +342,23 @@ is composed of multiple machine words,
 performs multiple individually atomic operations.)
 .Pp
 The
+.Fn BIT_OR2
+macro computes
+.Fa src1
+bitwise or
+.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
@@ -328,6 +375,23 @@ is similar, with the same atomic semantics as
 .Fn BIT_OR_ATOMIC .
 .Pp
 The
+.Fn BIT_AND2
+macro computes
+.Fa src1
+bitwise and
+.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_NAND
 macro clears bits set in
 .Fa src
@@ -339,6 +403,53 @@ equivalent of the scalar:
 .Fa dst
 &=
 .Fa ~ src . )
+.Pp
+The
+.Fn BIT_NAND2
+macro computes
+.Fa src1
+bitwise and 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_XOR
+macro toggles bits set in
+.Fa src
+in
+.Fa dst .
+(It is the
+.Nm
+equivalent of the scalar:
+.Fa dst
+^=
+.Fa src . )
+.Pp
+The
+.Fn BIT_XOR2
+macro computes
+.Fa src1
+bitwise exclusive or
+.Fa src2
+and assigns the result to
+.Fa dst .
+(It is the
+.Nm
+equivalent of the scalar:
+.Fa dst
+=
+.Fa src1
+^
+.Fa src2 . )
 .Sh BITSET_T_INITIALIZER EXAMPLE
 .Bd -literal
 BITSET_DEFINE(_myset, MYSETSIZE);

Modified: stable/11/sys/sys/bitset.h
==============================================================================
--- stable/11/sys/sys/bitset.h	Wed Jun  7 09:10:24 2017	(r319649)
+++ stable/11/sys/sys/bitset.h	Wed Jun  7 11:30:28 2017	(r319650)
@@ -122,16 +122,46 @@
 		(d)->__bits[__i] |= (s)->__bits[__i];			\
 } while (0)
 
+#define	BIT_OR2(_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++)		\
 		(d)->__bits[__i] &= (s)->__bits[__i];			\
 } while (0)
 
+#define	BIT_AND2(_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_NAND(_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_NAND2(_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_XOR(_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_XOR2(_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_CLR_ATOMIC(_s, n, p)					\


More information about the svn-src-all mailing list