56 lines
2.2 KiB
Text
56 lines
2.2 KiB
Text
|
Use more generic and more accurate tests for LP64 and endianness.
|
||
|
|
||
|
Index: src/include/janet.h
|
||
|
--- src/include/janet.h.orig
|
||
|
+++ src/include/janet.h
|
||
|
@@ -103,44 +103,18 @@ extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/* Check 64-bit vs 32-bit */
|
||
|
-#if ((defined(__x86_64__) || defined(_M_X64)) \
|
||
|
- && (defined(JANET_POSIX) || defined(JANET_WINDOWS))) \
|
||
|
- || (defined(_WIN64)) /* Windows 64 bit */ \
|
||
|
- || (defined(__ia64__) && defined(__LP64__)) /* Itanium in LP64 mode */ \
|
||
|
- || defined(__alpha__) /* DEC Alpha */ \
|
||
|
- || (defined(__sparc__) && defined(__arch64__) || defined (__sparcv9)) /* BE */ \
|
||
|
- || defined(__s390x__) /* S390 64-bit (BE) */ \
|
||
|
- || (defined(__ppc64__) || defined(__PPC64__)) \
|
||
|
- || defined(__aarch64__) /* ARM 64-bit */ \
|
||
|
- || (defined(__riscv) && (__riscv_xlen == 64)) /* RISC-V 64-bit */
|
||
|
+#if defined(__LP64__) || defined(_LP64)
|
||
|
#define JANET_64 1
|
||
|
#else
|
||
|
#define JANET_32 1
|
||
|
#endif
|
||
|
|
||
|
-/* Check big endian */
|
||
|
-#if defined(__LITTLE_ENDIAN__) || \
|
||
|
- (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||
|
-/* If we know the target is LE, always use that - e.g. ppc64 little endian
|
||
|
- * defines the __LITTLE_ENDIAN__ macro in the ABI spec, so we can rely
|
||
|
- * on that and if that's not defined, fall back to big endian assumption
|
||
|
- */
|
||
|
+/* Check endianness */
|
||
|
+#include <endian.h>
|
||
|
+#if BYTE_ORDER == LITTLE_ENDIAN
|
||
|
#define JANET_LITTLE_ENDIAN 1
|
||
|
-#elif defined(__MIPSEB__) /* MIPS 32-bit */ \
|
||
|
- || defined(__ppc__) || defined(__PPC__) /* CPU(PPC) - PowerPC 32-bit */ \
|
||
|
- || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) \
|
||
|
- || defined(_M_PPC) || defined(__PPC) \
|
||
|
- || defined(__ppc64__) || defined(__PPC64__) /* PowerPC 64-bit */ \
|
||
|
- || defined(__sparc) /* Sparc 32bit */ \
|
||
|
- || defined(__sparc__) /* Sparc 64-bit */ \
|
||
|
- || defined(__s390x__) /* S390 64-bit */ \
|
||
|
- || defined(__s390__) /* S390 32-bit */ \
|
||
|
- || defined(__ARMEB__) /* ARM big endian */ \
|
||
|
- || ((defined(__CC_ARM) || defined(__ARMCC__)) /* ARM RealView compiler */ \
|
||
|
- && defined(__BIG_ENDIAN))
|
||
|
-#define JANET_BIG_ENDIAN 1
|
||
|
#else
|
||
|
-#define JANET_LITTLE_ENDIAN 1
|
||
|
+#define JANET_BIG_ENDIAN 1
|
||
|
#endif
|
||
|
|
||
|
/* Limits for converting doubles to 64 bit integers */
|