[m-rev.] for review: implement is_nan/1 and is_inf/1 for MSVC
Peter Wang
novalazy at gmail.com
Fri May 31 17:33:07 AEST 2013
On Fri, 31 May 2013 16:56:21 +1000 (EST), Julien Fischer <jfischer at opturion.com> wrote:
>
> For review by anyone.
>
> Branches: 13.05, master
>
> -------------------
>
> Implement is_nan/1 and is_inf/1 installations using MSVC.
>
> runtime/mercury_float.c:
> Provide MSVC specific definitions for MR_is_nan
> and MR_is_inf.
>
> Julien.
>
> diff --git a/NEWS b/NEWS
> index 1f50052..8ba2bd7 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -20,6 +20,8 @@ This is a bug-fix release.
> (Bug #257)
> * A bug that caused a compiler abort in the low-level C backend has been
> fixed.
> +* The functions float.is_nan/1 and float.is_inf/1 now work when using
> + Microsoft Visual C++ as the C compiler.
>
> Changes to the Mercury standard library:
>
Did the fallbacks not work before?
> diff --git a/runtime/mercury_float.c b/runtime/mercury_float.c
> index 798cc30..49d319e 100644
> --- a/runtime/mercury_float.c
> +++ b/runtime/mercury_float.c
> @@ -111,6 +111,8 @@ MR_is_nan(MR_Float Flt)
> return isnanf(Flt);
> #elif defined(MR_HAVE_ISNAN)
> return isnan(Flt);
> +#elif defined(MR_MSVC)
> + return _isnan(Flt);
> #else
> return (Flt != Flt);
> #endif
> @@ -130,6 +132,10 @@ MR_is_inf(MR_Float Flt)
> return isinf(Flt);
> #elif defined(MR_HAVE_FINITE)
> return !finite(Flt) && (Flt == Flt);
> +#elif defined(MR_MSVC)
> + int sw;
> + sw = _fpclassify(Flt);
> + return (sw == _FPCLASS_NINF) || (sw == _FPCLASS_INF);
What does sw stand for?
Looks fine otherwise.
Peter
More information about the reviews
mailing list