chiark / gitweb /
Use fls() if available
[disorder] / lib / bits.h
index 856db683c2a283036f0b70db4c21c11a1a97977d..0965cb602f044f664de5edbe3392b5951feeb106 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 */