diff --git a/userspace/libraries/LibC/malloc.cpp b/userspace/libraries/LibC/malloc.cpp index 2c44cce5..42eff97e 100644 --- a/userspace/libraries/LibC/malloc.cpp +++ b/userspace/libraries/LibC/malloc.cpp @@ -96,8 +96,6 @@ struct BitmapAllocator // NOTE: We could optimize other bitmap functions than this // but this one is the bottle neck so it doesn't matter - static_assert(sizeof(unsigned long long) == sizeof(uint64_t)); - if (index >= total_chunks) return index; @@ -105,7 +103,7 @@ struct BitmapAllocator { const uint64_t qword = *reinterpret_cast(base + (index - rem) / 8) >> rem; if (qword != UINT64_MAX >> rem) - return index + __builtin_ctzll(~qword); + return index + BAN::Math::ctz(~qword); index += 64 - rem; } @@ -113,7 +111,7 @@ struct BitmapAllocator { const uint64_t qword = *reinterpret_cast(base + index / 8); if (qword != UINT64_MAX) - return index + __builtin_ctzll(~qword); + return index + BAN::Math::ctz(~qword); index += 64; } diff --git a/userspace/libraries/LibQR/QRCode.cpp b/userspace/libraries/LibQR/QRCode.cpp index 15df284b..2bb7fbb7 100644 --- a/userspace/libraries/LibQR/QRCode.cpp +++ b/userspace/libraries/LibQR/QRCode.cpp @@ -771,9 +771,9 @@ namespace LibQR const auto mod2_remainder = [](uint32_t data, uint32_t generator, uint32_t degree) { - constexpr auto bits = [](uint32_t val) -> uint32_t { return 31 - __builtin_clz(val | 1); }; - while (bits(data) >= degree) - data ^= generator << (bits(data) - degree); + uint32_t bits; + while ((bits = BAN::Math::ilog2(data | 1)) >= degree) + data ^= generator << (bits - degree); return data; };