]> granicus.if.org Git - python/commitdiff
Add check for C99 round function to configure, and define
authorMark Dickinson <dickinsm@gmail.com>
Sat, 18 Apr 2009 13:58:18 +0000 (13:58 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sat, 18 Apr 2009 13:58:18 +0000 (13:58 +0000)
a fallback function if round doesn't exist.

Include/pymath.h
Python/pymath.c
configure
configure.in
pyconfig.h.in

index 8872e8a9977faed53d9c6b31fc1521fc5071c427..816691abd9677693e6a4db95913c7ed5cba00078 100644 (file)
@@ -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
index 2e049be8704339a9a09e49be3bfd5c0e76960a17..eb06eb2244b1fb91e2a56046816b88c0411689cf 100644 (file)
@@ -69,6 +69,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>
 
index f4ee3109f422cd928cdefe0136a096fbbb45c99a..de5c3541fa0ac441b1993e970e25234e7ef63494 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 71274 .
+# From configure.in Revision: 71663 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 3.1.
 #
@@ -22310,7 +22310,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
index b3bd00fb2701e501c4e8843dd57525f54a93e262..7f7dc7f0c87e0bf2d39991f2f39360f9bb238199 100644 (file)
@@ -3337,7 +3337,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
index 72f5fb3959ee87113efbb4515d30c2536bf8c9ad..1807d8006421fa50afd432381f9da82bf5cc0785 100644 (file)
 /* 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