1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

AK+Everywhere: Replace __builtin bit functions

In order to reduce our reliance on __builtin_{ffs, clz, ctz, popcount},
this commit removes all calls to these functions and replaces them with
the equivalent functions in AK/BuiltinWrappers.h.
This commit is contained in:
Nick Johnson 2021-12-19 15:46:55 -06:00 committed by Andreas Kling
parent 26bb3e1acf
commit 08e4a1a4dc
20 changed files with 108 additions and 115 deletions

View file

@ -106,29 +106,6 @@ extern "C" {
# endif
#endif
#ifdef __cplusplus
ALWAYS_INLINE int count_trailing_zeroes_32(unsigned int val)
{
# if defined(__GNUC__) || defined(__clang__)
return __builtin_ctz(val);
# else
for (u8 i = 0; i < 32; ++i) {
if ((val >> i) & 1) {
return i;
}
}
return 0;
# endif
}
ALWAYS_INLINE int count_trailing_zeroes_32_safe(unsigned int val)
{
if (val == 0)
return 32;
return count_trailing_zeroes_32(val);
}
#endif
#ifdef AK_OS_BSD_GENERIC
# define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
# define CLOCK_REALTIME_COARSE CLOCK_REALTIME