summaryrefslogtreecommitdiff
path: root/lib/pow2.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pow2.h')
-rw-r--r--lib/pow2.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/pow2.h b/lib/pow2.h
new file mode 100644
index 00000000..2cbca1ab
--- /dev/null
+++ b/lib/pow2.h
@@ -0,0 +1,12 @@
+#ifndef FIO_POW2_H
+#define FIO_POW2_H
+
+#include <inttypes.h>
+#include "types.h"
+
+static inline bool is_power_of_2(uint64_t val)
+{
+ return (val != 0 && ((val & (val - 1)) == 0));
+}
+
+#endif