Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/share/man/man3 add __BITMAP_TYPE
details: https://anonhg.NetBSD.org/src/rev/c756f64604fb
branches: trunk
changeset: 783126:c756f64604fb
user: christos <christos%NetBSD.org@localhost>
date: Fri Dec 07 01:54:41 2012 +0000
description:
add __BITMAP_TYPE
diffstat:
share/man/man3/Makefile | 3 +-
share/man/man3/bitmap.3 | 51 +++++++++++++++++++++++++++++-------------------
2 files changed, 33 insertions(+), 21 deletions(-)
diffs (132 lines):
diff -r d9ea68f40a18 -r c756f64604fb share/man/man3/Makefile
--- a/share/man/man3/Makefile Fri Dec 07 01:54:27 2012 +0000
+++ b/share/man/man3/Makefile Fri Dec 07 01:54:41 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.80 2012/12/01 20:33:02 christos Exp $
+# $NetBSD: Makefile,v 1.81 2012/12/07 01:54:41 christos Exp $
# @(#)Makefile 8.2 (Berkeley) 12/13/93
MAN= _DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \
@@ -272,6 +272,7 @@
bitmap.3 __BITMAP_ISSET.3 \
bitmap.3 __BITMAP_SET.3 \
bitmap.3 __BITMAP_SIZE.3 \
+ bitmap.3 __BITMAP_TYPE.3 \
bitmap.3 __BITMAP_ZERO.3
.include <bsd.man.mk>
diff -r d9ea68f40a18 -r c756f64604fb share/man/man3/bitmap.3
--- a/share/man/man3/bitmap.3 Fri Dec 07 01:54:27 2012 +0000
+++ b/share/man/man3/bitmap.3 Fri Dec 07 01:54:41 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: bitmap.3,v 1.6 2012/12/04 18:10:25 wiz Exp $
+.\" $NetBSD: bitmap.3,v 1.7 2012/12/07 01:54:42 christos Exp $
.\"
.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd December 4, 2012
+.Dd December 6, 2012
.Dt BITMAP 3
.Os
.Sh NAME
@@ -35,6 +35,7 @@
.Nm __BITMAP_ISSET ,
.Nm __BITMAP_SET ,
.Nm __BITMAP_SIZE ,
+.Nm __BITMAP_TYPE ,
.Nm __BITMAP_ZERO
.Nd bitmap manipulation macros
.Sh LIBRARY
@@ -45,6 +46,7 @@
.Fn __BITMAP_ISSET "int bit" "type *bitmap"
.Fn __BITMAP_SET "int bit" "type *bitmap"
.Fn __BITMAP_SIZE "type" "int nbits"
+.Fn __BITMAP_TYPE "name" "type" "int nbits"
.Fn __BITMAP_ZERO "type *bitmap"
.Sh DESCRIPTION
The supplied macros are similar to the
@@ -71,9 +73,10 @@
bitmaps:
.Pp
.Fn __BITMAP_CLR bit bitmap
-initializes a descriptor set pointed to by
-.Fa bitmap
-to the null set.
+removes the given
+.Fa bit
+from the
+.Fa bitmap .
.Pp
.Fn __BITMAP_ISSET bit bitmap
is non-zero if
@@ -82,23 +85,31 @@
.Fa bitmap ,
zero otherwise.
.Pp
+.Fn __BITMAP_SET bit bitmap
+Sets the given
+.Fa bit
+in the
+.Fa bitmap .
+.Pp
.Fn __BITMAP_SIZE type nbits
Returns the number of elements would be required of the given
.Fa type
to hold
.Fa nbits .
.Pp
-.Fn __BITMAP_SET bit bitmap
-Sets the given
-.Fa bit
-in the
-.Fa bitmap .
+.Fn __BITMAP_TYPE name type nbits
+Declares the properly sized bitmap structure
+of the given
+.Fa type
+that holds
+.Fa nbits
+and is named
+.Fa name .
.Pp
-.Fn __BITMAP_CLR bit bitmap
-removes the given
-.Fa bit
-from the
-.Fa bitmap .
+.Fn __BITMAP_ZERO bit bitmap
+initializes a descriptor set pointed to by
+.Fa bitmap
+to the null set.
.Pp
The behavior of these macros is undefined for negative
bit values or ones greater than the number of bits the bitmap can hold.
@@ -109,19 +120,19 @@
int
main(int argc, char **argv)
{
- uint32_t bitmap[__BITMAP_SIZE(uint32_t, 5000)];
+ __BITMAP_TYPE(, uint32_t, 5000) bitmap;
/* Initialize the read set to null */
- __BITMAP_ZERO(bitmap);
+ __BITMAP_ZERO(\*[Am]bitmap);
/* Set bit 1 */
- __BITMAP_SET(1, bitmap);
+ __BITMAP_SET(1, \*[Am]bitmap);
for (size_t i = 0; i \*[Lt] 5000; i++) {
- if (__BITMAP_ISSET(i, bitmap)) {
+ if (__BITMAP_ISSET(i, \*[Am]bitmap)) {
/* Should just print 1 */
printf("Bit %zu is set\en", i);
- __BITMAP_CLR(i, bitmap);
+ __BITMAP_CLR(i, \*[Am]bitmap);
}
break;
}
Home |
Main Index |
Thread Index |
Old Index