]> granicus.if.org Git - python/commitdiff
Backport r71704 (add configure check for C99 round function) to trunk.
authorMark Dickinson <dickinsm@gmail.com>
Sat, 18 Apr 2009 14:41:37 +0000 (14:41 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sat, 18 Apr 2009 14:41:37 +0000 (14:41 +0000)
Include/pymath.h
Python/pymath.c
configure
configure.in
pyconfig.h.in

index 6ad174d64555c4b3b0725986b839f0b063537766..2cb2a23cf73070df795f22ff6d38751476726399 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 2749688944b9750a9f939697bd985a2ab08795a4..643805856d9d71c0ad0158a17a73d6202fe133c4 100644 (file)
@@ -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>
 
index 17b932d9616770aadf0a71a76389ad031d664cd5..bf46b24f8b2cfb52e3bdb8a5f1be647c6fd407a8 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
index 5505dfb919fef532204d00c80c0239123e88c44c..1cb6cfe5899945f2cfb7eb661f3c77378ddb73ce 100644 (file)
@@ -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
index a7f1ab188575d2fdfab8b490962d203abe84c481..44525665eade478eae0468e3038dcaa0d02d3d09 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