format: Fix clz for 32-bit targets

This commit is contained in:
Alexis Engelke
2023-01-14 19:41:46 +01:00
parent 2f7e8dd0de
commit d7aff5de28

View File

@@ -44,7 +44,13 @@ fd_strpcat(char* restrict dst, struct FdStr src) {
static unsigned
fd_clz64(uint64_t v) {
#if defined(__GNUC__)
#if INTPTR_MAX == INT64_MAX
return __builtin_clzl(v);
#else
if (v <= 0xffffffff)
return 32 + __builtin_clzl(v);
return __builtin_clzl(v >> 32);
#endif
#elif defined(_MSC_VER)
unsigned long index;