AK: Don't use GCC's __builtin_ffs on riscv64 without Zbb extension

GCC redirects `__builtin_ffs` to `ffs` on RISC-V without the Zbb
extension, causing a linker error.
This commit is contained in:
Sönke Holz 2023-08-20 19:46:39 +02:00 committed by Jelle Raaijmakers
parent d572ad38ac
commit e300da4db4
Notes: sideshowbarker 2024-07-16 23:54:15 +09:00

View file

@ -134,7 +134,7 @@ inline constexpr int count_leading_zeroes_safe(IntType value)
template<Integral IntType>
inline constexpr int bit_scan_forward(IntType value)
{
#if defined(AK_COMPILER_CLANG) || defined(AK_COMPILER_GCC)
#if defined(AK_COMPILER_CLANG) || (defined(AK_COMPILER_GCC) && (!ARCH(RISCV64) || defined(__riscv_zbb)))
static_assert(sizeof(IntType) <= sizeof(unsigned long long));
if constexpr (sizeof(IntType) <= sizeof(unsigned int))
return __builtin_ffs(value);