2017-10-23 21:52:00 +02:00
|
|
|
From d3920dce139734e00bbe4447a16ef24dfe4d704a Mon Sep 17 00:00:00 2001
|
2016-12-19 22:29:07 +01:00
|
|
|
From: Eric Le Bihan <eric.le.bihan.dev@free.fr>
|
2017-10-23 21:52:00 +02:00
|
|
|
Date: Tue, 10 Oct 2017 19:51:02 +0200
|
2016-12-19 22:29:07 +01:00
|
|
|
Subject: [PATCH] No runtime tests for endianness
|
|
|
|
|
|
|
|
Replace build and execution of runtime test programs for determining
|
|
|
|
the endianness of the target with compile time test programs.
|
|
|
|
|
|
|
|
This improves support for cross-compilation.
|
|
|
|
|
|
|
|
Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
|
|
|
|
---
|
2017-10-23 21:52:00 +02:00
|
|
|
configure | 13 ++++++++++---
|
2016-12-19 22:29:07 +01:00
|
|
|
src/sysdeps/trybigendian.c | 16 ++++++++++++++++
|
2017-03-20 21:11:22 +01:00
|
|
|
src/sysdeps/trylittleendian.c | 19 +++++++++++++++++++
|
2017-10-23 21:52:00 +02:00
|
|
|
3 files changed, 45 insertions(+), 3 deletions(-)
|
2016-12-19 22:29:07 +01:00
|
|
|
create mode 100644 src/sysdeps/trybigendian.c
|
|
|
|
create mode 100644 src/sysdeps/trylittleendian.c
|
|
|
|
|
|
|
|
diff --git a/configure b/configure
|
2017-10-23 21:52:00 +02:00
|
|
|
index f34dcd0..f2a77f3 100755
|
2016-12-19 22:29:07 +01:00
|
|
|
--- a/configure
|
|
|
|
+++ b/configure
|
2017-10-23 21:52:00 +02:00
|
|
|
@@ -478,12 +478,19 @@ EOF
|
2016-12-19 22:29:07 +01:00
|
|
|
exec 3>&-
|
|
|
|
|
2017-10-23 21:52:00 +02:00
|
|
|
echo "Checking system endianness..."
|
|
|
|
- $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o tryendianness src/sysdeps/tryendianness.c
|
2016-12-19 22:29:07 +01:00
|
|
|
- endianness=$(./tryendianness) || fail "$0: unable to determine endianness"
|
2017-10-23 21:52:00 +02:00
|
|
|
+ if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o trybigendian src/sysdeps/trybigendian.c 2>/dev/null; then
|
2016-12-19 22:29:07 +01:00
|
|
|
+ endianness=big
|
|
|
|
+ else
|
2017-10-23 21:52:00 +02:00
|
|
|
+ if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -o trylittleendian src/sysdeps/trylittleendian.c 2>/dev/null; then
|
2016-12-19 22:29:07 +01:00
|
|
|
+ endianness=little
|
|
|
|
+ else
|
|
|
|
+ fail "$0: unable to determine endianness"
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
echo "endianness: $endianness" >> $sysdeps/sysdeps
|
|
|
|
echo "#define ${package_macro_name}_ENDIANNESS \"$endianness\"" >> $sysdeps/sysdeps.h
|
|
|
|
echo " ... $endianness"
|
|
|
|
- rm -f tryendianness
|
|
|
|
+ rm -f trybigendian trylittleendian
|
|
|
|
|
2017-06-25 21:26:13 +02:00
|
|
|
trytypes
|
|
|
|
choose clr accept4 ACCEPT4 'accept4()'
|
2016-12-19 22:29:07 +01:00
|
|
|
diff --git a/src/sysdeps/trybigendian.c b/src/sysdeps/trybigendian.c
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..d857572
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/sysdeps/trybigendian.c
|
|
|
|
@@ -0,0 +1,16 @@
|
|
|
|
+#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN) || \
|
|
|
|
+ defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
|
|
|
|
+ defined(__BIG_ENDIAN) || \
|
|
|
|
+ defined(__ARMEB__) || \
|
|
|
|
+ defined(__THUMBEB__) || \
|
|
|
|
+ defined(__AARCH64EB__) || \
|
|
|
|
+ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
|
|
|
|
+#define YEAH
|
|
|
|
+#else
|
|
|
|
+#error "not big endian"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+int main(void)
|
|
|
|
+{
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
diff --git a/src/sysdeps/trylittleendian.c b/src/sysdeps/trylittleendian.c
|
|
|
|
new file mode 100644
|
2017-03-20 21:11:22 +01:00
|
|
|
index 0000000..68b93c1
|
2016-12-19 22:29:07 +01:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/sysdeps/trylittleendian.c
|
2017-03-20 21:11:22 +01:00
|
|
|
@@ -0,0 +1,19 @@
|
2016-12-19 22:29:07 +01:00
|
|
|
+#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \
|
|
|
|
+ defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \
|
|
|
|
+ defined(__LITTLE_ENDIAN) || \
|
|
|
|
+ defined(__ARMEL__) || \
|
|
|
|
+ defined(__THUMBEL__) || \
|
|
|
|
+ defined(__AARCH64EL__) || \
|
2017-03-20 21:11:22 +01:00
|
|
|
+ defined(__i386) || defined(__i386__) || \
|
|
|
|
+ defined(__amd64) || defined(__amd64__) || \
|
|
|
|
+ defined(__x86_64) || defined(__x86_64__) || \
|
2016-12-19 22:29:07 +01:00
|
|
|
+ defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
|
|
|
|
+#define YEAH
|
|
|
|
+#else
|
|
|
|
+#error "not little endian"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+int main(void)
|
|
|
|
+{
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
--
|
2017-10-23 21:52:00 +02:00
|
|
|
2.13.6
|
2016-12-19 22:29:07 +01:00
|
|
|
|