#include <linux/types.h>
#include <linux/bitops.h>
Go to the source code of this file.
ilog2 - log of base 2 of 32-bit or a 64-bit unsigned value
- parameter
constant-capable log of base 2 calculation
- this can be used to initialise global variables from constant data, hence the massive ternary operator construction
selects the appropriately-sized optimised version depending on sizeof(n)
Definition at line 85 of file log2.h.
order_base_2 - calculate the (rounded up) base 2 order of the argument
: parameter
The first few values calculated by this routine: ob2(0) = 0 ob2(1) = 0 ob2(2) = 1 ob2(3) = 2 ob2(4) = 2 ob2(5) = 3 ... and so on.
Definition at line 206 of file log2.h.
#define rounddown_pow_of_two |
( |
|
n | ) |
|
Value:( \
__builtin_constant_p(
n) ? ( \
__rounddown_pow_of_two(
n) \
)
rounddown_pow_of_two - round the given value down to nearest power of two
- parameter
round the given value down to the nearest power of two
- the result is undefined when n == 0
- this can be used to initialise global variables from constant data
Definition at line 185 of file log2.h.
#define roundup_pow_of_two |
( |
|
n | ) |
|
Value:( \
__builtin_constant_p(
n) ? ( \
) : \
__roundup_pow_of_two(
n) \
)
roundup_pow_of_two - round the given value up to nearest power of two
- parameter
round the given value up to the nearest power of two
- the result is undefined when n == 0
- this can be used to initialise global variables from constant data
Definition at line 168 of file log2.h.