Move is_power_of_two to misc_utils

This commit is contained in:
2026-01-02 19:19:25 +00:00
parent 91138f9239
commit ebf16c6ba3
2 changed files with 4 additions and 3 deletions

View File

@@ -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;

View File

@@ -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