|
XenevaOS
|


Go to the source code of this file.
Macros | |
| #define | __round_mask(x, y) ((__typeof__(x))((y)-1)) |
| #define | round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) |
| #define | round_down(x, y) ((x) & ~__round_mask(x, y)) |
| #define | DIV_ROUND_UP_POW2(n, d) ((n) / (d) + !!((n) & ((d) - 1))) |
| #define | DIV_ROUND_UP __KERNEL_DIV_ROUND_UP |
| #define | DIV_ROUND_DOWN_ULL(ll, d) ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; }) |
| #define | DIV_ROUND_UP_ULL(ll, d) DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d)) |
| #define | DIV_ROUND_UP_SECTOR_T(ll, d) DIV_ROUND_UP(ll,d) |
| #define | roundup(x, y) |
| #define | rounddown(x, y) |
| #define | DIV_ROUND_CLOSEST __KERNEL_DIV_ROUND_CLOSEST |
| #define | DIV_ROUND_CLOSEST_ULL(x, divisor) |
| #define | __STRUCT_FRACT(type) |
| #define | mult_frac(x, n, d) |
| #define | sector_div(a, b) do_div(a, b) |
| #define | abs(x) |
| #define | __abs_choose_expr(x, type, other) |
| #define | abs_diff(a, b) |
Functions | |
| u64 | int_pow (u64 base, unsigned int exp) |
| unsigned long | int_sqrt (unsigned long) |
| u32 | int_sqrt64 (u64 x) |
| #define __abs_choose_expr | ( | x, | |
| type, | |||
| other | |||
| ) |
| #define __round_mask | ( | x, | |
| y | |||
| ) | ((__typeof__(x))((y)-1)) |
| #define __STRUCT_FRACT | ( | type | ) |
| #define abs | ( | x | ) |
abs - return absolute value of an argument @x: the value.
If it is unsigned type, @x is converted to signed type first. char is treated as if it was signed (regardless of whether it really is) but the macro's return type is preserved as char.
NOTE, for signed type if @x is the minimum, the returned result is undefined as there is not enough bits to represent it as a positive number.
Return: an absolute value of @x.
abs_diff - return absolute value of the difference between the arguments : the first argument : the second argument
and have to be of the same type. With this restriction we compare signed to signed and unsigned to unsigned. The result is the subtraction the smaller of the two from the bigger, hence result is always a positive value.
Return: an absolute value of the difference between the and .
| #define DIV_ROUND_CLOSEST __KERNEL_DIV_ROUND_CLOSEST |
| #define DIV_ROUND_CLOSEST_ULL | ( | x, | |
| divisor | |||
| ) |
| #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP |
DIV_ROUND_UP_POW2 - divide and round up
: numerator @d: denominator (must be a power of 2)
Divides
by @d and rounds up to next multiple of @d (which must be a power of 2). Avoids integer overflows that may occur with __KERNEL_DIV_ROUND_UP(). Performance is roughly equivalent to __KERNEL_DIV_ROUND_UP().
| #define DIV_ROUND_UP_SECTOR_T | ( | ll, | |
| d | |||
| ) | DIV_ROUND_UP(ll,d) |
| #define DIV_ROUND_UP_ULL | ( | ll, | |
| d | |||
| ) | DIV_ROUND_DOWN_ULL((unsigned long long)(ll) + (d) - 1, (d)) |
| #define mult_frac | ( | x, | |
| n, | |||
| d | |||
| ) |
| #define round_down | ( | x, | |
| y | |||
| ) | ((x) & ~__round_mask(x, y)) |
round_down - round down to next specified power of 2 @x: the value to round @y: multiple to round down to (must be a power of 2)
Rounds @x down to next multiple of @y (which must be a power of 2). To perform arbitrary rounding down, use rounddown() below.
| #define round_up | ( | x, | |
| y | |||
| ) | ((((x)-1) | __round_mask(x, y))+1) |
round_up - round up to next specified power of 2 @x: the value to round @y: multiple to round up to (must be a power of 2)
Rounds @x up to next multiple of @y (which must be a power of 2). To perform arbitrary rounding up, use roundup() below.
| #define rounddown | ( | x, | |
| y | |||
| ) |
rounddown - round down to next specified multiple @x: the value to round @y: multiple to round down to
Rounds @x down to next multiple of @y. If @y will always be a power of 2, consider using the faster round_down().
| #define roundup | ( | x, | |
| y | |||
| ) |
roundup - round up to the next specified multiple @x: the value to up @y: multiple to round up to
Rounds @x up to next multiple of @y. If @y will always be a power of 2, consider using the faster round_up().
| unsigned long int_sqrt | ( | unsigned long | ) |