Skip to content

Commit

Permalink
Fix architecture detection for IBM Z and System/390. (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceLR authored Jan 8, 2024
1 parent 3047e61 commit 93eeddd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ elif [ "$PLATFORM" = "unix" ] || [ "$PLATFORM" = "unix-devel" ]; then
ARCHNAME=sparc64
elif [ "$MACH" = "riscv64" ]; then
ARCHNAME=riscv64
elif [ "$MACH" = "s390" ]; then
ARCHNAME=s390
elif [ "$MACH" = "s390x" ]; then
ARCHNAME=s390x
else
ARCHNAME=$MACH
#RAWLIBDIR=lib
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
GIT

+ Fixed config.sh and platform_endian.h detection for IBM Z and
System/390 architecture.


December 31st, 2023 - MZX 2.93

This is the first MegaZeux release in about 3 years, so there
Expand Down
17 changes: 14 additions & 3 deletions src/platform_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#define __ENDIAN_H

/* If SDL is available, include the header and use SDL's configured
* endianness. If it's not available, use a list of architectures (actually
* borrowed from SDL 1.2.13) to figure out our likely endianness.
* endianness. If it's not available, use GCC/clang or a list of architectures
* (both checks borrowed from SDL) to determine the endianness.
*/

#define PLATFORM_LIL_ENDIAN 0x1234
Expand All @@ -44,10 +44,20 @@
#define PLATFORM_BYTE_ORDER PLATFORM_BIG_ENDIAN
#elif defined(__LITTLE_ENDIAN__)
#define PLATFORM_BYTE_ORDER PLATFORM_LIL_ENDIAN
/* 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 PLATFORM_BYTE_ORDER PLATFORM_LIL_ENDIAN
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define PLATFORM_BYTE_ORDER PLATFORM_BIG_ENDIAN
#else
#error Unsupported endianness
#endif /**/
#elif defined(__hppa__) || \
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
((defined(__mips__) || defined(__mips) || defined(__MIPS__)) && defined(__MIPSEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
defined(__s390__) || defined(__s390x__) || defined(__zarch__) || defined(__SYSC_ZARCH__) || \
defined(__sparc__)
#define PLATFORM_BYTE_ORDER PLATFORM_BIG_ENDIAN
#else
Expand All @@ -74,7 +84,8 @@
defined(_MIPS_SIM) && defined(_ABI64) && _MIPS_SIM == _ABI64) || \
(defined(__GNUC__) && \
(defined(__x86_64__) || defined(__powerpc64__) || defined(__PPC64__) || \
defined(__aarch64__) || defined(__alpha__)))
defined(__aarch64__) || defined(__alpha__) || \
defined(__s390x__) || defined(__zarch__)))
#define ARCHITECTURE_BITS 64
#else
#define ARCHITECTURE_BITS 32
Expand Down

0 comments on commit 93eeddd

Please sign in to comment.