Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Add __MASK(3)
details: https://anonhg.NetBSD.org/src/rev/f0839c56c178
branches: trunk
changeset: 359773:f0839c56c178
user: skrll <skrll%NetBSD.org@localhost>
date: Sat Jan 22 08:58:48 2022 +0000
description:
Add __MASK(3)
__MASK(n): first n bits all set, where __MASK(4) == 0b1111.
diffstat:
distrib/sets/lists/comp/mi | 5 ++++-
share/man/man3/Makefile | 3 ++-
share/man/man3/bits.3 | 18 ++++++++++++++----
sys/sys/cdefs.h | 5 ++++-
4 files changed, 24 insertions(+), 7 deletions(-)
diffs (128 lines):
diff -r 7f40f5adee5f -r f0839c56c178 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Sat Jan 22 08:09:39 2022 +0000
+++ b/distrib/sets/lists/comp/mi Sat Jan 22 08:58:48 2022 +0000
@@ -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
diff -r 7f40f5adee5f -r f0839c56c178 share/man/man3/Makefile
--- a/share/man/man3/Makefile Sat Jan 22 08:09:39 2022 +0000
+++ b/share/man/man3/Makefile Sat Jan 22 08:58:48 2022 +0000
@@ -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 @@
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
diff -r 7f40f5adee5f -r f0839c56c178 share/man/man3/bits.3
--- a/share/man/man3/bits.3 Sat Jan 22 08:09:39 2022 +0000
+++ b/share/man/man3/bits.3 Sat Jan 22 08:58:48 2022 +0000
@@ -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 @@
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 @@
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 ,
diff -r 7f40f5adee5f -r f0839c56c178 sys/sys/cdefs.h
--- a/sys/sys/cdefs.h Sat Jan 22 08:09:39 2022 +0000
+++ b/sys/sys/cdefs.h Sat Jan 22 08:58:48 2022 +0000
@@ -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))
Home |
Main Index |
Thread Index |
Old Index