diff options
| author | Heiko Carstens <hca@linux.ibm.com> | 2025-09-22 13:40:19 +0200 |
|---|---|---|
| committer | Alexander Gordeev <agordeev@linux.ibm.com> | 2025-09-24 16:24:17 +0200 |
| commit | 7b80a23c0e33ae5a3ae68e0cf5b5a59e8a368c37 (patch) | |
| tree | 1c350ab7b3c27e5e03bb52aded5066e2871c7c8d | |
| parent | 5671ce2a1fc6b4a16cff962423bc416b92cac3c8 (diff) | |
s390/bitops: Switch to generic fls(), fls64(), etc.
Switch to generic fls(), fls64(), etc. which are implemented with
__builtin_ctzl(), __builtin_clzl().
Those builtins are available for all supported compilers.
Kernel image size is reduced by ~10kb (gcc 15.1.0 + defconfig).
Acked-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
| -rw-r--r-- | arch/s390/include/asm/bitops.h | 56 |
1 files changed, 5 insertions, 51 deletions
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h index e643f24ebc05..8b9060c26c52 100644 --- a/arch/s390/include/asm/bitops.h +++ b/arch/s390/include/asm/bitops.h @@ -181,17 +181,6 @@ static __always_inline __attribute_const__ unsigned long __flogr(unsigned long w } /** - * __ffs - find first bit in word. - * @word: The word to search - * - * Undefined if no bit exists, so code should check against 0 first. - */ -static __always_inline __flatten unsigned long __ffs(unsigned long word) -{ - return __flogr(-word & word) ^ (BITS_PER_LONG - 1); -} - -/** * ffs - find first bit set * @word: the word to search * @@ -205,48 +194,13 @@ static __always_inline __flatten int ffs(int word) return BITS_PER_LONG - __flogr(-val & val); } -/** - * __fls - find last (most-significant) set bit in a long word - * @word: the word to search - * - * Undefined if no set bit exists, so code should check against 0 first. - */ -static __always_inline __flatten unsigned long __fls(unsigned long word) -{ - return __flogr(word) ^ (BITS_PER_LONG - 1); -} - -/** - * fls64 - find last set bit in a 64-bit word - * @word: the word to search - * - * This is defined in a similar way as the libc and compiler builtin - * ffsll, but returns the position of the most significant set bit. - * - * fls64(value) returns 0 if value is 0 or the position of the last - * set bit if value is nonzero. The last (most significant) bit is - * at position 64. - */ -static __always_inline __flatten int fls64(unsigned long word) -{ - return BITS_PER_LONG - __flogr(word); -} - -/** - * fls - find last (most-significant) bit set - * @word: the word to search - * - * This is defined the same way as ffs. - * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. - */ -static __always_inline __flatten int fls(unsigned int word) -{ - return fls64(word); -} - +#include <asm-generic/bitops/builtin-__ffs.h> +#include <asm-generic/bitops/ffz.h> +#include <asm-generic/bitops/builtin-__fls.h> +#include <asm-generic/bitops/builtin-fls.h> +#include <asm-generic/bitops/fls64.h> #include <asm/arch_hweight.h> #include <asm-generic/bitops/const_hweight.h> -#include <asm-generic/bitops/ffz.h> #include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/le.h> #include <asm-generic/bitops/ext2-atomic-setbit.h> |
