<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 9ffa1d1f29fc1ac92f28e809aa5bf97897338d1d Mon Sep 17 00:00:00 2001
From: barracuda156 &lt;vital.had@gmail.com&gt;
Date: Sat, 20 Jan 2024 16:48:45 +0800
Subject: [PATCH 6/6] Fix endianness includes and macros

---
 a68g-config.h               | 8 +++++++-
 configure.ac                | 2 +-
 src/a68g/rts-sounds.c       | 9 ++++-----
 src/include/a68g-includes.h | 4 ++++
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a68g-config.h a68g-config.h
index d3a0e0e..3c87975 100644
--- a68g-config.h
+++ a68g-config.h
@@ -66,7 +66,13 @@
 /* #undef HAVE_DLFCN_H */
 
 /* Define to 1 if you have the &lt;endian.h&gt; header file. */
-#define HAVE_ENDIAN_H 1
+/* #define HAVE_ENDIAN_H 1 */
+
+/* Define to 1 if you have the &lt;machine/endian.h&gt; header file. */
+#define HAVE_MACHINE_ENDIAN_H 1
+
+/* Define to 1 if you have the &lt;sys/endian.h&gt; header file. */
+/* #define HAVE_SYS_ENDIAN_H 1 */
 
 /* Define to 1 if you have the &lt;errno.h&gt; header file. */
 #define HAVE_ERRNO_H 1
diff --git configure.ac configure.ac
index e27241e..2e8c6f5 100644
--- configure.ac
+++ configure.ac
@@ -514,7 +514,7 @@ AC_HEADER_DIRENT
 AC_HEADER_SYS_WAIT
 AC_HEADER_TIOCGWINSZ
 
-AC_CHECK_HEADERS([assert.h complex.h ctype.h endian.h errno.h execinfo.h fcntl.h fenv.h float.h libgen.h limits.h regex.h setjmp.h signal.h stdarg.h stddef.h stdio.h stdlib.h sys/ioctl.h sys/resource.h sys/time.h termios.h time.h unistd.h])
+AC_CHECK_HEADERS([assert.h complex.h ctype.h endian.h machine/endian.h sys/endian.h errno.h execinfo.h fcntl.h fenv.h float.h libgen.h limits.h regex.h setjmp.h signal.h stdarg.h stddef.h stdio.h stdlib.h sys/ioctl.h sys/resource.h sys/time.h termios.h time.h unistd.h])
 
 #
 # Functions we expect.
diff --git src/a68g/rts-sounds.c src/a68g/rts-sounds.c
index 04157d1..9447d4d 100644
--- src/a68g/rts-sounds.c
+++ src/a68g/rts-sounds.c
@@ -31,14 +31,13 @@
 
 #define MAX_BYTES 4
 
-#if (__BYTE_ORDER == __LITTLE_ENDIAN)
-  #define A68_LITTLE_ENDIAN A68_TRUE
-  #define A68_BIG_ENDIAN A68_FALSE
-#elif (__BYTE_ORDER == __BIG_ENDIAN)
+#if (defined(__BYTE_ORDER__) &amp;&amp; (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || \
+  (defined(BYTE_ORDER) &amp;&amp; (BYTE_ORDER == BIG_ENDIAN))
   #define A68_LITTLE_ENDIAN A68_FALSE
   #define A68_BIG_ENDIAN A68_TRUE
 #else
-  #error "undefined endianness"
+  #define A68_LITTLE_ENDIAN A68_TRUE
+  #define A68_BIG_ENDIAN A68_FALSE
 #endif
 
 // From public Microsoft RIFF documentation.
diff --git src/include/a68g-includes.h src/include/a68g-includes.h
index 6134842..a680378 100644
--- src/include/a68g-includes.h
+++ src/include/a68g-includes.h
@@ -75,6 +75,10 @@
 
 #if defined (HAVE_ENDIAN_H)
 #  include &lt;endian.h&gt;
+#elif defined (HAVE_MACHINE_ENDIAN_H)
+#  include &lt;machine/endian.h&gt;
+#elif defined (HAVE_SYS_ENDIAN_H)
+#  include &lt;sys/endian.h&gt;
 #endif
 
 #if defined (HAVE_ERRNO_H)
</pre></body></html>