summaryrefslogtreecommitdiff
path: root/lib/bitops.h
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-09-09 02:43:39 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-11-26 18:39:02 +0100
commitaf02b83b888c693c292960072195f0e1caf1d2a1 (patch)
treef9d1b7d31e6f56a541493a8e86b9195e1213cb7b /lib/bitops.h
parentd033e6327d1e63f5d212981fca785b5086491905 (diff)
Lib: Basic and hierarchical bitmaps
Basic bitmap is obvious. Hierarchical bitmap is structure of several bitmaps, where higher levels are conjunctions of intervals on level below, allowing for efficient lookup of first unset bit.
Diffstat (limited to 'lib/bitops.h')
-rw-r--r--lib/bitops.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/bitops.h b/lib/bitops.h
index 39ade388..a4c48a10 100644
--- a/lib/bitops.h
+++ b/lib/bitops.h
@@ -29,6 +29,9 @@ static inline u32 u32_hash(u32 v) { return v * 2902958171u; }
static inline u8 u32_popcount(u32 v) { return __builtin_popcount(v); }
+static inline int u32_clz(u32 v) { return __builtin_clz(v); }
+static inline int u32_ctz(u32 v) { return __builtin_ctz(v); }
+
static inline int uint_is_pow2(uint n) { return n && !(n & (n-1)); }
#endif