[m-rev.] for review: mercury implementation of string__format

Peter Ross pro at missioncriticalit.com
Fri Nov 22 04:21:36 AEDT 2002


On Fri, Nov 22, 2002 at 03:20:27AM +1100, Fergus Henderson wrote:
> On 21-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > runtime/mercury_conf.h.in:
> > 	#define for existence of ieeefp.h.
> 
> It would be nice to also check for isnan() and isinf() in <math.h>, which
> is where C99 puts them.
> 
> > +:- pragma promise_pure(is_nan/1).
> > +:- pragma foreign_proc(c, is_nan(Flt::in),
> > +		[will_not_call_mercury, thread_safe], "
> > +#if MR_USE_SINGLE_PREC_FLOAT
> > +	SUCCESS_INDICATOR = isnanf(Flt);
> > +#else
> > +	SUCCESS_INDICATOR = isnan(Flt);
> > +#endif
> 
> The use of isnan() and isnanf() need to be protected by
> conditional compilation, since not all systems support them.
> 
> Likewise for isinf() and isinff().
> 
I am heading off now but just checking that I am on the right approach with
configure.  The bit I am worried about is the

#ifdef MR_HAVE_IEEEFP_H 

will this be defined or do I need to do it another way.


Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.340
diff -u -r1.340 configure.in
--- configure.in	19 Nov 2002 08:16:05 -0000	1.340
+++ configure.in	21 Nov 2002 17:19:24 -0000
@@ -545,7 +545,7 @@
 		unistd.h sys/wait.h sys/siginfo.h sys/signal.h ucontext.h \
 		asm/sigcontext.h sys/param.h sys/time.h sys/times.h \
 		sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \
-		sys/stropts.h windows.h)
+		sys/stropts.h windows.h ieeefp.h)
 
 if test "$MR_HAVE_UCONTEXT_H" != 1; then
 	MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h)
@@ -2850,6 +2850,15 @@
 else
 	AC_MSG_RESULT(no)
 fi
+
+#-----------------------------------------------------------------------------#
+#
+# Check for the various IEEE predicates
+#
+MERCURY_CHECK_FOR_IEEE_FUNC(isnan)
+MERCURY_CHECK_FOR_IEEE_FUNC(isnanf)
+MERCURY_CHECK_FOR_IEEE_FUNC(isinf)
+MERCURY_CHECK_FOR_IEEE_FUNC(isinff)
 
 #-----------------------------------------------------------------------------#
 #
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.15
diff -u -r1.15 aclocal.m4
--- aclocal.m4	19 Nov 2002 08:16:05 -0000	1.15
+++ aclocal.m4	21 Nov 2002 17:19:24 -0000
@@ -24,6 +24,30 @@
     done
 ])
 #-----------------------------------------------------------------------------#
+AC_DEFUN(MERCURY_CHECK_FOR_IEEE_FUNC,
+[
+AC_MSG_CHECKING(for $1 function)
+mercury_cv_ieee_func_define="MR_HAVE_`echo $1 | \
+	tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
+
+AC_TRY_LINK([
+	#include <math.h>
+#ifdef MR_HAVE_IEEEFP_H
+	#include <ieeefp.h>
+#endif
+],[
+	$1(1.0);
+],[mercury_cv_have_ieee_func=yes],[mercury_cv_have_ieee_func=no])
+
+if test "$mercury_cv_have_ieee_func" = yes; then
+	AC_MSG_RESULT(yes)
+	AC_DEFINE($mercury_cv_ieee_func_define)
+else
+	AC_MSG_RESULT(no)
+fi
+])
+
+#-----------------------------------------------------------------------------#
 #
 # Turn off MacOS's so-called "smart" C preprocessor, if present,
 # since it causes lots of spurious warning messages,
--------------------------------------------------------------------------
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