Browse code

Provide a fallback version of the libm function trunc

This fixes compilation on DOS.

Signed-off-by: Martin Storsjö <martin@martin.st>

Martin Storsjö authored on 2011/04/21 20:02:38
Showing 2 changed files
... ...
@@ -1119,6 +1119,7 @@ HAVE_LIST="
1119 1119
     sys_videoio_h
1120 1120
     ten_operands
1121 1121
     threads
1122
+    trunc
1122 1123
     truncf
1123 1124
     vfp_args
1124 1125
     VirtualAlloc
... ...
@@ -2852,6 +2853,7 @@ check_mathfunc lrint
2852 2852
 check_mathfunc lrintf
2853 2853
 check_mathfunc round
2854 2854
 check_mathfunc roundf
2855
+check_mathfunc trunc
2855 2856
 check_mathfunc truncf
2856 2857
 
2857 2858
 # these are off by default, so fail if requested and not available
... ...
@@ -86,6 +86,13 @@ static av_always_inline av_const float roundf(float x)
86 86
 }
87 87
 #endif /* HAVE_ROUNDF */
88 88
 
89
+#if !HAVE_TRUNC
90
+static av_always_inline av_const double trunc(double x)
91
+{
92
+    return (x > 0) ? floor(x) : ceil(x);
93
+}
94
+#endif /* HAVE_TRUNC */
95
+
89 96
 #if !HAVE_TRUNCF
90 97
 static av_always_inline av_const float truncf(float x)
91 98
 {