49 unsigned int m = (
BITLL(32 + p) + div - 1) / (
unsigned long long)div;
51 return (
udiv_t){ .p = p, .m = m, };
64 unsigned int q = ((
unsigned long long)udiv.
m * val) >> 32;
65 unsigned int t = ((val - q) >> 1) + q;
67 return t >> (udiv.
p - 1);
84 if (__predict_false(udiv.
p == 0x20))
88 if (__predict_false(udiv.
m == 0 && udiv.
p == 0))
Various common macros used throughout the codebase.
Functions to help with integer math.
static bool is_power_of_two(unsigned int val)
Definition intmath.h:24
Macros to help dealing with register fields.
#define BITLL(bit)
Create a 64-bit mask with a bit set.
Definition regfield.h:34
Pre-processed unsigned integer divider value.
Definition udiv.h:33
unsigned int p
Definition udiv.h:34
unsigned int m
Definition udiv.h:35
static udiv_t udiv_set_divider(unsigned int div)
Create a udiv_t from an unsigned int divider.
Definition udiv.h:46
static unsigned int udiv_divide(unsigned int val, udiv_t udiv)
Perform a division using the udiv_t, with bound checking.
Definition udiv.h:79
static unsigned int udiv_divide_fast(unsigned int val, udiv_t udiv)
Perform a division using the udiv_t, without bound checking.
Definition udiv.h:63