diff --git a/lib/libc/string/ffs.c b/lib/libc/string/ffs.c --- a/lib/libc/string/ffs.c +++ b/lib/libc/string/ffs.c @@ -47,5 +47,9 @@ int ffs(int mask) { +#ifdef __clang__ return (__builtin_ffs(mask)); +#else /* gcc */ + return (mask == 0 ? 0 : __builtin_ctz(mask) + 1); +#endif } diff --git a/lib/libc/string/ffsl.c b/lib/libc/string/ffsl.c --- a/lib/libc/string/ffsl.c +++ b/lib/libc/string/ffsl.c @@ -44,5 +44,9 @@ int ffsl(long mask) { +#ifdef __clang__ return (__builtin_ffsl(mask)); +#else /* gcc */ + return (mask == 0 ? 0 : __builtin_ctzl(mask) + 1); +#endif } diff --git a/lib/libc/string/ffsll.c b/lib/libc/string/ffsll.c --- a/lib/libc/string/ffsll.c +++ b/lib/libc/string/ffsll.c @@ -44,5 +44,9 @@ int ffsll(long long mask) { +#ifdef __clang__ return (__builtin_ffsll(mask)); +#else /* gcc */ + return (mask == 0 ? 0 : __builtin_ctzll(mask) + 1); +#endif } diff --git a/tools/build/depend-cleanup.sh b/tools/build/depend-cleanup.sh --- a/tools/build/depend-cleanup.sh +++ b/tools/build/depend-cleanup.sh @@ -124,3 +124,11 @@ "$OBJTOP"/obj-lib32/secure/lib/libcrypto \ "$OBJTOP"/obj-lib32/secure/lib/libssl fi + +# 20230707 ee8b0c436d72 ffs/fls replaced +clean_dep lib/libc ffs S +clean_dep lib/libc ffsl S +clean_dep lib/libc ffsll S +clean_dep lib/libc fls S +clean_dep lib/libc flsl S +clean_dep lib/libc flsll S