freebsd-dev/include
Alan Somers 8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
..
arpa include: minor spelling fixes. 2016-04-30 14:43:42 +00:00
gssapi Add META_MODE support. 2015-06-13 19:20:56 +00:00
protocols Add META_MODE support. 2015-06-13 19:20:56 +00:00
rpc xdr: Fix xdr_rpc* defines. 2016-03-04 22:03:38 +00:00
rpcsvc include: minor spelling fixes. 2016-04-30 14:43:42 +00:00
xlocale Commit log from Dragonfly: 2015-10-13 20:43:49 +00:00
_ctype.h Commit log from Dragonfly: 2015-10-13 20:43:49 +00:00
a.out.h
ar.h
assert.h
bitstring.h Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
complex.h
cpio.h
ctype.h Commit log from Dragonfly: 2015-10-13 20:43:49 +00:00
db.h
dirent.h
dlfcn.h
elf-hints.h
elf.h
err.h
fmtmsg.h
fnmatch.h
fstab.h
fts.h
ftw.h
getopt.h
glob.h
grp.h
gssapi.h
hesiod.h
iconv.h Remove the const qualifier from iconv(3) to comply with POSIX: 2015-04-15 09:09:20 +00:00
ieeefp.h
ifaddrs.h
inttypes.h
iso646.h
kenv.h
langinfo.h
libgen.h
limits.h - Add the definition of CHARCLASS_NAME_MAX, as per POSIX.1-2001. 2016-01-09 14:53:23 +00:00
link.h
locale.h
Makefile MFH 2016-04-16 02:32:12 +00:00
Makefile.depend new depends 2015-06-16 23:37:19 +00:00
malloc_np.h Update jemalloc to 4.1.0. 2016-02-29 19:10:32 +00:00
malloc.h
memory.h
mk-osreldate.sh Stop building vers.c in include/ and only build the needed osreldate.h. 2015-11-25 19:10:59 +00:00
monetary.h
mpool.h
mqueue.h
ndbm.h
netconfig.h
netdb.h addrinfo.ai_family is an address family, not a protocol family. 2015-12-20 15:18:50 +00:00
nl_types.h
nlist.h
nss.h
nsswitch.h
paths.h Implement suggestion by jhb@ to have _PATH_FIRMWARE instead of hard 2016-03-23 04:18:57 +00:00
printf.h
proc_service.h
pthread_np.h
pthread.h Implement process-shared locks support for libthr.so.3, without 2016-02-28 17:52:33 +00:00
pwd.h
ranlib.h
readpassphrase.h
regex.h
res_update.h
resolv.h resolver: preserve binary compatibility; reduce header pollution 2015-12-14 17:21:06 +00:00
runetype.h
search.h Replace implementation of hsearch() by one that scales. 2015-12-27 07:50:11 +00:00
semaphore.h Ensure #include <semaphore.h> is sufficient for using SEM_VALUE_MAX. 2015-01-31 16:39:26 +00:00
setjmp.h
signal.h Hide ucontext_t and mcontext_t when neither POSIX nor XSI features are 2016-02-13 17:23:55 +00:00
spawn.h
stab.h
stdalign.h
stdbool.h
stddef.h
stdio.h Add _flags2 per jhb@ suggestion since no room left in _flags. 2015-10-28 14:40:02 +00:00
stdlib.h For C++, expose long long types and functions (lldiv_t, llabs, lldiv, 2016-03-23 19:17:12 +00:00
stdnoreturn.h
string.h
stringlist.h Remove clause 3 and 4 from the license 2015-05-21 08:38:25 +00:00
strings.h
sysexits.h
tar.h
termios.h
tgmath.h
time.h
timeconv.h
timers.h
ttyent.h
uchar.h
ulimit.h
unistd.h Implement process-shared locks support for libthr.so.3, without 2016-02-28 17:52:33 +00:00
unwind.h
utime.h
utmpx.h
uuid.h
varargs.h
wchar.h
wctype.h Commit log from Dragonfly: 2015-10-13 20:43:49 +00:00
wordexp.h
xlocale.h