diff --git a/Include/pymath.h b/Include/pymath.h index 7cea9ae22f4..13f95b4ff1d 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -87,7 +87,7 @@ extern double copysign(double, double); * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan */ #ifndef Py_IS_NAN -#ifdef HAVE_ISNAN +#ifdef HAVE_DECL_ISNAN #define Py_IS_NAN(X) isnan(X) #else #define Py_IS_NAN(X) ((X) != (X)) @@ -104,7 +104,7 @@ extern double copysign(double, double); * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf */ #ifndef Py_IS_INFINITY -#ifdef HAVE_ISINF +#ifdef HAVE_DECL_ISINF #define Py_IS_INFINITY(X) isinf(X) #else #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) diff --git a/PC/pyconfig.h b/PC/pyconfig.h index 53568a6bd47..06d22a344df 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -395,11 +395,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */ /* Define to 1 if you have the `copysign' function. */ #define HAVE_COPYSIGN 1 -/* Define to 1 if you have the `isinf' function. */ -#define HAVE_ISINF 1 +/* Define to 1 if you have the `isinf' macro. */ +#define HAVE_DECL_ISINF 1 /* Define to 1 if you have the `isnan' function. */ -#define HAVE_ISNAN 1 +#define HAVE_DECL_ISNAN 1 /* Define if on AIX 3. System headers sometimes define this. diff --git a/configure b/configure index 5937219898c..ffadc122113 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 67461 . +# From configure.in Revision: 68245 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.1. # @@ -21214,6 +21214,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 +#include +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 @@ -21400,9 +21488,7 @@ done - - -for ac_func in acosh asinh atanh copysign expm1 finite isinf isnan log1p +for ac_func in acosh asinh atanh copysign expm1 finite log1p do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -21495,6 +21581,209 @@ _ACEOF fi done +{ echo "$as_me:$LINENO: checking whether isinf is declared" >&5 +echo $ECHO_N "checking whether isinf is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_isinf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef isinf + (void) isinf; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +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_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_isinf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_isinf=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isinf" >&5 +echo "${ECHO_T}$ac_cv_have_decl_isinf" >&6; } +if test $ac_cv_have_decl_isinf = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISINF 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISINF 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether isnan is declared" >&5 +echo $ECHO_N "checking whether isnan is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_isnan+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef isnan + (void) isnan; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +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_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_isnan=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_isnan=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isnan" >&5 +echo "${ECHO_T}$ac_cv_have_decl_isnan" >&6; } +if test $ac_cv_have_decl_isnan = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISNAN 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISNAN 0 +_ACEOF + + +fi +{ echo "$as_me:$LINENO: checking whether isfinite is declared" >&5 +echo $ECHO_N "checking whether isfinite is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_isfinite+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef isfinite + (void) isfinite; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +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_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_have_decl_isfinite=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_isfinite=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isfinite" >&5 +echo "${ECHO_T}$ac_cv_have_decl_isfinite" >&6; } +if test $ac_cv_have_decl_isfinite = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISFINITE 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_ISFINITE 0 +_ACEOF + + +fi + + LIBS=$LIBS_SAVE diff --git a/configure.in b/configure.in index 394c8047b6b..d80e7a7412a 100644 --- a/configure.in +++ b/configure.in @@ -3056,6 +3056,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 +#include +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) @@ -3084,7 +3122,8 @@ fi AC_REPLACE_FUNCS(hypot) -AC_CHECK_FUNCS(acosh asinh atanh copysign expm1 finite isinf isnan log1p) +AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite log1p]) +AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include ]]) LIBS=$LIBS_SAVE diff --git a/pyconfig.h.in b/pyconfig.h.in index f37774c2f96..383c587dd37 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -58,6 +58,10 @@ /* Define to 1 if you have the header file. */ #undef HAVE_BLUETOOTH_H +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +#undef HAVE_BROKEN_MBSTOWCS + /* Define if nice() returns success/failure instead of the new priority. */ #undef HAVE_BROKEN_NICE @@ -112,6 +116,18 @@ /* Define if you have the 'resize_term' function. */ #undef HAVE_CURSES_RESIZE_TERM +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#undef HAVE_DECL_ISFINITE + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#undef HAVE_DECL_ISINF + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#undef HAVE_DECL_ISNAN + /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #undef HAVE_DECL_TZNAME @@ -312,12 +328,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_IO_H -/* Define to 1 if you have the `isinf' function. */ -#undef HAVE_ISINF - -/* Define to 1 if you have the `isnan' function. */ -#undef HAVE_ISNAN - /* Define to 1 if you have the `kill' function. */ #undef HAVE_KILL @@ -357,7 +367,7 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H -/* Define to 1 if you have the `readline' library (-lreadline). */ +/* Define if you have the readline library (-lreadline). */ #undef HAVE_LIBREADLINE /* Define to 1 if you have the `resolv' library (-lresolv). */ @@ -800,10 +810,6 @@ /* Define to 1 if you have the `wcsxfrm' function. */ #undef HAVE_WCSXFRM -/* Define if mbstowcs(NULL, "text", 0) does not return the number of - wide chars that would be converted */ -#undef HAVE_BROKEN_MBSTOWCS - /* Define if tzset() actually switches the local timezone in a meaningful way. */ #undef HAVE_WORKING_TZSET @@ -984,6 +990,9 @@ first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN +/* Define if arithmetic is subject to x87-style double rounding issue */ +#undef X87_DOUBLE_ROUNDING + /* Define to 1 if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */