2 * ilog - Integer logarithm.
4 * ILOG_32() and ILOG_64() compute the minimum number of bits required to store
5 * an unsigned 32-bit or 64-bit value without any leading zero bits.
6 * This can also be thought of as the location of the highest set bit, with
7 * counting starting from one (so that 0 returns 0, 1 returns 1, and 2**31
9 * When the value is known to be non-zero ILOGNZ_32() and ILOGNZ_64() can
10 * compile into as few as two instructions, one of which may get optimized out
12 * STATIC_ILOG_32 and STATIC_ILOG_64 allow computation on compile-time
13 * constants, so other compile-time constants can be derived from them.
18 * #include <ccan/ilog/ilog.h>
22 * printf("ILOG_32(0x%08X)=%i\n",0,ILOG_32(0));
23 * for(i=1;i<=STATIC_ILOG_32(USHRT_MAX);i++){
25 * v=(uint32_t)1U<<i-1;
26 * //Here we know v is non-zero, so we can use ILOGNZ_32().
27 * printf("ILOG_32(0x%08X)=%i\n",v,ILOGNZ_32(v));
32 * License: LGPL (v2 or later)
37 int main(int _argc,const char *_argv[]){
38 /*Expect exactly one argument.*/
40 if(strcmp(_argv[1],"depends")==0){
41 /*PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY*/