aboutsummaryrefslogtreecommitdiff
path: root/string/ffsll.c
diff options
context:
space:
mode:
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>2023-08-25 13:30:58 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-02-01 09:31:33 -0300
commitae4b8d6a0e0dc502e3d8307474a2e5691b7434da (patch)
tree8e8d958ebb90b9edec3847a53364edb32a2314a3 /string/ffsll.c
parent26d01172f5c3f3b912ecf21ebb911eb5351bba4d (diff)
downloadglibc-ae4b8d6a0e0dc502e3d8307474a2e5691b7434da.zip
glibc-ae4b8d6a0e0dc502e3d8307474a2e5691b7434da.tar.gz
glibc-ae4b8d6a0e0dc502e3d8307474a2e5691b7434da.tar.bz2
string: Use builtins for ffs and ffsll
It allows to remove a lot of arch-specific implementations. Checked on x86_64, aarch64, powerpc64. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'string/ffsll.c')
-rw-r--r--string/ffsll.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/string/ffsll.c b/string/ffsll.c
index 7d16250..0ec39a0 100644
--- a/string/ffsll.c
+++ b/string/ffsll.c
@@ -18,20 +18,26 @@
#include <limits.h>
#define ffsl __something_else
#include <string.h>
-
#undef ffsll
+#include <math-use-builtins.h>
+#include <libc-diag.h>
/* Find the first bit set in I. */
int
-ffsll (long long int i)
+__ffsll (long long int i)
{
+#if USE_FFSLL_BUILTIN
+ return __builtin_ffsll (i);
+#else
unsigned long long int x = i & -i;
if (x <= 0xffffffff)
return ffs (i);
else
return 32 + ffs (i >> 32);
+#endif
}
+weak_alias (__ffsll, ffsll)
#if ULONG_MAX != UINT_MAX
#undef ffsl