freebsd-dev/share/man/man3
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
..
assert.3 multiple: Remove 3rd clause from BSD license where approved by the 2014-03-14 03:07:51 +00:00
ATOMIC_VAR_INIT.3 Escape Ed to prevent mandoc to avoid confusion with the mdoc's Ed macros 2014-12-26 21:11:33 +00:00
bitstring.3 Improve performance and functionality of the bitstring(3) api 2016-05-04 22:34:11 +00:00
end.3 multiple: Remove 3rd clause from BSD license where approved by the 2014-03-14 03:07:51 +00:00
fpgetround.3 multiple: Remove 3rd clause from BSD license where approved by the 2014-03-14 03:07:51 +00:00
intro.3 multiple: Remove 3rd clause from BSD license where approved by the 2014-03-14 03:07:51 +00:00
makedev.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
Makefile Separate manual pages into their own package. 2016-01-21 16:36:33 +00:00
Makefile.depend Add META_MODE support. 2015-06-13 19:20:56 +00:00
offsetof.3 Silence mandoc lint. 2014-07-29 19:41:00 +00:00
pthread_affinity_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_atfork.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_attr_affinity_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_attr_get_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_attr_setcreatesuspend_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_attr.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_barrier_destroy.3
pthread_barrierattr.3
pthread_cancel.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_cleanup_pop.3 Correct a typo: this is the manpage for pthread_cleanup_pop, not push. 2014-10-27 15:45:37 +00:00
pthread_cleanup_push.3 Clarify that pthread_cleanup_push()/pop() are implemented as macros that 2014-10-25 19:31:34 +00:00
pthread_cond_broadcast.3
pthread_cond_destroy.3 Make sure sections are sorted into conventional order. 2012-03-25 16:00:56 +00:00
pthread_cond_init.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_cond_signal.3
pthread_cond_timedwait.3 Remove trailing whitespace per mdoc lint warning 2012-03-29 05:02:12 +00:00
pthread_cond_wait.3 Remove trailing whitespace per mdoc lint warning 2012-03-29 05:02:12 +00:00
pthread_condattr.3 General mdoc(7) and typo fixes. 2012-05-11 20:06:46 +00:00
pthread_create.3 Xref pthread_cancel... 2014-03-16 01:17:09 +00:00
pthread_detach.3
pthread_equal.3
pthread_exit.3 Xref pthread_cancel... 2014-03-16 01:17:09 +00:00
pthread_getconcurrency.3 Fixing a typo. 2013-04-15 03:02:55 +00:00
pthread_getcpuclockid.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_getspecific.3 Added description of POSIX-specified behavior when invoked on a key from within that key's destructor. 2015-05-19 02:24:55 +00:00
pthread_getthreadid_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_join.3 - The ETIMEDOUT error applies to pthread_timedjoin_np(), not pthread_join(). 2010-06-29 14:32:01 +00:00
pthread_key_create.3
pthread_key_delete.3
pthread_kill.3
pthread_main_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_multi_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_mutex_destroy.3
pthread_mutex_init.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_mutex_lock.3
pthread_mutex_timedlock.3
pthread_mutex_trylock.3
pthread_mutex_unlock.3
pthread_mutexattr_getkind_np.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_mutexattr.3
pthread_once.3
pthread_resume_all_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_resume_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_rwlock_destroy.3
pthread_rwlock_init.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_rwlock_rdlock.3
pthread_rwlock_timedrdlock.3
pthread_rwlock_timedwrlock.3 - Fix typo 2011-02-24 10:21:26 +00:00
pthread_rwlock_unlock.3
pthread_rwlock_wrlock.3
pthread_rwlockattr_destroy.3
pthread_rwlockattr_getpshared.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_rwlockattr_init.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_rwlockattr_setpshared.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
pthread_schedparam.3
pthread_self.3 Introduce a non-portable function pthread_getthreadid_np(3) to retrieve 2011-02-07 21:26:46 +00:00
pthread_set_name_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_setspecific.3 Provide an unambiguous description of the potential hazard in calling 2015-05-28 16:18:41 +00:00
pthread_sigmask.3 Add restrict keyword to pthread_sigmask prototype and manpage. 2011-02-20 09:52:29 +00:00
pthread_spin_init.3
pthread_spin_lock.3
pthread_suspend_all_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_suspend_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_switch_add_np.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
pthread_testcancel.3 Make wait6(2), waitid(3) and ppoll(2) cancellation points. The 2015-04-18 21:35:41 +00:00
pthread_yield.3
pthread.3 sort SEE ALSO 2014-12-26 22:41:10 +00:00
queue.3 Make the system queue header file fully usable within C++ programs by 2015-06-28 21:06:45 +00:00
siginfo.3 use .Mt to mark up email addresses consistently (part6) 2014-06-23 08:27:27 +00:00
stdarg.3 multiple: Remove 3rd clause from BSD license where approved by the 2014-03-14 03:07:51 +00:00
sysexits.3 Bump date missed in r202756 2012-09-14 17:50:42 +00:00
tgmath.3 Fix a typographical error. 2015-01-06 23:04:41 +00:00
timeradd.3
tree.3 Provide individual prototype and generate macros for the red-black tree. 2015-01-24 12:43:36 +00:00