Patch is ok.  Please go ahead.

Thanks,
Kai

2016-08-22 15:40 GMT+02:00 Martin Storsjö <mar...@martin.st>:
> ---
> This is the same fix as in e9e42ce3113b which is already pushed;
> I didn't notice that this function has a separate copy of the
> implementation (contrary to e.g. rintl where the ARM block
> just calls rint).
> ---
>  mingw-w64-crt/math/llrintl.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/mingw-w64-crt/math/llrintl.c b/mingw-w64-crt/math/llrintl.c
> index 59ace2d..ac06ab2 100644
> --- a/mingw-w64-crt/math/llrintl.c
> +++ b/mingw-w64-crt/math/llrintl.c
> @@ -4,6 +4,7 @@
>   * No warranty is given; refer to the file DISCLAIMER.PD within this package.
>   */
>  #include <math.h>
> +#include <fenv.h>
>
>  long long llrintl (long double x)
>  {
> @@ -11,7 +12,15 @@ long long llrintl (long double x)
>  #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || 
> defined(__i386__)
>    __asm__ __volatile__ ("fistpll %0"  : "=m" (retval) : "t" (x) : "st");
>  #else
> -  retval = (long long)x;
> +  int mode = fegetround();
> +  if (mode == FE_DOWNWARD)
> +    retval = (long long)floor(x);
> +  else if (mode == FE_UPWARD)
> +    retval = (long long)ceil(x);
> +  else if (mode == FE_TOWARDZERO)
> +    retval = x >= 0 ? (long long)floor(x) : (long long)ceil(x);
> +  else
> +    retval = x >= 0 ? (long long)floor(x + 0.5) : (long long)ceil(x - 0.5);
>  #endif
>    return retval;
>  }
> --
> 2.7.4
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to