X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ffree.c;h=e6d871a58607180c9a81afec54ccbdc7a88c0e2a;hb=d1cea3ebf96f61b5bbac1e74975700770e06add6;hp=5284510a07fbdfd3aa5341360c29448e3eb9f183;hpb=8a462e5a662a6da97060162f0b9220c60ebfdd8c;p=ccan diff --git a/ccan/tdb2/free.c b/ccan/tdb2/free.c index 5284510a..e6d871a5 100644 --- a/ccan/tdb2/free.c +++ b/ccan/tdb2/free.c @@ -17,50 +17,14 @@ */ #include "private.h" #include +#include #include #include #include static unsigned fls64(uint64_t val) { -#if HAVE_BUILTIN_CLZL - if (val <= ULONG_MAX) { - /* This is significantly faster! */ - return val ? sizeof(long) * CHAR_BIT - __builtin_clzl(val) : 0; - } else { -#endif - uint64_t r = 64; - - if (!val) - return 0; - if (!(val & 0xffffffff00000000ull)) { - val <<= 32; - r -= 32; - } - if (!(val & 0xffff000000000000ull)) { - val <<= 16; - r -= 16; - } - if (!(val & 0xff00000000000000ull)) { - val <<= 8; - r -= 8; - } - if (!(val & 0xf000000000000000ull)) { - val <<= 4; - r -= 4; - } - if (!(val & 0xc000000000000000ull)) { - val <<= 2; - r -= 2; - } - if (!(val & 0x8000000000000000ull)) { - val <<= 1; - r -= 1; - } - return r; -#if HAVE_BUILTIN_CLZL - } -#endif + return ilog64(val); } /* In which bucket would we find a particular record size? (ignoring header) */