summaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-01-04 12:29:36 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-01-04 12:29:36 (GMT)
commit04b272336d8f4842d752449427ebef608dfcaca3 (patch)
tree52a5448d9c9435d6c1edfba8c0235153a76c18f5 /configure.in
parentd81780b8b0de6f0a191335da1ca1a040626bf97e (diff)
downloadcpython-04b272336d8f4842d752449427ebef608dfcaca3.zip
cpython-04b272336d8f4842d752449427ebef608dfcaca3.tar.gz
cpython-04b272336d8f4842d752449427ebef608dfcaca3.tar.bz2
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.in')
-rw-r--r--configure.in38
1 files changed, 38 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 7136d78..ea8727c 100644
--- a/configure.in
+++ b/configure.in
@@ -3143,6 +3143,44 @@ 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.
+AC_MSG_CHECKING(for x87-style double rounding)
+AC_CACHE_VAL(ac_cv_x87_double_rounding, [
+AC_TRY_RUN([
+#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);
+}
+],
+ac_cv_x87_double_rounding=no,
+ac_cv_x87_double_rounding=yes,
+ac_cv_x87_double_rounding=no)])
+AC_MSG_RESULT($ac_cv_x87_double_rounding)
+if test "$ac_cv_x87_double_rounding" = yes
+then
+ AC_DEFINE(X87_DOUBLE_ROUNDING, 1,
+ [Define if arithmetic is subject to x87-style double rounding issue])
+fi
+
+
# On FreeBSD 6.2, it appears that tanh(-0.) returns 0. instead of
# -0. on some architectures.
AC_MSG_CHECKING(whether tanh preserves the sign of zero)