From ae4b8d6a0e0dc502e3d8307474a2e5691b7434da Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Netto Date: Fri, 25 Aug 2023 13:30:58 -0300 Subject: 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 --- string/ffsll.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'string/ffsll.c') 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 #define ffsl __something_else #include - #undef ffsll +#include +#include /* 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 -- cgit v1.1