#include <derive-c/core/panic.h>
#include <stdlib.h>
Go to the source code of this file.
◆ DEBUG_UNUSED
#define DEBUG_UNUSED |
( |
| ident | ) |
|
Value:ident __attribute__((unused))
Definition at line 11 of file helpers.h.
◆ EXPAND
◆ FORCE_INLINE
#define FORCE_INLINE inline __attribute__((always_inline)) |
◆ LIKELY
Value:__builtin_expect(!!(x), 1)
Definition at line 18 of file helpers.h.
◆ NS
Value:
#define NS_EXPANDED(pre, post)
Definition at line 6 of file helpers.h.
◆ NS_EXPANDED
#define NS_EXPANDED |
( |
| pre, |
|
|
| post ) |
◆ PRIVATE
◆ UNUSED
Value:ident __attribute__((unused))
Definition at line 16 of file helpers.h.
◆ is_power_of_2()
bool is_power_of_2 |
( |
size_t | x | ) |
|
|
inlinestatic |
Definition at line 46 of file helpers.h.
46{ return x != 0 && (x & (x - 1)) == 0; }
◆ modulus_power_of_2_capacity()
size_t modulus_power_of_2_capacity |
( |
size_t | index, |
|
|
size_t | capacity ) |
|
inlinestatic |
Definition at line 48 of file helpers.h.
48 {
50
51 return index & (capacity - 1);
52}
static bool is_power_of_2(size_t x)
#define DEBUG_ASSERT(expr)
◆ next_power_of_2()
size_t next_power_of_2 |
( |
size_t | x | ) |
|
|
inlinestatic |
Definition at line 31 of file helpers.h.
31 {
32 if (x == 0)
33 return 1;
34 x--;
35 x |= x >> 1;
36 x |= x >> 2;
37 x |= x >> 4;
38 x |= x >> 8;
39 x |= x >> 16;
40#if SIZE_MAX > 0xFFFFFFFF
41 x |= x >> 32;
42#endif
43 return x + 1;
44}