diff options
author | Thorsten Blum <thorsten.blum@toblux.com> | 2024-04-21 01:38:37 +0300 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2024-05-03 18:04:50 +0300 |
commit | 9c313ccdfc079f71f16c9b3d3a6c6d60996b9367 (patch) | |
tree | f02cf54d4387467cf9f7b844afb2d62f7754c3dc /include/linux/bitops.h | |
parent | e67572cd2204894179d89bd7b984072f19313b03 (diff) | |
download | linux-9c313ccdfc079f71f16c9b3d3a6c6d60996b9367.tar.xz |
bitops: Change function return types from long to int
Change the return types of bitops functions (ffs, fls, and fns) from
long to int. The expected return values are in the range [0, 64], for
which int is sufficient.
Additionally, int aligns well with the return types of the corresponding
__builtin_* functions, potentially reducing overall type conversions.
Many of the existing bitops functions already return an int and don't
need to be changed. The bitops functions in arch/ should be considered
separately.
Adjust some return variables to match the function return types.
With GCC 13 and defconfig, these changes reduced the size of a test
kernel image by 5,432 bytes on arm64 and by 248 bytes on riscv; there
were no changes in size on x86_64, powerpc, or m68k.
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/linux/bitops.h')
-rw-r--r-- | include/linux/bitops.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 2ba557e067fe..f60220f119e2 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -200,7 +200,7 @@ static __always_inline __s64 sign_extend64(__u64 value, int index) return (__s64)(value << shift) >> shift; } -static inline unsigned fls_long(unsigned long l) +static inline unsigned int fls_long(unsigned long l) { if (sizeof(l) == 4) return fls(l); @@ -236,7 +236,7 @@ static inline int get_count_order_long(unsigned long l) * The result is not defined if no bits are set, so check that @word * is non-zero before calling this. */ -static inline unsigned long __ffs64(u64 word) +static inline unsigned int __ffs64(u64 word) { #if BITS_PER_LONG == 32 if (((u32)word) == 0UL) @@ -252,7 +252,7 @@ static inline unsigned long __ffs64(u64 word) * @word: The word to search * @n: Bit to find */ -static inline unsigned long fns(unsigned long word, unsigned int n) +static inline unsigned int fns(unsigned long word, unsigned int n) { unsigned int bit; |