diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-04-18 14:41:37 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-04-18 14:41:37 (GMT) |
commit | 8e5446f902c58a48796c1f0e25a263b7268afe34 (patch) | |
tree | 1f117ab0286a1a2a6f24ff997ca64b67ac1ae194 | |
parent | 4beb89b9f7a40703136d0ddac7aecd71d59d17bc (diff) | |
download | cpython-8e5446f902c58a48796c1f0e25a263b7268afe34.zip cpython-8e5446f902c58a48796c1f0e25a263b7268afe34.tar.gz cpython-8e5446f902c58a48796c1f0e25a263b7268afe34.tar.bz2 |
Backport r71704 (add configure check for C99 round function) to trunk.
-rw-r--r-- | Include/pymath.h | 4 | ||||
-rw-r--r-- | Python/pymath.c | 13 | ||||
-rwxr-xr-x | configure | 5 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | pyconfig.h.in | 3 |
5 files changed, 24 insertions, 3 deletions
diff --git a/Include/pymath.h b/Include/pymath.h index 6ad174d..2cb2a23 100644 --- a/Include/pymath.h +++ b/Include/pymath.h @@ -22,6 +22,10 @@ functions and constants extern double copysign(double, double); #endif +#ifndef HAVE_ROUND +extern double round(double); +#endif + #ifndef HAVE_ACOSH extern double acosh(double); #endif diff --git a/Python/pymath.c b/Python/pymath.c index 2749688..6438058 100644 --- a/Python/pymath.c +++ b/Python/pymath.c @@ -47,6 +47,19 @@ copysign(double x, double y) } #endif /* HAVE_COPYSIGN */ +#ifndef HAVE_ROUND +double +round(double x) +{ + double absx, y; + absx = fabs(x); + y = floor(absx); + if (absx - y >= 0.5) + y += 1.0; + return copysign(y, x); +} +#endif /* HAVE_ROUND */ + #ifndef HAVE_LOG1P #include <float.h> @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 70903 . +# From configure.in Revision: 71009 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.7. # @@ -22169,7 +22169,8 @@ fi -for ac_func in acosh asinh atanh copysign expm1 finite hypot log1p + +for ac_func in acosh asinh atanh copysign expm1 finite hypot log1p round do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/configure.in b/configure.in index 5505dfb..1cb6cfe 100644 --- a/configure.in +++ b/configure.in @@ -3250,7 +3250,7 @@ then [Define if tanh(-0.) is -0., or if platform doesn't have signed zeros]) fi -AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p]) +AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite hypot log1p round]) AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]]) LIBS=$LIBS_SAVE diff --git a/pyconfig.h.in b/pyconfig.h.in index a7f1ab1..4452566 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -504,6 +504,9 @@ /* Define if you have readline 4.0 */ #undef HAVE_RL_PRE_INPUT_HOOK +/* Define to 1 if you have the `round' function. */ +#undef HAVE_ROUND + /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT |