diff options
author | daan <daanl@outlook.com> | 2019-09-09 08:12:50 -0700 |
---|---|---|
committer | daan <daanl@outlook.com> | 2019-09-09 08:12:50 -0700 |
commit | ce81af11199b05ade3a1faf9c3dcf53459ee643f (patch) | |
tree | 8f62b875775edc5ed69c82714adf37c7c328fa0f /include/mimalloc-internal.h | |
parent | b104e434e44da8bc4e2fc50d92d4f9a36c086c72 (diff) |
use mi_is_power_of_two when possible (pr #118)
Diffstat (limited to 'include/mimalloc-internal.h')
-rw-r--r-- | include/mimalloc-internal.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index de77f3b..fd97b3e 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -167,10 +167,12 @@ static inline bool mi_mul_overflow(size_t count, size_t size, size_t* total) { #endif } -// Align upwards -static inline uintptr_t _mi_is_power_of_two(uintptr_t x) { +// Is `x` a power of two? +static inline bool _mi_is_power_of_two(uintptr_t x) { return ((x & (x - 1)) == 0); } + +// Align upwards static inline uintptr_t _mi_align_up(uintptr_t sz, size_t alignment) { uintptr_t mask = alignment - 1; if ((alignment & mask) == 0) { // power of two? |