count-leading-zeros: new module
authorEric Blake <eblake@redhat.com>
Fri, 10 Aug 2012 22:51:08 +0000 (16:51 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 10 Aug 2012 23:10:15 +0000 (17:10 -0600)
commit0da76a94c8668319c68af5e8c2e71c80528db5de
tree5ac0d7b5a649530427cdcba712f3c5030e4ac4ce
parenta451aa0d0cbbec1efae7d07eb002fd4220511a27
count-leading-zeros: new module

I needed gcc's clz to determine the most significant bit of a
number (useful for things like truncating to a power of 2),
and was surprised it is not a standardized function (the
opposite direction of finding the least significant bit is
given by ffs).  This borrows heavily from the design of the
count-one-bits module.

* modules/count-leading-zeros: New module.
* m4/count-leading-zeros.m4: New file.
* lib/count-leading-zeros.h: Likewise.
* modules/count-leading-zeros-tests: New test.
* tests/test-count-leading-zeros.c: New file.
* MODULES.html.sh (Integer arithmetic functions): Document it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
MODULES.html.sh
lib/count-leading-zeros.h [new file with mode: 0644]
m4/count-leading-zeros.m4 [new file with mode: 0644]
modules/count-leading-zeros [new file with mode: 0644]
modules/count-leading-zeros-tests [new file with mode: 0644]
tests/test-count-leading-zeros.c [new file with mode: 0644]