aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bits.h
diff options
Diffstat (limited to 'bits.h')
-rw-r--r--bits.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/bits.h b/bits.h
index c0dc952e..63a663c2 100644
--- a/bits.h
+++ b/bits.h
@@ -58,4 +58,9 @@ static inline long long bits_extend(long long val, unsigned size, int is_signed)
return val;
}
+static inline int is_power_of_2(long long val)
+{
+ return val && !(val & (val - 1));
+}
+
#endif