freebsd-skq/lib
asomers 09b44517ca 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
..
atf Fix including Kyuafile in packaged base system. 2016-04-29 05:28:40 +00:00
clang Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally. 2016-03-26 03:46:12 +00:00
csu Don't reset CC away from full-pathed gcc. 2016-03-24 21:48:10 +00:00
lib80211 First pass through library packaging. 2016-02-04 21:16:35 +00:00
libalias Update libalias and libpam packaged files. 2016-02-05 01:03:38 +00:00
libarchive MFH 2016-03-10 21:16:01 +00:00
libauditd First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbegemot First pass through library packaging. 2016-02-04 21:16:35 +00:00
libblocksruntime First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbluetooth Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
libbsdstat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbsm First pass through library packaging. 2016-02-04 21:16:35 +00:00
libbsnmp MFH r289384-r293170 2016-01-04 19:19:48 +00:00
libbz2 First pass through library packaging. 2016-02-04 21:16:35 +00:00
libc Correct wording. 2016-05-03 15:58:35 +00:00
libc_nonshared Add META_MODE support. 2015-06-13 19:20:56 +00:00
libc++ MFH 2016-03-14 18:54:29 +00:00
libcalendar First pass through library packaging. 2016-02-04 21:16:35 +00:00
libcam Fix va_list handling 2016-04-28 18:41:55 +00:00
libcasper MFH 2016-04-16 02:32:12 +00:00
libclang_rt Implement (ACFLAGS|CFLAGS|CXXFLAGS).SRC globally. 2016-03-26 03:46:12 +00:00
libcom_err First pass through library packaging. 2016-02-04 21:16:35 +00:00
libcompat rexec(3): use NULL instead of zero for pointers. 2016-04-18 14:37:26 +00:00
libcompiler_rt MFH 2016-03-06 04:13:17 +00:00
libcrypt MFH 2016-03-10 21:16:01 +00:00
libcuse libcuse: make more use of the howmany() macro when available. 2016-04-26 01:20:16 +00:00
libcxxrt MFH 2016-04-04 23:55:32 +00:00
libdevctl Add 'devctl delete' that calls device_delete_child(). 2016-04-27 16:33:17 +00:00
libdevinfo MFH 2016-04-04 23:55:32 +00:00
libdevstat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libdpv MFH 2016-03-02 16:14:46 +00:00
libdwarf elftoolchain: Use ${SRCTOP} for the top of the FreeBSD tree 2016-04-21 12:58:29 +00:00
libedit lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libefi First pass through library packaging. 2016-02-04 21:16:35 +00:00
libelf elftoolchain: Use ${SRCTOP} for the top of the FreeBSD tree 2016-04-21 12:58:29 +00:00
libelftc elftoolchain: Use ${SRCTOP} for the top of the FreeBSD tree 2016-04-21 12:58:29 +00:00
libevent First pass through library packaging. 2016-02-04 21:16:35 +00:00
libexecinfo First pass through library packaging. 2016-02-04 21:16:35 +00:00
libexpat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libfetch lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libfigpar MFH 2016-03-02 16:14:46 +00:00
libgeom First pass through library packaging. 2016-02-04 21:16:35 +00:00
libgpio Use GPIOTOGGLE to toggle the pin state instead of read, modify and write. 2016-04-19 15:18:31 +00:00
libgssapi lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libiconv_modules META MODE: Prefer INSTALL=tools/install.sh to lessen the need for xinstall.host. 2015-11-25 19:10:28 +00:00
libipsec libipsec: use NULL instead of zero for pointers. 2016-04-18 15:08:31 +00:00
libjail First pass through library packaging. 2016-02-04 21:16:35 +00:00
libkiconv lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libkvm lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libldns First pass through library packaging. 2016-02-04 21:16:35 +00:00
liblzma First pass through library packaging. 2016-02-04 21:16:35 +00:00
libmagic MFV r298178: 2016-04-18 07:36:24 +00:00
libmd MFH 2016-03-02 16:14:46 +00:00
libmemstat MFH 2016-02-10 04:20:39 +00:00
libmilter MFH 2016-03-02 16:14:46 +00:00
libmp MFH 2016-03-10 21:16:01 +00:00
libmt MFH 2016-03-02 16:14:46 +00:00
libnandfs First pass through library packaging. 2016-02-04 21:16:35 +00:00
libnetbsd First pass through library packaging. 2016-02-04 21:16:35 +00:00
libnetgraph First pass through library packaging. 2016-02-04 21:16:35 +00:00
libngatm First pass through library packaging. 2016-02-04 21:16:35 +00:00
libnv MFH 2016-03-10 21:16:01 +00:00
libopenbsd First pass through library packaging. 2016-02-04 21:16:35 +00:00
libopie First pass through library packaging. 2016-02-04 21:16:35 +00:00
libpam MFH 2016-04-16 02:32:12 +00:00
libpcap MFH 2016-03-02 16:14:46 +00:00
libpe DIRDEPS_BUILD: Update dependencies. 2016-02-16 02:14:30 +00:00
libpjdlog MFH 2016-03-02 16:14:46 +00:00
libpmc lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libproc MFH 2016-03-10 21:16:01 +00:00
libprocstat First pass through library packaging. 2016-02-04 21:16:35 +00:00
libradius First pass through library packaging. 2016-02-04 21:16:35 +00:00
librpcsec_gss First pass through library packaging. 2016-02-04 21:16:35 +00:00
librpcsvc MFH 2016-03-02 16:14:46 +00:00
librt MFH 2016-03-10 21:16:01 +00:00
librtld_db First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsbuf First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsdp lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libsm MFH 2016-03-02 16:14:46 +00:00
libsmb First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsmdb MFH 2016-03-02 16:14:46 +00:00
libsmutil MFH 2016-03-02 16:14:46 +00:00
libsqlite3 First pass through library packaging. 2016-02-04 21:16:35 +00:00
libstand libstand: make more use of the howmany() macro when available. 2016-04-26 01:19:36 +00:00
libstdbuf First pass through library packaging. 2016-02-04 21:16:35 +00:00
libstdthreads First pass through library packaging. 2016-02-04 21:16:35 +00:00
libsysdecode MFH 2016-04-04 23:55:32 +00:00
libtacplus First pass through library packaging. 2016-02-04 21:16:35 +00:00
libtelnet First pass through library packaging. 2016-02-04 21:16:35 +00:00
libthr MFH 2016-04-16 02:32:12 +00:00
libthread_db First pass through library packaging. 2016-02-04 21:16:35 +00:00
libucl First pass through library packaging. 2016-02-04 21:16:35 +00:00
libufs First pass through library packaging. 2016-02-04 21:16:35 +00:00
libugidfw First pass through library packaging. 2016-02-04 21:16:35 +00:00
libulog First pass through library packaging. 2016-02-04 21:16:35 +00:00
libunbound MFH 2016-03-14 18:54:29 +00:00
libusb lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libusbhid MFH 2016-04-11 15:24:59 +00:00
libutil Remove useless calls to basename(). 2016-05-01 08:22:11 +00:00
libvgl MFH 2016-04-13 16:19:50 +00:00
libvmmapi lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
libwrap First pass through library packaging. 2016-02-04 21:16:35 +00:00
libxo MFH 2016-04-16 02:32:12 +00:00
liby First pass through library packaging. 2016-02-04 21:16:35 +00:00
libypclnt MFH 2016-04-16 02:32:12 +00:00
libz MFH 2016-04-04 23:55:32 +00:00
msun lib: minor spelling fixes in comments. 2016-05-01 19:37:33 +00:00
ncurses MFH 2016-04-16 02:32:12 +00:00
tests Fix including Kyuafile in packaged base system. 2016-04-29 05:28:40 +00:00
Makefile MFH 2016-03-14 18:54:29 +00:00
Makefile.inc