[m-rev.] diff: move is_nan/is_inf implementations into the runtime to avoid warnings
Peter Ross
pro at missioncriticalit.com
Sat Nov 30 00:51:52 AEDT 2002
Hi,
===================================================================
Estimated hours taken: 0.5
Branches: main
Move implementation of is_nan and is_inf into the runtime.
This avoids problems with warnings about implicit declarations of
functions isnan and isinf when compiling with --ansi.
library/float.m:
runtime/mercury_float.c:
runtime/mercury_float.h:
Move the bodies of is_nan and is_inf into the runtime.
Index: library/float.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/float.m,v
retrieving revision 1.49
diff -u -r1.49 float.m
--- library/float.m 25 Nov 2002 11:53:18 -0000 1.49
+++ library/float.m 29 Nov 2002 13:47:37 -0000
@@ -448,13 +448,7 @@
:- pragma promise_pure(is_nan/1).
:- pragma foreign_proc(c, is_nan(Flt::in),
[will_not_call_mercury, thread_safe], "
-#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISNANF)
- SUCCESS_INDICATOR = isnanf(Flt);
-#elif defined(MR_HAVE_ISNAN)
- SUCCESS_INDICATOR = isnan(Flt);
-#else
- SUCCESS_INDICATOR = (Flt != Flt);
-#endif
+ SUCCESS_INDICATOR = MR_is_nan(Flt);
").
:- pragma foreign_proc(il, is_nan(Flt::in),
[will_not_call_mercury, thread_safe, max_stack_size(1)], "
@@ -470,13 +464,7 @@
:- pragma promise_pure(is_inf/1).
:- pragma foreign_proc(c, is_inf(Flt::in),
[will_not_call_mercury, thread_safe], "
-#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF)
- SUCCESS_INDICATOR = isinff(Flt);
-#elif defined(MR_HAVE_ISINF)
- SUCCESS_INDICATOR = isinf(Flt);
-#else
- SUCCESS_INDICATOR = (Flt == Flt / 2.0 && Flt != 0.0);
-#endif
+ SUCCESS_INDICATOR = MR_is_inf(Flt);
").
:- pragma foreign_proc(il, is_inf(Flt::in),
[will_not_call_mercury, thread_safe, max_stack_size(1)], "
Index: runtime/mercury_float.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_float.c,v
retrieving revision 1.6
diff -u -r1.6 mercury_float.c
--- runtime/mercury_float.c 29 Nov 2002 13:26:00 -0000 1.6
+++ runtime/mercury_float.c 29 Nov 2002 13:47:37 -0000
@@ -5,6 +5,7 @@
*/
#include "mercury_imp.h"
+#include <math.h>
/*
** The function `MR_hash_float()' is used by the library predicate
@@ -83,4 +84,28 @@
} while (round != f);
return;
+}
+
+MR_bool
+MR_is_nan(MR_Float Flt)
+{
+#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISNANF)
+ return isnanf(Flt);
+#elif defined(MR_HAVE_ISNAN)
+ return isnan(Flt);
+#else
+ return (Flt != Flt);
+#endif
+}
+
+MR_bool
+MR_is_inf(MR_Float Flt)
+{
+#if defined(MR_USE_SINGLE_PREC_FLOAT) && defined(MR_HAVE_ISINFF)
+ return isinff(Flt);
+#elif defined(MR_HAVE_ISINF)
+ return isinf(Flt);
+#else
+ return (Flt == Flt / 2.0 && Flt != 0.0);
+#endif
}
Index: runtime/mercury_float.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_float.h,v
retrieving revision 1.16
diff -u -r1.16 mercury_float.h
--- runtime/mercury_float.h 29 Nov 2002 13:26:01 -0000 1.16
+++ runtime/mercury_float.h 29 Nov 2002 13:47:37 -0000
@@ -116,4 +116,7 @@
MR_Integer MR_hash_float(MR_Float);
+MR_bool MR_is_nan(MR_Float);
+MR_bool MR_is_inf(MR_Float);
+
#endif /* not MERCURY_FLOAT_H */
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list