blob: 46ba9d93a5ebcc1a0d45ab5d38acda2cea635274 [file] [log] [blame]
#pragma once
#include <stdint.h>
inline static uint32_t bit_length(uint32_t n) {
const uint32_t n_minus_1 = n - 1;
if (n_minus_1 == 0) {
return 0;
} else {
return 32 - __builtin_clz(n_minus_1);
}
}