Support int[*] { 1, 2, 3 } expressions.

This commit is contained in:
Christoffer Lerno
2024-09-12 00:11:09 +02:00
parent 1b54a99f6a
commit 9f4da339c3
4 changed files with 42 additions and 7 deletions

View File

@@ -9,6 +9,7 @@
#if PLATFORM_WINDOWS
#include "direct.h"
#include "intrin.h"
#endif
#if FETCH_AVAILABLE
@@ -412,6 +413,22 @@ static inline bool is_power_of_two(uint64_t x)
return x != 0 && (x & (x - 1)) == 0;
}
static int clz(uint64_t num)
{
#if IS_CLANG || IS_GCC
return (int)__builtin_ctzll(num);
#else
unsigned long index;
_BitScanReverse64(&index, (__int64)num);
return (int)index;
#endif
}
static inline unsigned char power_of_2(uint64_t pot_value)
{
return 64 - clz(pot_value);
}
static inline uint32_t next_highest_power_of_2(uint32_t v)
{
v--;