Move is_power_of_two to misc_utils
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
#include "mem_utils.h"
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/assert/assert.h"
|
||||
#include "../../../common/misc/misc_utils.h"
|
||||
#include <stddef.h>
|
||||
|
||||
wapp_intern b8 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
|
||||
void *wapp_mem_util_align_forward(void *ptr, u64 alignment) {
|
||||
wapp_debug_assert(ptr != NULL, "`ptr` should not be NULL");
|
||||
wapp_runtime_assert(is_power_of_two(alignment), "`alignment` value is not a power of two");
|
||||
wapp_runtime_assert(wapp_is_power_of_two(alignment), "`alignment` value is not a power of two");
|
||||
|
||||
uptr p = (uptr)ptr;
|
||||
uptr align = (uptr)alignment;
|
||||
|
||||
@@ -47,6 +47,8 @@ BEGIN_C_LINKAGE
|
||||
) + 1 \
|
||||
)
|
||||
|
||||
#define wapp_is_power_of_two(NUM) ((NUM & (NUM - 1)) == 0)
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user