|
| #define | IC_NUM_BITS(t) (sizeof(t) * 8) |
| | Number of bits that make up a type. More...
|
| |
| #define | IC_POINTER_TO_UINT(x) ((uintptr_t) (x)) |
| | Cast x, a pointer, to an unsigned integer. More...
|
| |
| #define | IC_UINT_TO_POINTER(x) ((void *) (uintptr_t) (x)) |
| | Cast x, an unsigned integer, to a void*. More...
|
| |
| #define | IC_POINTER_TO_INT(x) ((intptr_t) (x)) |
| | Cast x, a pointer, to a signed integer. More...
|
| |
| #define | IC_INT_TO_POINTER(x) ((void *) (intptr_t) (x)) |
| | Cast x, a signed integer, to a void*. More...
|
| |
| #define | IC_GENMASK32(h, l) (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (32UL - 1 - (h)))) |
| | Create a contiguous bitmask starting at bit position l and ending at position h. More...
|
| |
| #define | IC_GENMASK64(h, l) (((~0ULL) - (1ULL << (l)) + 1) & (~0ULL >> (64ULL - 1 - (h)))) |
| | Create a contiguous 64-bit bitmask starting at bit position l and ending at position h. More...
|
| |
| #define | IC_G_LSB_GET(value) ((value) & -(value)) |
| | Only use in global scope; extract the Least Significant Bit from value. More...
|
| |
| #define | IC_LSB_GET(value) _IC_MAKE_SINGLE_EVAL_1(value) |
| | Extract the Least Significant Bit from value. More...
|
| |
| #define | IC_G_FIELD_GET(mask, value) (((value) & (mask)) / IC_LSB_GET(mask)) |
| | Only use in global scope; extract a bitfield element from value corresponding to the field mask mask. More...
|
| |
| #define | IC_FIELD_GET(mask, value) _IC_MAKE_SINGLE_EVAL_2(IC_G_FIELD_GET, mask, value) |
| | Extract a bitfield element from value corresponding to the field mask mask. More...
|
| |
| #define | IC_G_FIELD_PREP(mask, value) (((value) * IC_LSB_GET(mask)) & (mask)) |
| | Only use in global scope; prepare a bitfield element using value with mask representing its field position and width. The result should be combined with other fields using a logical OR. More...
|
| |
| #define | IC_FIELD_PREP(mask, value) _IC_MAKE_SINGLE_EVAL_2(IC_G_FIELD_PREP, mask, value) |
| | Prepare a bitfield element using value with mask representing its field position and width. The result should be combined with other fields using a logical OR. More...
|
| |
| #define | IC_ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1) |
| | 0 if cond is true-ish; causes a compile error otherwise. More...
|
| |
| #define | IC_ARRAY_LENGTH(array) (unsigned int) (_IC_IS_ARRAY(array) + (sizeof(array) / sizeof((array)[0]))) |
| | Number of elements in the given array; the "length". More...
|
| |
| #define | IC_ARRAY_SIZE(array) (size_t)(_IC_IS_ARRAY(array) + sizeof(array)) |
| | Size of the given array in 8-bit bytes. More...
|
| |
| #define | IC_IS_ARRAY_ELEMENT(array, ptr) |
| | Whether ptr is an element of array. More...
|
| |
| #define | IC_ARRAY_INDEX(array, ptr) IC_IS_ARRAY_ELEMENT(array, ptr) ? (__typeof__((array)[0]) *) (ptr) - (array) : -1 |
| | Index of ptr within array. More...
|
| |
| #define | IC_PART_OF_ARRAY(array, ptr) |
| | Check if a pointer ptr lies within array. More...
|
| |
| #define | IC_ARRAY_INDEX_FLOOR(array, ptr) |
| | Array-index of ptr within array, rounded down. More...
|
| |
| #define | IC_SAME_TYPE(a, b) __builtin_types_compatible_p(__typeof__(a), __typeof__(b)) |
| | Validate if two entities have a compatible type. More...
|
| |
| #define | IC_CONTAINER_OF(ptr, type, field) |
| | Get a pointer to a structure containing the element. More...
|
| |
| #define | IC_G_IROUND_UP(x, align) |
| | Only use in global scope; value of integer x rounded up to the next multiple of align. More...
|
| |
| #define | IC_IROUND_UP(x, align) _IC_MAKE_SINGLE_EVAL_2(IC_G_IROUND_UP, x, align) |
| | Value of integer x rounded up to the next multiple of align. More...
|
| |
| #define | IC_G_IROUND_DOWN(x, align) (((unsigned long) (x) / (unsigned long) (align)) * (unsigned long) (align)); |
| | Only use in global scope; value of integer x rounded down to the next multiple of align. More...
|
| |
| #define | IC_IROUND_DOWN(x, align) _IC_MAKE_SINGLE_EVAL_2(IC_IROUND_DOWN, x, align) |
| | Value of integer x rounded down to the next multiple of align. More...
|
| |
| #define | IC_WB_UP(x) IC_IROUND_UP(x, sizeof(void *)) |
| | Value of x rounded up to the next word boundary. More...
|
| |
| #define | IC_WB_DN(x) IC_IROUND_DOWN(x, sizeof(void *)) |
| | Value of x rounded down to the previous word boundary. More...
|
| |
| #define | IC_G_CEIL(x) ceil(x) |
| | Only use in global scope; compile-time floating point ceiling of f32 (float), f64 (double), & f128 (long double). More...
|
| |
| #define | IC_CEIL(x) |
| | Compile-time floating point ceiling of f32 (float), f64 (double), & f128 (long double). More...
|
| |
| #define | IC_G_FLOOR(x) floor(x) |
| | Only use in global scope; compile-time floating point floor of f32 (float), f64 (double), & f128 (long double). More...
|
| |
| #define | IC_FLOOR(x) |
| | Compile-time floating point floor of f32 (float), f64 (double), & f128 (long double). More...
|
| |
| #define | IC_G_ROUND(x) (__typeof__(x)) (int64_t) ((x) + ((x) >= 0 ? 0.5 : -0.5)) |
| | Only use in global scope; round of f32 (float), f64 (double), & f128 (long double). More...
|
| |
| #define | IC_ROUND(x) |
| | Round of f32 (float), f64 (double), & f128 (long double). More...
|
| |
| #define | IC_G_DIV_ROUND_UP(n, d) (((n) + (d) -1) / (d)) |
| | Only use in global scope; divide and round up. More...
|
| |
| #define | IC_DIV_ROUND_UP(n, d) _IC_MAKE_SINGLE_EVAL_2(IC_G_DIV_ROUND_UP, n, d) |
| | Divide and round up. More...
|
| |
| #define | IC_G_DIV_ROUND_CLOSEST(n, d) ((((n) < 0) ^ ((d) < 0)) ? ((n) - ((d) / 2)) / (d) : ((n) + ((d) / 2)) / (d)) |
| | Only use in global scope; divide and round to the nearest integer. More...
|
| |
| #define | IC_DIV_ROUND_CLOSEST(n, d) _IC_MAKE_SINGLE_EVAL_2(IC_G_DIV_ROUND_CLOSEST, n, d) |
| | Divide and round to the nearest integer. More...
|
| |
| #define | IC_G_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
| | Only use in global scope; obtain the maximum of two values. More...
|
| |
| #define | IC_MAX(a, b) _IC_MAKE_SINGLE_EVAL_2(IC_G_MAX, a, b) |
| | Obtain the maximum of two values. More...
|
| |
| #define | IC_G_MIN(a, b) (((a) < (b)) ? (a) : (b)) |
| | Only use in global scope; obtain the minimum of two values. More...
|
| |
| #define | IC_MIN(a, b) _IC_MAKE_SINGLE_EVAL_2(IC_G_MIN, a, b) |
| | Obtain the minimum of two values. More...
|
| |
| #define | IC_G_CLAMP(val, low, high) (((val) <= (low)) ? (low) : IC_MIN(val, high)) |
| | Only use in global scope; clamp a value to a given range. More...
|
| |
| #define | IC_CLAMP(val, low, high) _IC_MAKE_SINGLE_EVAL_3(IC_G_CLAMP, val, low, high) |
| | Clamp a value to a given range. More...
|
| |
| #define | IC_G_IN_RANGE(val, min, max) ((__typeof__(val)) -1) > 0 ? ((val) <= (max)) : ((val) >= (min) && (val) <= (max)) |
| | Only use in global scope; checks if a value is within range. More...
|
| |
| #define | IC_IN_RANGE(val, min, max) _IC_MAKE_SINGLE_EVAL_3(IC_G_IN_RANGE, val, min, max) |
| | Checks if a value is within range. More...
|
| |
| #define | IC_G_ILOG2(x) (sizeof(__typeof__(x)) > 4 ? (64 - __builtin_clzll(x) - 1) : (32 - __builtin_clz(x) - 1)) |
| | Only use in global scope; compute integer value of log2(x) More...
|
| |
| #define | IC_ILOG2(x) |
| | Compute integer value log2(x) More...
|
| |
| #define | IC_G_LOG2CEIL(x) (x) < 1 ? 0 : IC_G_ILOG2((x) -1) + 1 |
| | Only use in global scope; compute ceil(log2(x)) More...
|
| |
| #define | IC_LOG2CEIL(x) _IC_MAKE_SINGLE_EVAL_1(IC_G_LOG2CEIL, x) |
| | Compute ceil(log2(x)) More...
|
| |
| #define | IC_G_NHPOT(x) ((x) < 1 ? 1 : ((x) > (1ULL << 63) ? 0 : 1ULL << IC_G_LOG2CEIL(x))) |
| | Only use in global scope; compute next highest power of two. More...
|
| |
| #define | IC_NHPOT(x) _IC_MAKE_SINGLE_EVAL_1(IC_G_NHPOT, x) |
| | Compute next highest power of two. More...
|
| |
| #define | IC_G_POW2_CEIL(x) ((x) <= 2UL ? (x) : (1UL << (8 * sizeof(long) - __builtin_clzl((x) -1)))) |
| | Only use in global scope; calculate power of two ceiling for some nonzero value. More...
|
| |
| #define | IC_POW2_CEIL(x) _IC_MAKE_SINGLE_EVAL_1(IC_G_POW2_CEIL, x) |
| | Calculate power of two ceiling for some nonzero value. More...
|
| |
| #define | IC_G_IS_POW2(x) (((x) != 0) && (((x) & ((x) -1)) == 0)) |
| | Only use in global scope; check whether or not a value is a power of 2. More...
|
| |
| #define | IC_IS_POW2(x) _IC_MAKE_SINGLE_EVAL_1(IC_G_IS_POW2) |
| | Check whether or not a value is a power of 2. More...
|
| |
| #define | IC_BIT(n) (1UL << (n)) |
| | Unsigned integer with bit position n set. More...
|
| |
| #define | IC_BIT64(n) (1ULL << (n)) |
| | 64-bit unsigned integer with bit position n set. More...
|
| |
| #define | IC_G_WRITE_BIT(var, bit, set) (set) ? ((var) | IC_BIT(bit)) : ((var) & ~IC_BIT(bit)) |
| | Only use in global scope; set or clear a bit depending on a boolean value. More...
|
| |
| #define | IC_WRITE_BIT(var, bit, set) _IC_MAKE_SINGLE_EVAL_3(IC_G_WRITE_BIT, var, bit, set) |
| | Set or clear a bit depending on a boolean value. More...
|
| |
| #define | IC_BIT_MASK(n) (IC_BIT(n) - 1UL) |
| | Bit mask with bits 0 through n-1 (inclusive) set, or 0 if n is 0. More...
|
| |
| #define | IC_BIT64_MASK(n) (IC_BIT64(n) - 1ULL) |
| | 64-bit bit mask with bits 0 through n-1 (inclusive) set, or 0 if n is 0. More...
|
| |
| #define | IC_G_IS_SHIFTED_BIT_MASK(m, s) (!(((m) >> (s)) & (((m) >> (s)) + 1U))) |
| | Only use in global scope; check if bits are set continuously from the specified bit. More...
|
| |
| #define | IC_IS_SHIFTED_BIT_MASK(m, s) _IC_MAKE_SINGLE_EVAL_2(IC_G_IS_SHIFTED_BIT_MASK, m, s) |
| | Check if bits are set continuously from the specified bit. More...
|
| |
| #define | IC_G_IS_BIT_MASK(m) IC_G_IS_SHIFTED_BIT_MASK(m, 0) |
| | Only use in global scope; check if bits are set continuously from the LSB. More...
|
| |
| #define | IC_IS_BIT_MASK(m) IC_IS_SHIFTED_BIT_MASK(m, 0) |
| | Check if bits are set continuously from the LSB. More...
|
| |
| #define | IC_G_BSWAP24(x) (((x) >> 16) & 0x0000FF) | (((x) >> 00) & 0x00FF00) | ((((x) & 0x0000FF) << 16)) |
| | Only use in global scope; 24-bit byte swap. More...
|
| |
| #define | IC_BSWAP24(x) _IC_MAKE_SINGLE_EVAL_1(IC_G_BSWAP24, x) |
| | 24-bit byte swap. More...
|
| |