1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

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>
This commit is contained in:
Adhemerval Zanella Netto
2023-08-25 13:30:58 -03:00
committed by Adhemerval Zanella
parent 26d01172f5
commit ae4b8d6a0e
28 changed files with 48 additions and 651 deletions

View File

@ -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