summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-01-04 12:29:36 +0000
committerMark Dickinson <dickinsm@gmail.com>2009-01-04 12:29:36 +0000
commita698de2638d581addc574be189d663c59df8ffb9 (patch)
tree23078d4419a31ee344552ae6c6dd81eb41df77ff /configure
parent63ed0d51bbc6f2303fb4e7e12d2a8b86edcfc875 (diff)
downloadcpython-a698de2638d581addc574be189d663c59df8ffb9.tar.gz
Add autoconf test to detect x87-style double rounding, as described in
issue #2937. This information can be helpful for diagnosing platform- specific problems in math and cmath. The result of the test also serves as a fairly reliable indicator of whether the x87 floating-point instructions (as opposed to SSE2) are in use on Intel x86/x86_64 systems.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure92
1 files changed, 90 insertions, 2 deletions
diff --git a/configure b/configure
index 7425216c4c..70bad0a2b1 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 67463 .
+# From configure.in Revision: 68292 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 2.7.
#
@@ -2256,7 +2256,7 @@ echo $ECHO_N "checking for --without-gcc... $ECHO_C" >&6; }
if test "${with_gcc+set}" = set; then
withval=$with_gcc;
case $withval in
- no) CC=cc
+ no) CC=${CC:-cc}
without_gcc=yes;;
yes) CC=gcc
without_gcc=no;;
@@ -21523,6 +21523,94 @@ fi
LIBS_SAVE=$LIBS
LIBS="$LIBS $LIBM"
+# Detect whether system arithmetic is subject to x87-style double
+# rounding issues. The result of this test has little meaning on non
+# IEEE 754 platforms. On IEEE 754, test should return 1 if rounding
+# mode is round-to-nearest and double rounding issues are present, and
+# 0 otherwise. See http://bugs.python.org/issue2937 for more info.
+{ echo "$as_me:$LINENO: checking for x87-style double rounding" >&5
+echo $ECHO_N "checking for x87-style double rounding... $ECHO_C" >&6; }
+if test "${ac_cv_x87_double_rounding+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+if test "$cross_compiling" = yes; then
+ ac_cv_x87_double_rounding=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 <stdlib.h>
+#include <math.h>
+int main() {
+ volatile double x, y, z;
+ /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */
+ x = 0.99999999999999989; /* 1-2**-53 */
+ y = 1./x;
+ if (y != 1.)
+ exit(0);
+ /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */
+ x = 1e16;
+ y = 2.99999;
+ z = x + y;
+ if (z != 1e16+4.)
+ exit(0);
+ /* both tests show evidence of double rounding */
+ exit(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_x87_double_rounding=no
+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_x87_double_rounding=yes
+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_x87_double_rounding" >&5
+echo "${ECHO_T}$ac_cv_x87_double_rounding" >&6; }
+if test "$ac_cv_x87_double_rounding" = yes
+then
+
+cat >>confdefs.h <<\_ACEOF
+#define X87_DOUBLE_ROUNDING 1
+_ACEOF
+
+fi
+
+
# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
# -0. on some architectures.
{ echo "$as_me:$LINENO: checking whether tanh preserves the sign of zero" >&5