util: ilog2

This commit is contained in:
Matheus
2023-07-16 21:43:22 -03:00
parent f3714b83c8
commit cf858a87fc
+4
View File
@@ -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