configure: Check for the math function rint
authorRonald S. Bultje <rsbultje@gmail.com>
Tue, 26 Jun 2012 12:05:28 +0000 (15:05 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 11 Jul 2012 07:40:11 +0000 (10:40 +0300)
Add a fallback implementation if it doesn't exist.

Signed-off-by: Martin Storsjö <martin@martin.st>
configure
libavutil/libm.h

index ffb1e7e..2888c72 100755 (executable)
--- a/configure
+++ b/configure
@@ -1124,6 +1124,7 @@ HAVE_LIST="
     poll_h
     posix_memalign
     rdtsc
     poll_h
     posix_memalign
     rdtsc
+    rint
     round
     roundf
     rweflags
     round
     roundf
     rweflags
@@ -2954,6 +2955,7 @@ check_mathfunc log2
 check_mathfunc log2f
 check_mathfunc lrint
 check_mathfunc lrintf
 check_mathfunc log2f
 check_mathfunc lrint
 check_mathfunc lrintf
+check_mathfunc rint
 check_mathfunc round
 check_mathfunc roundf
 check_mathfunc trunc
 check_mathfunc round
 check_mathfunc roundf
 check_mathfunc trunc
index b5821e8..8305b7c 100644 (file)
@@ -86,6 +86,13 @@ static av_always_inline av_const int isnan(float x)
 #define log2f(x) ((float)log2(x))
 #endif /* HAVE_LOG2F */
 
 #define log2f(x) ((float)log2(x))
 #endif /* HAVE_LOG2F */
 
+#if !HAVE_RINT
+static inline double rint(double x)
+{
+    return x >= 0 ? floor(x + 0.5) : ceil(x - 0.5);
+}
+#endif /* HAVE_RINT */
+
 #if !HAVE_LRINT
 static av_always_inline av_const long int lrint(double x)
 {
 #if !HAVE_LRINT
 static av_always_inline av_const long int lrint(double x)
 {