diff options
Diffstat (limited to 'src/include/math.h')
-rw-r--r-- | src/include/math.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/include/math.h b/src/include/math.h new file mode 100644 index 000000000..eddb92f64 --- /dev/null +++ b/src/include/math.h @@ -0,0 +1,23 @@ +#include <stdint.h> +#include <builtins.h> + +#ifndef _MATH_H +#define _MATH_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +ALWAYS_INLINE +static inline int64_t log2(uint64_t s) +{ + int64_t n = cntlzd(s); + return 63-n; +} + +#ifdef __cplusplus +}; +#endif + +#endif |