RE: [PATCH] bitops: Change function return types from long to int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Thorsten Blum <thorsten.blum@xxxxxxxxxx>
> Sent: Sunday, April 21, 2024 6:39 AM
> To: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Wang, Xiao W <xiao.w.wang@xxxxxxxxx>; Palmer Dabbelt
> <palmer@xxxxxxxxxxxx>; Charlie Jenkins <charlie@xxxxxxxxxxxx>; Namhyung
> Kim <namhyung@xxxxxxxxxx>; Huacai Chen <chenhuacai@xxxxxxxxxx>; Youling
> Tang <tangyouling@xxxxxxxxxxx>; Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>;
> Jinyang He <hejinyang@xxxxxxxxxxx>; linux-arch@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx; Thorsten Blum <thorsten.blum@xxxxxxxxxx>
> Subject: [PATCH] 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.

Could we change the return types to "int", instead of "unsigned int"?
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html says that these __builtin_*
functions return "int".

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

I guess your test is based on 64bit arch, right?

BRs,
Xiao






[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux