From patchwork Thu Apr 21 11:03:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Provide a fallback version of the libm function trunc X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 2479 Message-Id: <1303383836-92779-1-git-send-email-martin@martin.st> To: libav-devel@libav.org Date: Thu, 21 Apr 2011 14:03:56 +0300 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= List-Id: libav development This fixes compilation on DOS. --- configure | 2 ++ libavutil/libm.h | 7 +++++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 32c3544..dd44ba4 100755 --- a/configure +++ b/configure @@ -1119,6 +1119,7 @@ HAVE_LIST=" sys_videoio_h ten_operands threads + trunc truncf vfp_args VirtualAlloc @@ -2852,6 +2853,7 @@ check_mathfunc lrint check_mathfunc lrintf check_mathfunc round check_mathfunc roundf +check_mathfunc trunc check_mathfunc truncf # these are off by default, so fail if requested and not available diff --git a/libavutil/libm.h b/libavutil/libm.h index 704bcf9..783f3cd 100644 --- a/libavutil/libm.h +++ b/libavutil/libm.h @@ -86,6 +86,13 @@ static av_always_inline av_const float roundf(float x) } #endif /* HAVE_ROUNDF */ +#if !HAVE_TRUNC +static av_always_inline av_const double trunc(double x) +{ + return (x > 0) ? floor(x) : ceil(x); +} +#endif /* HAVE_TRUNC */ + #if !HAVE_TRUNCF static av_always_inline av_const float truncf(float x) {