45static inline uint32_t
__hi(uint64_t x) {
46 return (uint32_t) (x >> 32);
53static inline uint32_t
__lo(uint64_t x) {
61static inline uint64_t
round64(uint64_t x) {
62 uint64_t r = (uint64_t)
__hi(x);
64 if (
__lo(x) >= INT32_MAX) {
80 uint64_t r =
round64((uint64_t)
__lo(x) * (uint64_t) y);
82 r += (uint64_t)
__hi(x) * (uint64_t) y;
96 return (uint32_t)
round64((uint64_t) x * (uint64_t) y);
103 return 32 - __builtin_clz(v);
109static inline uint32_t
ilog_2(uint32_t v) {
110 return 31 - __builtin_clz(v);
124 return (v & (v - 1)) == 0;
static uint32_t next_power_of_2(uint32_t v)
Returns the next highest power of 2 of a value.
Definition utils.h:116
static uint64_t round64(uint64_t x)
The function treats the 64-bit number as if it were a 32-bit integer and a 32-bit fraction,...
Definition utils.h:61
static uint32_t log_next_power_of_2(uint32_t v)
Returns the log of the next highest power of 2 of a value.
Definition utils.h:102
static bool is_power_of_2(uint32_t v)
Returns True if the value is a power of 2.
Definition utils.h:123
static uint32_t scale32(uint32_t x, uint32_t y)
The function scales the 32-bit number x, treating y as if it were an unsigned long fract,...
Definition utils.h:92
static uint32_t ilog_2(uint32_t v)
Returns the integer part of the log to base 2 of a number.
Definition utils.h:109
static uint64_t scale64(uint64_t x, uint32_t y)
The function scales the 64-bit number x, treating y as if it were an unsigned long fract,...
Definition utils.h:76
static uint32_t __hi(uint64_t x)
This function returns the most significant 32-bit word of a 64-bit unsigned integer.
Definition utils.h:45
static uint32_t __lo(uint64_t x)
This function returns the least significant 32-bit word of a 64-bit unsigned integer.
Definition utils.h:53