aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/bluetooth/hccontrol
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2016-05-04 22:34:11 +0000
committerAlan Somers <asomers@FreeBSD.org>2016-05-04 22:34:11 +0000
commit8907f744ff167dcf9545e2cb089e2831bdd58cd6 (patch)
tree2b9b397696c8820e2fd08a07204e38c5e1570743 /usr.sbin/bluetooth/hccontrol
parentdd3f00cbaf11542cacc58ea873ca1adc7c5da2cc (diff)
downloadsrc-8907f744ff167dcf9545e2cb089e2831bdd58cd6.tar.gz
src-8907f744ff167dcf9545e2cb089e2831bdd58cd6.zip
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
Notes
Notes: svn path=/head/; revision=299090
Diffstat (limited to 'usr.sbin/bluetooth/hccontrol')
-rw-r--r--usr.sbin/bluetooth/hccontrol/le.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.sbin/bluetooth/hccontrol/le.c b/usr.sbin/bluetooth/hccontrol/le.c
index c7be20db1e3e..88ef75189e36 100644
--- a/usr.sbin/bluetooth/hccontrol/le.c
+++ b/usr.sbin/bluetooth/hccontrol/le.c
@@ -32,9 +32,9 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
-#include <sys/bitstring.h>
#include <sys/select.h>
#include <assert.h>
+#include <bitstring.h>
#include <err.h>
#include <errno.h>
#include <netgraph/ng_message.h>