From 3a1d72406e098391268b4fb18d9bac48e766c8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 3 May 2026 19:36:35 +0200 Subject: [PATCH] Fix build on sparc64 and ppc Dynamic endian checking can't be used in RZ_SYS_ENDIAN because its value is used in the preprocessor. When __BYTE_ORDER__ is not available, as is the case on OpenBSD/sparc64, we fall back to big endian. --- librz/include/rz_types.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/librz/include/rz_types.h b/librz/include/rz_types.h index 1d65924b5d..eca6478b4d 100644 --- a/librz/include/rz_types.h +++ b/librz/include/rz_types.h @@ -203,8 +203,6 @@ extern "C" { #endif #endif -static const ut32 rz_endianness_one = 1; - #define RZ_SYS_ENDIAN_NONE 0 #define RZ_SYS_ENDIAN_LITTLE 1 #define RZ_SYS_ENDIAN_BIG 2 @@ -230,7 +228,6 @@ static const ut32 rz_endianness_one = 1; #else #define RZ_SYS_BITS RZ_SYS_BITS_32 #endif - #if defined(__BYTE_ORDER__) #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE @@ -240,7 +237,7 @@ static const ut32 rz_endianness_one = 1; #error "Unsupported endianness" #endif #else - #define RZ_SYS_ENDIAN ((*((char *)&(rz_endianness_one)) == 1) ? RZ_SYS_ENDIAN_LITTLE : RZ_SYS_ENDIAN_BIG) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG #endif #elif __arm__ #define RZ_SYS_ARCH "arm" @@ -260,7 +257,11 @@ static const ut32 rz_endianness_one = 1; #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG #elif __sparc__ #define RZ_SYS_ARCH "sparc" - #define RZ_SYS_BITS RZ_SYS_BITS_32 + #ifdef __sparc64__ + #define RZ_SYS_BITS (RZ_SYS_BITS_32 | RZ_SYS_BITS_64) + #else + #define RZ_SYS_BITS RZ_SYS_BITS_32 + #endif #if defined(__BYTE_ORDER__) #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_LITTLE @@ -270,7 +271,7 @@ static const ut32 rz_endianness_one = 1; #error "Unsupported endianness" #endif #else - #define RZ_SYS_ENDIAN ((*((char *)&(rz_endianness_one)) == 1) ? RZ_SYS_ENDIAN_LITTLE : RZ_SYS_ENDIAN_BIG) + #define RZ_SYS_ENDIAN RZ_SYS_ENDIAN_BIG #endif #elif __mips__ #define RZ_SYS_ARCH "mips"