]> The Tcpdump Group git mirrors - libpcap/commit
Clean up the "find first bit set" stuff.
authorGuy Harris <[email protected]>
Fri, 22 Sep 2017 20:25:03 +0000 (13:25 -0700)
committerGuy Harris <[email protected]>
Fri, 22 Sep 2017 20:25:03 +0000 (13:25 -0700)
commitc9c706d86a62066afc2c011b214e75de93eebda6
tree09ef82177e78a745c3a99ab7a21fa44889b99942
parent37c525063f697d02e73fa9180b767a202fc6444f
Clean up the "find first bit set" stuff.

We really want a zero-origin "find first bit set" that returns 0 if the
low-order bit is set.  Have a lowest_set_bit() function that does that,
and whose behavior is undefined if no bit is set; that's OK, as the loop
that uses it checks for an empty bit set.

If we have GCC 3.4 or later, or a compiler that claims compatibility
with it, just use __builtin_ctz() (the index of the first bit set is
equal to the count of trailing zeroes).

Otherwise, if we have Visual Studio 2005 or later, use
_BitScanForward().

Otherwise, if we have DJGPP on MS-DOS, call ffs() and subtract 1 from
its result; we've already included <string.h>, which declares ffs().

Otherwise, if we have Watcom C on MS-DOS, or if we have ffs() and it's
declared in <strings.h>, include <strings.h>, call ffs(), and subtract 1
from its result.

Otherwise, use a perfect-hash-function-based algorithm.

While we're at it, move the compiler version tests into
pcap/compiler-tests.h, in case they're needed by something that doesn't
include pcap/funcattrs.h.
CMakeLists.txt
Makefile.in
config.h.in
configure
configure.ac
optimize.c
pcap/compiler-tests.h [new file with mode: 0644]
pcap/funcattrs.h