#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <derive-c/core/attributes.h>
#include <derive-c/core/panic.h>
#include <derive-c/core/compiler.h>
#include <derive-c/core/namespace.h>
#include <bit>
#include <type_traits>
Go to the source code of this file.
◆ DC_MATH_IS_POWER_OF_2
| #define DC_MATH_IS_POWER_OF_2 |
( |
| x | ) |
|
Value:((x) != 0 && ((x) & ((x) - 1)) == 0)
Definition at line 14 of file math.h.
◆ DC_MATH_MSB_INDEX
| #define DC_MATH_MSB_INDEX |
( |
| x | ) |
|
Value:
constexpr unsigned msb_index(T x) noexcept
Definition at line 43 of file math.h.
◆ dc_math_is_aligned_pow2()
Definition at line 67 of file math.h.
68 {
70 return ((uintptr_t)ptr & (alignment - 1)) == 0;
71}
#define DC_MATH_IS_POWER_OF_2(x)
#define DC_ASSUME(expr,...)
◆ dc_math_modulus_power_of_2_capacity()
Definition at line 61 of file math.h.
62 {
64 return index & (capacity - 1);
65}
◆ dc_math_next_power_of_2()
Definition at line 46 of file math.h.
46 {
47 if (x == 0)
48 return 1;
49 x--;
50 x |= x >> 1;
51 x |= x >> 2;
52 x |= x >> 4;
53 x |= x >> 8;
54 x |= x >> 16;
55#if SIZE_MAX > 0xFFFFFFFF
56 x |= x >> 32;
57#endif
58 return x + 1;
59}