X-Git-Url: https://git.distorted.org.uk/~mdw/disorder/blobdiff_plain/52b88d2428a808d0636a1cb8205a1f891fc23e6a..d22b8a59995829bc14b4490b9bddd95346e0585d:/lib/bits.h diff --git a/lib/bits.h b/lib/bits.h index 856db68..0965cb6 100644 --- a/lib/bits.h +++ b/lib/bits.h @@ -25,7 +25,15 @@ #ifndef BITS_H #define BITS_H +#include /* for fls() */ + +#if HAVE_FLS +static inline int leftmost_bit(uint32_t n) { + return fls(n) - 1; +} +#else int leftmost_bit(uint32_t n); +#endif #endif /* BITS_H */