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

From: Thorsten Blum
Date: Mon Apr 22 2024 - 05:15:42 EST


On 22. Apr 2024, at 07:24, Wang, Xiao W <xiao.w.wang@xxxxxxxxx> wrote:
>
> 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".

We could, but changing the signedness breaks assertions in other modules and
drivers (e.g., where min() and max() are used) and has quite a few side effects.

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

Yes, except for m68k.