diff options
author | asomers <asomers@FreeBSD.org> | 2016-05-23 20:29:18 +0000 |
---|---|---|
committer | asomers <asomers@FreeBSD.org> | 2016-05-23 20:29:18 +0000 |
commit | d14be2b60f06ebf4ccf3da56f630c33392a87b92 (patch) | |
tree | 75b6884b5df8b2102bd857790de587c4b853854d /share/man/man3 | |
parent | 50b3af23076e765c9e465ecc41463bd28f983697 (diff) | |
download | FreeBSD-src-d14be2b60f06ebf4ccf3da56f630c33392a87b92.zip FreeBSD-src-d14be2b60f06ebf4ccf3da56f630c33392a87b92.tar.gz |
Add bit_count to the bitstring(3) api
Add a bit_count function, which efficiently counts the number of bits set in
a bitstring.
sys/sys/bitstring.h
tests/sys/sys/bitstring_test.c
share/man/man3/bitstring.3
Add bit_alloc
sys/kern/subr_unit.c
Use bit_count instead of a naive counting loop in check_unrhdr, used
when INVARIANTS are enabled. The userland test runs about 6x faster
in a generic build, or 8.5x faster when built for Nehalem, which has
the POPCNT instruction.
sys/sys/param.h
Bump __FreeBSD_version due to the addition of bit_alloc
UPDATING
Add a note about the ABI incompatibility of the bitstring(3)
changes, as suggested by lidl.
Suggested by: gibbs
Reviewed by: gibbs, ngie
MFC after: 9 days
X-MFC-With: 299090, 300538
Relnotes: yes
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D6255
Diffstat (limited to 'share/man/man3')
-rw-r--r-- | share/man/man3/bitstring.3 | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/share/man/man3/bitstring.3 b/share/man/man3/bitstring.3 index f2dbb81..3db5be7 100644 --- a/share/man/man3/bitstring.3 +++ b/share/man/man3/bitstring.3 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" Copyright (c) 2014 Spectra Logic Corporation +.\" Copyright (c) 2014,2016 Spectra Logic Corporation .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -58,12 +58,13 @@ .\" @(#)bitstring.3 8.1 (Berkeley) 7/19/93 .\" $FreeBSD$ .\" -.Dd May 4, 2016 +.Dd May 23, 2016 .Dt BITSTRING 3 .Os .Sh NAME .Nm bit_alloc , .Nm bit_clear , +.Nm bit_count , .Nm bit_decl , .Nm bit_ffc , .Nm bit_ffs , @@ -84,6 +85,8 @@ .Ft void .Fn bit_clear "bitstr_t *name" "int bit" .Ft void +.Fn bit_count "bitstr_t *name" "int count" "int nbits" "int *value" +.Ft void .Fn bit_ffc "bitstr_t *name" "int nbits" "int *value" .Ft void .Fn bit_ffs "bitstr_t *name" "int nbits" "int *value" @@ -225,6 +228,17 @@ the location referenced by .Fa value is set to \-1. .Pp +The +.Fn bit_count +function stores in the location referenced by +.Fa value +the number of bits set in the array of +.Fa nbits +bits referenced by +.Fa name , +at or after the zero-based bit index +.Fa start . +.Pp The arguments in bit string macros are evaluated only once and may safely have side effects. .Sh EXAMPLES |