Module Name: src Committed By: skrll Date: Sat Jan 22 08:58:48 UTC 2022
Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man3: Makefile bits.3 src/sys/sys: cdefs.h Log Message: Add __MASK(3) __MASK(n): first n bits all set, where __MASK(4) == 0b1111. To generate a diff of this commit: cvs rdiff -u -r1.2409 -r1.2410 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.90 -r1.91 src/share/man/man3/Makefile cvs rdiff -u -r1.20 -r1.21 src/share/man/man3/bits.3 cvs rdiff -u -r1.158 -r1.159 src/sys/sys/cdefs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2409 src/distrib/sets/lists/comp/mi:1.2410 --- src/distrib/sets/lists/comp/mi:1.2409 Sat Jan 22 08:09:39 2022 +++ src/distrib/sets/lists/comp/mi Sat Jan 22 08:58:48 2022 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2409 2022/01/22 08:09:39 pho Exp $ +# $NetBSD: mi,v 1.2410 2022/01/22 08:58:48 skrll Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.comp comp-sys-root @@ -5851,6 +5851,7 @@ ./usr/share/man/cat3/__CONCAT.0 comp-c-catman .cat ./usr/share/man/cat3/__FPTRCAST.0 comp-c-catman .cat ./usr/share/man/cat3/__KERNEL_RCSID.0 comp-c-catman .cat +./usr/share/man/cat3/__MASK.0 comp-c-catman .cat ./usr/share/man/cat3/__RCSID.0 comp-c-catman .cat ./usr/share/man/cat3/__SHIFTIN.0 comp-c-catman .cat ./usr/share/man/cat3/__SHIFTOUT.0 comp-c-catman .cat @@ -14198,6 +14199,7 @@ ./usr/share/man/html3/__CONCAT.html comp-c-htmlman html ./usr/share/man/html3/__FPTRCAST.html comp-c-htmlman html ./usr/share/man/html3/__KERNEL_RCSID.html comp-c-htmlman html +./usr/share/man/html3/__MASK.html comp-c-htmlman html ./usr/share/man/html3/__RCSID.html comp-c-htmlman html ./usr/share/man/html3/__SHIFTIN.html comp-c-htmlman html ./usr/share/man/html3/__SHIFTOUT.html comp-c-htmlman html @@ -22382,6 +22384,7 @@ ./usr/share/man/man3/__CONCAT.3 comp-c-man .man ./usr/share/man/man3/__FPTRCAST.3 comp-c-man .man ./usr/share/man/man3/__KERNEL_RCSID.3 comp-c-man .man +./usr/share/man/man3/__MASK.3 comp-c-man .man ./usr/share/man/man3/__RCSID.3 comp-c-man .man ./usr/share/man/man3/__SHIFTIN.3 comp-c-man .man ./usr/share/man/man3/__SHIFTOUT.3 comp-c-man .man Index: src/share/man/man3/Makefile diff -u src/share/man/man3/Makefile:1.90 src/share/man/man3/Makefile:1.91 --- src/share/man/man3/Makefile:1.90 Mon Jan 13 08:25:02 2020 +++ src/share/man/man3/Makefile Sat Jan 22 08:58:48 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.90 2020/01/13 08:25:02 kamil Exp $ +# $NetBSD: Makefile,v 1.91 2022/01/22 08:58:48 skrll Exp $ # @(#)Makefile 8.2 (Berkeley) 12/13/93 MAN= _DIAGASSERT.3 __CONCAT.3 __FPTRCAST.3 __UNCONST.3 __USE.3 CMSG_DATA.3 \ @@ -47,6 +47,7 @@ MLINKS+=bitstring.3 bit_alloc.3 \ bitstring.3 bit_test.3 MLINKS+=bits.3 __BIT.3 \ bits.3 __BITS.3 \ + bits.3 __MASK.3 \ bits.3 __SHIFTIN.3 \ bits.3 __SHIFTOUT.3 \ bits.3 __SHIFTOUT_MASK.3 Index: src/share/man/man3/bits.3 diff -u src/share/man/man3/bits.3:1.20 src/share/man/man3/bits.3:1.21 --- src/share/man/man3/bits.3:1.20 Thu Jan 20 07:30:25 2022 +++ src/share/man/man3/bits.3 Sat Jan 22 08:58:48 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: bits.3,v 1.20 2022/01/20 07:30:25 skrll Exp $ +.\" $NetBSD: bits.3,v 1.21 2022/01/22 08:58:48 skrll Exp $ .\" .\" Copyright (c) 2006, 2010 David Young. All rights reserved. .\" @@ -25,12 +25,13 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 20, 2022 +.Dd January 22, 2022 .Dt BITS 3 .Os .Sh NAME .Nm __BIT , .Nm __BITS , +.Nm __MASK , .Nm __SHIFTIN , .Nm __SHIFTOUT , .Nm __SHIFTOUT_MASK @@ -43,6 +44,8 @@ .Ft uintmax_t .Fn __BITS "m" "n" .Ft uintmax_t +.Fn __MASK "n" +.Ft uintmax_t .Fn __SHIFTIN "v" "mask" .Ft uintmax_t .Fn __SHIFTOUT "v" "mask" @@ -57,9 +60,10 @@ is a span of consecutive bits defined by the bits in the bitfield. .Pp Use -.Fn __BIT +.Fn __BIT , +.Fn __BITS , and -.Fn __BITS +.Fn __MASK to define bitmasks: .Bl -tag -width __BITS -offset indent .It Fn __BIT "n" @@ -77,6 +81,12 @@ It does not matter whether or .Fa m No <= Fa n . The least significant bit is bit 0. +.It Fn __MASK "n" +Return a bitmask with the first +.Fa n +bits set. That is, bits 0 through +.Fa n +- 1, inclusive, set. .El .Pp .Fn __SHIFTIN , Index: src/sys/sys/cdefs.h diff -u src/sys/sys/cdefs.h:1.158 src/sys/sys/cdefs.h:1.159 --- src/sys/sys/cdefs.h:1.158 Tue Dec 14 20:12:48 2021 +++ src/sys/sys/cdefs.h Sat Jan 22 08:58:48 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.158 2021/12/14 20:12:48 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.159 2022/01/22 08:58:48 skrll Exp $ */ /* * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -649,6 +649,9 @@ (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \ ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1)))) +/* __MASK(n): first n bits all set, where __MASK(4) == 0b1111. */ +#define __MASK(__n) (__BIT(__n) - 1) + /* Macros for min/max. */ #define __MIN(a,b) ((/*CONSTCOND*/(a)<=(b))?(a):(b)) #define __MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b))