[Python-checkins] r71602 - in python/branches/py3k-short-float-repr: Python/dtoa.c configure configure.in pyconfig.h.in
mark.dickinson
python-checkins at python.org
Tue Apr 14 17:50:37 CEST 2009
Author: mark.dickinson
Date: Tue Apr 14 17:50:37 2009
New Revision: 71602
Log:
Add support for ARM mixed-endian doubles
Modified:
python/branches/py3k-short-float-repr/Python/dtoa.c
python/branches/py3k-short-float-repr/configure
python/branches/py3k-short-float-repr/configure.in
python/branches/py3k-short-float-repr/pyconfig.h.in
Modified: python/branches/py3k-short-float-repr/Python/dtoa.c
==============================================================================
--- python/branches/py3k-short-float-repr/Python/dtoa.c (original)
+++ python/branches/py3k-short-float-repr/Python/dtoa.c Tue Apr 14 17:50:37 2009
@@ -115,7 +115,8 @@
#ifdef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
#define IEEE_8087
#endif
-#ifdef DOUBLE_IS_BIG_ENDIAN_IEEE754
+
+#if defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) || defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)
#define IEEE_MC68k
#endif
#if defined(IEEE_8087) + defined(IEEE_MC68k) != 1
Modified: python/branches/py3k-short-float-repr/configure
==============================================================================
--- python/branches/py3k-short-float-repr/configure (original)
+++ python/branches/py3k-short-float-repr/configure Tue Apr 14 17:50:37 2009
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 71321 .
+# From configure.in Revision: 71576 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 3.1.
#
@@ -21751,6 +21751,82 @@
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.
+{ echo "$as_me:$LINENO: checking whether C doubles are ARM mixed-endian IEEE 754 binary64" >&5
+echo $ECHO_N "checking whether C doubles are ARM mixed-endian IEEE 754 binary64... $ECHO_C" >&6; }
+if test "${ac_cv_mixed_endian_double+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test "$cross_compiling" = yes; then
+ ac_cv_mixed_endian_double=no
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#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;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_mixed_endian_double=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_mixed_endian_double=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+
+fi
+
+{ echo "$as_me:$LINENO: result: $ac_cv_mixed_endian_double" >&5
+echo "${ECHO_T}$ac_cv_mixed_endian_double" >&6; }
+if test "$ac_cv_mixed_endian_double" = yes
+then
+
+cat >>confdefs.h <<\_ACEOF
+#define DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 1
+_ACEOF
+
+fi
+
# David Gay's code in Python/dtoa.c requires that the FPU uses 53-bit
# rounding; this is a particular problem on x86, where the x87 FPU has
# a default rounding precision of 64 bits. For gcc/x86, we try to fix
Modified: python/branches/py3k-short-float-repr/configure.in
==============================================================================
--- python/branches/py3k-short-float-repr/configure.in (original)
+++ python/branches/py3k-short-float-repr/configure.in Tue Apr 14 17:50:37 2009
@@ -3115,6 +3115,33 @@
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_TRY_RUN([
+#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
+then
+ 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)])
+fi
+
# David Gay's code in Python/dtoa.c requires that the FPU uses 53-bit
# rounding; this is a particular problem on x86, where the x87 FPU has
# a default rounding precision of 64 bits. For gcc/x86, we try to fix
Modified: python/branches/py3k-short-float-repr/pyconfig.h.in
==============================================================================
--- python/branches/py3k-short-float-repr/pyconfig.h.in (original)
+++ python/branches/py3k-short-float-repr/pyconfig.h.in Tue Apr 14 17:50:37 2009
@@ -15,6 +15,10 @@
/* Define if you have the Mach cthreads package */
#undef C_THREADS
+/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM
+ mixed-endian order (byte order 45670123) */
+#undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
+
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most
significant byte first */
#undef DOUBLE_IS_BIG_ENDIAN_IEEE754
More information about the Python-checkins
mailing list