From 9ffa1d1f29fc1ac92f28e809aa5bf97897338d1d Mon Sep 17 00:00:00 2001 From: barracuda156 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 header file. */ -#define HAVE_ENDIAN_H 1 +/* #define HAVE_ENDIAN_H 1 */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MACHINE_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +/* #define HAVE_SYS_ENDIAN_H 1 */ /* Define to 1 if you have the 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__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) || \ + (defined(BYTE_ORDER) && (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 +#elif defined (HAVE_MACHINE_ENDIAN_H) +# include +#elif defined (HAVE_SYS_ENDIAN_H) +# include #endif #if defined (HAVE_ERRNO_H)