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

-- 
Tom

Attachment: signature.asc
Description: PGP signature

Reply via email to