#ifndef UTILS_MATH_H #define UTILS_MATH_H #include // https://stackoverflow.com/questions/466204/rounding-up-to-next-power-of-2 // https://stackoverflow.com/questions/1322510/given-an-integer-how-do-i-find-the-next-largest-power-of-two-using-bit-twiddlin/1322548#1322548 static inline uint64_t utils_nearest_bigger_power_of_2_u64(uint64_t value) { value--; value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; value |= value >> 32; value++; return value; } #endif