opnsense-src/sys/dev
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
..
aac
aacraid
acpi_support s/struct device */device_t/g 2016-05-04 06:26:27 +00:00
acpica
adb
adlink
advansys
ae
age
agp
aha
ahb
ahci
aic
aic7xxx
alc
ale
alpm
altera
amdpm
amdsbwd
amdsmb
amdtemp
amr
an
arcmsr
asmc
ata
ath
atkbdc
auxio
bce
beri
bfe
bge
bhnd
bktr
bm
buslogic s/struct device */device_t/g 2016-05-04 06:24:10 +00:00
bvm
bwi
bwn [bwn] fix rate control feedback. 2016-05-04 02:11:45 +00:00
bxe
cadence
cardbus
cas
ce
cesa
cfe
cfi
ciss
cm
cmx
coretemp
cp
cpuctl
cpufreq
cs
ct
ctau
cx
cxgb
cxgbe
cy
cyapa
dc
dcons
de
digi
dpaa
dpms
dpt
drm
drm2
dwc
e1000
ed
eisa
en
ep
esp s/struct device */device_t/g 2016-05-04 06:24:51 +00:00
et
etherswitch
ex
exca
extres
fatm
fb
fdc s/struct device */device_t/g 2016-05-04 06:25:12 +00:00
fdt
fe
ffec
filemon
firewire
flash
fxp
gem
glxiic
glxsb
gpio
gxemul
hatm
hifn
hme
hpt27xx
hptiop Use imin() macro from sys/libkern.h. 2016-05-04 01:43:07 +00:00
hptmv
hptnr
hptrr
hwpmc
hyperv
ic
ichiic
ichsmb
ichwd
ida
ie
if_ndis
iicbus
iir
intpm
io
ioat Use DEVMETHOD_END ({ NULL, NULL }) instead of hardcoding { 0, 0 } 2016-05-03 23:56:52 +00:00
ipmi
ips
ipw
isci
iscsi
iscsi_initiator
isl
ismt
isp
ispfw
iwi
iwm
iwn iwn: fix device reset after watchdog timeout. 2016-05-04 12:51:27 +00:00
ixgb
ixgbe
ixl
jme
joy
kbd
kbdmux
ksyms
le
led
lge
lmc s/struct device */device_t/g 2016-05-04 06:23:49 +00:00
malo
mbox
mc146818
mca
mcd
md
mdio
mem
mfi
mge
mii
mk48txx
mlx
mlx5
mly
mmc
mn
mpr
mps
mpt
mrsas
mse
msk
mvs
mwl
mxge
my
nand
ncr
nctgpio
ncv
netfpga10g/nf10bmac
netmap sys/dev: minor spelling fixes. 2016-05-03 03:41:25 +00:00
nfe
nfsmb
nge
nmdm
nsp
ntb
null
nvd
nvme
nvram
nvram2env Fix nvram2env after bus_space_fdt removal. 2016-05-04 01:56:37 +00:00
nxge
oce
ofw
otus
ow
patm
pbio
pccard
pccbb
pcf
pci Fix build without "options PCI_IOV". 2016-05-04 06:22:41 +00:00
pcn
pdq
pms dev/pms: minor spelling fixes for the FreeBSD-specific part. 2016-05-04 17:52:53 +00:00
powermac_nvram
ppbus
ppc
proto
psci
pst
pty
puc
qlxgb
qlxgbe
qlxge
quicc
ral
random
rc
rccgpio
re
rl
rndtest
rp
rt
rtwn
safe
sbni
scc
scd
sdhci
sec
sf
sfxge
sge
si
siba
siis
sio
sis
sk
smbus
smc
sn
snc
snp
sound
speaker
spibus
ste
stg
stge
streams
sym
syscons
tdfx
terasic
ti
tl
tpm
trm
tsec
twa
twe
tws
tx
txp
uart
ubsec
urtwn
usb Extend the UQ_NO_STRINGS quirk to also cover the USB language string 2016-05-04 08:57:40 +00:00
utopia
vge
viapm
viawd
videomode
virtio
vkbd
vmware/vmxnet3
vnic
vr
vt
vte
vx
vxge
watchdog
wb
wbwd
wds
wi wi: fix a comment (0x1fff has 13 bits set). 2016-05-04 18:08:38 +00:00
wl
wpi
wtap
xe
xen Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
xilinx
xl