Re: [PATCH v2 1/2] include/uapi/linux/swab.h: move default implementation for swab macros into asm-generic

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

 



On Wed, Mar 19, 2025, at 22:37, Ignacio Encinas Rubio wrote:
> On 19/3/25 22:12, Arnd Bergmann wrote:
>> On Wed, Mar 19, 2025, at 22:09, Ignacio Encinas wrote:
>>> Move the default byteswap implementation into asm-generic so that it can
>>> be included from arch code.
>>>
>>> This is required by RISC-V in order to have a fallback implementation
>>> without duplicating it.
>>>
>>> Signed-off-by: Ignacio Encinas <ignacio@xxxxxxxxxxxx>
>>> ---
>>>  include/uapi/asm-generic/swab.h | 32 ++++++++++++++++++++++++++++++++
>>>  include/uapi/linux/swab.h       | 33 +--------------------------------
>>>  2 files changed, 33 insertions(+), 32 deletions(-)
>>>
>> 
>> I think we should just remove these entirely in favor of the
>> compiler-povided built-ins.
>
> Got it. I assumed they existed to explicitly avoid relying on
> __builtin_bswap as they might not exist. However, I did a quick grep and
> found that there are some uses in the wild.

Right, I do remember when we had a discussion about this maybe
15 years ago when gcc didn't have the builtins on all architectures
yet, but those versions are long gone, and we never cleaned it up.

> I couldn't find compiler builtins for ___constant_swahb32 nor 
> ___constant_swahw32, so I guess I'll leave them as they are.

Correct. There are also 24-bit and 48-bit swap functions
in include/linux/unaligned.h that have no corresponding builtins.

      Arnd




[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