Use fls() if available
[disorder] / lib / bits.h
index 856db68..0965cb6 100644 (file)
 #ifndef BITS_H
 #define BITS_H
 
+#include <string.h>                     /* 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 */