From owner-svn-src-stable@freebsd.org Wed Jun 7 11:30:30 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 14BACC09EF7; Wed, 7 Jun 2017 11:30:30 +0000 (UTC) (envelope-from kib@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 mx1.freebsd.org (Postfix) with ESMTPS id D787D703A4; Wed, 7 Jun 2017 11:30:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v57BUTT7053475; Wed, 7 Jun 2017 11:30:29 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v57BUSPq053473; Wed, 7 Jun 2017 11:30:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201706071130.v57BUSPq053473@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 7 Jun 2017 11:30:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r319650 - in stable/11: share/man/man9 sys/sys X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jun 2017 11:30:30 -0000 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) \