SDL_endian.h: use endian predefs from newer gcc and clang versions. Closes: https://github.com/libsdl-org/SDL/pull/5403
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) || \