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.
This commit is contained in:
Florian Märkl 2026-05-03 19:36:35 +02:00
parent bc22b44549
commit 3a1d72406e

View file

@ -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"