From ecc1c871e652f0d21d58466fc60ed4b87dacdbeb Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 14 Mar 2022 10:10:40 +0300 Subject: [PATCH] SDL_endian.h: use endian predefs from newer gcc and clang versions. Closes: https://github.com/libsdl-org/SDL/pull/5403 --- include/SDL_endian.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/SDL_endian.h b/include/SDL_endian.h index 46c296253..2866f4bea 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -65,6 +65,15 @@ _m_prefetch(void *__P) #elif defined(__FreeBSD__) || defined(__NetBSD__) #include #define SDL_BYTEORDER BYTE_ORDER +/* predefs from newer gcc and clang versions: */ +#elif defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) && defined(__BYTE_ORDER__) +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#error Unsupported endianness +#endif /**/ #else #if defined(__hppa__) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \