[m-rev.] for review: Work around isinf() link error on Solaris.

Peter Wang novalazy at gmail.com
Wed May 29 16:01:24 AEST 2013


On Solaris, isinf() is detected by configure but we pass -fno-builtin
for global registers on x86/x86-64, and that causes an undefined
reference to `isinf' when linking.

runtime/mercury_float.c:
	Don't use `isinf' or `isinff' on when __sun is defined.

	Add a better `isinf' fallback using finite().

diff --git a/runtime/mercury_float.c b/runtime/mercury_float.c
index 2a31a2e..8088ae9 100644
--- a/runtime/mercury_float.c
+++ b/runtime/mercury_float.c
@@ -119,11 +119,16 @@ MR_is_nan(MR_Float Flt)
 MR_bool
 MR_is_inf(MR_Float Flt)
 {
-#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF)
+    /*
+    ** On Solaris, isinf() is detected by configure but we pass -fno-builtin
+    ** for global registers on x86/x86-64, and that causes an undefined
+    ** reference to `isinf' when linking.
+    */
+#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF) && !defined(__sun)
     return isinff(Flt);
-#elif defined(MR_HAVE_ISINF)
+#elif defined(MR_HAVE_ISINF) && !defined(__sun)
     return isinf(Flt);
 #else
-    return (Flt == Flt / 2.0 && Flt != 0.0);
+    return !finite(Flt) && (Flt == Flt);
 #endif
 }




More information about the reviews mailing list