--- src/common/le_architecture.h.orig 2021-04-08 19:30:42.000000000 +0800 +++ src/common/le_architecture.h 2025-03-30 02:10:20.000000000 +0800 @@ -26,6 +26,8 @@ #if WINDOWS #include /* #define BYTE_ORDER */ +#elif defined(__APPLE__) +#include #endif /* This is copied directly from GNUnet headers */ @@ -62,7 +64,25 @@ * Endian operations */ -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if defined(__APPLE__) + +#define LE_htobe16(x) OSSwapHostToBigInt16(x) +#define LE_htole16(x) OSSwapHostToLittleInt16(x) +#define LE_be16toh(x) OSSwapBigToHostInt16(x) +#define LE_le16toh(x) OSSwapLittleToHostInt16(x) + +#define LE_htobe32(x) OSSwapHostToBigInt32(x) +#define LE_htole32(x) OSSwapHostToLittleInt32(x) +#define LE_be32toh(x) OSSwapBigToHostInt32(x) +#define LE_le32toh(x) OSSwapLittleToHostInt32(x) + +#define LE_htobe64(x) OSSwapHostToBigInt64(x) +#define LE_htole64(x) OSSwapHostToLittleInt64(x) +#define LE_be64toh(x) OSSwapBigToHostInt64(x) +#define LE_le64toh(x) OSSwapLittleToHostInt64(x) + +#elif __BYTE_ORDER == __LITTLE_ENDIAN + #define LE_htobe16(x) __bswap_16 (x) #define LE_htole16(x) (x) #define LE_be16toh(x) __bswap_16 (x) @@ -77,8 +97,9 @@ #define LE_htole64(x) (x) #define LE_be64toh(x) __bswap_64 (x) #define LE_le64toh(x) (x) -#endif -#if __BYTE_ORDER == __BIG_ENDIAN + +#elif __BYTE_ORDER == __BIG_ENDIAN + #define LE_htobe16(x) (x) #define LE_htole16(x) __bswap_16 (x) #define LE_be16toh(x) (x) @@ -93,8 +114,10 @@ #define LE_htole64(x) __bswap_64 (x) #define LE_be64toh(x) (x) #define LE_le64toh(x) __bswap_64 (x) -#endif +#else +#error "Endianness undefined!" +#endif /** * gcc-ism to get packed structs.