forked from Bananymous/banan-os
Userspace: Use BAN::Math instead of builtins
This commit is contained in:
@@ -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<const uint64_t*>(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<const uint64_t*>(base + index / 8);
|
||||
if (qword != UINT64_MAX)
|
||||
return index + __builtin_ctzll(~qword);
|
||||
return index + BAN::Math::ctz(~qword);
|
||||
index += 64;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user