diff --git a/kernel-src/include/util.h b/kernel-src/include/util.h index 287bfea0..1bace0df 100644 --- a/kernel-src/include/util.h +++ b/kernel-src/include/util.h @@ -8,4 +8,8 @@ static inline long abs(long x) { return x < 0 ? -x : x; } +static inline long ilog2(long x) { + return sizeof(long) * 8 - __builtin_clz(x) - 1; +} + #endif