summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2018-09-19 07:25:48 +0100
committerBenjamin Peterson <benjamin@python.org>2018-09-18 23:25:48 -0700
commit2a9c3805ddedf282881ef7811a561c70b74f80b1 (patch)
treef50deac3aa512a6932c1c459a0d77b3d6a101580 /configure.ac
parent471503954a91d86cf04228c38134108c67a263b0 (diff)
downloadcpython-git-2a9c3805ddedf282881ef7811a561c70b74f80b1.tar.gz
closes bpo-34585: Don't do runtime test to get float byte order. (GH-9085)
Currently configure.ac uses AC_RUN_IFELSE to determine the byte order of doubles, but this silently fails under cross compilation and Python doesn't do floats properly. Instead, steal a macro from autoconf-archive which compiles code using magic doubles (which encode to ASCII) and grep for the representation in the binary. RFC because this doesn't yet handle the weird ancient ARMv4 OABI 'mixed-endian' encoding properly. This encoding is ancient and I don't believe the union of "Python 3.8 users" and "OABI users" has anything in. Should the support for this just be dropped too? Alternatively, someone will need to find an OABI toolchain to verify the encoding of the magic double.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac76
1 files changed, 13 insertions, 63 deletions
diff --git a/configure.ac b/configure.ac
index 03638f8ae9..96331ec221 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4206,74 +4206,24 @@ fi
# * Check for various properties of floating point *
# **************************************************
-AC_MSG_CHECKING(whether C doubles are little-endian IEEE 754 binary64)
-AC_CACHE_VAL(ac_cv_little_endian_double, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
- return 0;
- else
- return 1;
-}
-]])],
-[ac_cv_little_endian_double=yes],
-[ac_cv_little_endian_double=no],
-[ac_cv_little_endian_double=no])])
-AC_MSG_RESULT($ac_cv_little_endian_double)
-if test "$ac_cv_little_endian_double" = yes
-then
- AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
- [Define if C doubles are 64-bit IEEE 754 binary format, stored
- with the least significant byte first])
-fi
-
-AC_MSG_CHECKING(whether C doubles are big-endian IEEE 754 binary64)
-AC_CACHE_VAL(ac_cv_big_endian_double, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x43\x3f\xff\x01\x02\x03\x04\x05", 8) == 0)
- return 0;
- else
- return 1;
-}
-]])],
-[ac_cv_big_endian_double=yes],
-[ac_cv_big_endian_double=no],
-[ac_cv_big_endian_double=no])])
-AC_MSG_RESULT($ac_cv_big_endian_double)
-if test "$ac_cv_big_endian_double" = yes
+AX_C_FLOAT_WORDS_BIGENDIAN
+if test "$ax_cv_c_float_words_bigendian" = "yes"
then
AC_DEFINE(DOUBLE_IS_BIG_ENDIAN_IEEE754, 1,
[Define if C doubles are 64-bit IEEE 754 binary format, stored
with the most significant byte first])
-fi
-
-# Some ARM platforms use a mixed-endian representation for doubles.
-# While Python doesn't currently have full support for these platforms
-# (see e.g., issue 1762561), we can at least make sure that float <-> string
-# conversions work.
-AC_MSG_CHECKING(whether C doubles are ARM mixed-endian IEEE 754 binary64)
-AC_CACHE_VAL(ac_cv_mixed_endian_double, [
-AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#include <string.h>
-int main() {
- double x = 9006104071832581.0;
- if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
- return 0;
- else
- return 1;
-}
-]])],
-[ac_cv_mixed_endian_double=yes],
-[ac_cv_mixed_endian_double=no],
-[ac_cv_mixed_endian_double=no])])
-AC_MSG_RESULT($ac_cv_mixed_endian_double)
-if test "$ac_cv_mixed_endian_double" = yes
+elif test "$ax_cv_c_float_words_bigendian" = "no"
then
+ AC_DEFINE(DOUBLE_IS_LITTLE_ENDIAN_IEEE754, 1,
+ [Define if C doubles are 64-bit IEEE 754 binary format, stored
+ with the least significant byte first])
+else
+ # Some ARM platforms use a mixed-endian representation for doubles.
+ # While Python doesn't currently have full support for these platforms
+ # (see e.g., issue 1762561), we can at least make sure that float <-> string
+ # conversions work.
+ # FLOAT_WORDS_BIGENDIAN doesnt actually detect this case, but if it's not big
+ # or little, then it must be this?
AC_DEFINE(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754, 1,
[Define if C doubles are 64-bit IEEE 754 binary format, stored
in ARM mixed-endian order (byte order 45670123)])