[m-rev.] for review: implement is_nan/1 and is_inf/1 for MSVC

Julien Fischer jfischer at opturion.com
Fri May 31 16:56:21 AEST 2013


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:

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);
  #else
      return (Flt == Flt / 2.0 && Flt != 0.0);
  #endif



More information about the reviews mailing list