Commit ecc1c871e652f0d21d58466fc60ed4b87dacdbeb

Ozkan Sezer 2022-03-14T10:10:40

SDL_endian.h: use endian predefs from newer gcc and clang versions. Closes: https://github.com/libsdl-org/SDL/pull/5403

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/include/SDL_endian.h b/include/SDL_endian.h
index 46c2962..2866f4b 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 <sys/endian.h>
 #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) || \