From c32d8916559ac9754f232bab2e90c6d928516b63 Mon Sep 17 00:00:00 2001 From: Sven Geuer <68420948@users.noreply.github.com> Date: Wed, 3 Dec 2025 20:03:22 +0100 Subject: [PATCH] Regard endianness independent of a specific CPU type or OS Regard endianess based on __BYTE_ORDER__ instead of __SPARC or _AIX. This makes sure endianness is handled correctly, at least with using GCC, without the need to fake a CPU type like proposed in https://github.com/trendmicro/tlsh/issues/131. Picking endianness based on a specific OS seems not correct at all. --- include/tlsh_impl.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/include/tlsh_impl.h b/include/tlsh_impl.h index b43290a..9e505ab 100644 --- a/include/tlsh_impl.h +++ b/include/tlsh_impl.h @@ -139,14 +139,12 @@ class TlshImpl unsigned char checksum[TLSH_CHECKSUM_LEN]; // 1 to 3 bytes unsigned char Lvalue; // 1 byte union { -#if defined(__SPARC) || defined(_AIX) - #pragma pack(1) -#endif - unsigned char QB; + #pragma pack(1) + unsigned char QB; struct{ -#if defined(__SPARC) || defined(_AIX) - unsigned char Q2ratio : 4; - unsigned char Q1ratio : 4; +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + unsigned char Q2ratio : 4; + unsigned char Q1ratio : 4; #else unsigned char Q1ratio : 4; unsigned char Q2ratio : 4;