[PATCH 2/2] riscv: byteorder: add test for big-endian
Ben Dooks
ben.dooks at codethink.co.uk
Tue Jun 10 17:41:33 CEST 2025
On 10/06/2025 16:33, Tom Rini wrote:
> On Tue, Jun 10, 2025 at 04:18:50PM +0100, Ben Dooks wrote:
>
>> Test for big-endian either via __RISCVEB__ which migth be
>> rather old, or check the BYTE_ORDER if the compiler defines
>> it (which should be any modern gcc like v12)
>>
>> Signed-off-by: Ben Dooks <ben.dooks at codethink.co.uk>
>> ---
>> arch/riscv/include/asm/byteorder.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/include/asm/byteorder.h b/arch/riscv/include/asm/byteorder.h
>> index d26ac5688fa..3140c1f585e 100644
>> --- a/arch/riscv/include/asm/byteorder.h
>> +++ b/arch/riscv/include/asm/byteorder.h
>> @@ -26,7 +26,7 @@
>> # define __SWAB_64_THRU_32__
>> #endif
>>
>> -#ifdef __RISCVEB__
>> +#if defined(__RISCVEB__) || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
>> #include <linux/byteorder/big_endian.h>
>> #else
>> #include <linux/byteorder/little_endian.h>
>
> What's this look like in the linux kernel? We should likely just mirror
> that.
We're still looking at the kernel too.
I think we could just drop the __RISCVEB__ test, I don't think anything
is defining it.
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
https://www.codethink.co.uk/privacy.html
More information about the U-Boot
mailing list