HomeFreeBSD

lib/libc/string: replace ffs/fls implementations with clang builtins

Description

lib/libc/string: replace ffs/fls implementations with clang builtins

Most architectures we support (except for riscv64) have instructions
to compute these functions very quickly. Replace old code with the
ftz and clz builtin functions, allowing clang to generate good code
for all architectures.

We cannot use the ffs builtins as gcc uses ffs() to implement these on
some platforms, potentially causing an infinite loop.

As a consequence, toss out arm and i386 ffs() implementations.

Sponsored by: The FreeBSD Foundation
Reported by: jlduran@gmail.com, jhb
Approved by: mhorne, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40730
Differential Revision: https://reviews.freebsd.org/D40966

(cherry picked from commit ee8b0c436d7221c25e8be3c3fe1f9da78b9d5b16)
(cherry picked from commit 3f5788e0ed8e85567f651ad360596b8c330af5a9)