From e24e77660ff2f80de9d0f1b773d84fc9fa246aca Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 13 Jun 2007 01:03:57 +0000 Subject: [PATCH] Detect and use the nan function. --- vvp/config.h.in | 15 ++++++++++++++- vvp/configure.in | 2 +- vvp/vthread.cc | 7 +++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/vvp/config.h.in b/vvp/config.h.in index c1371f1a1..bc1223953 100644 --- a/vvp/config.h.in +++ b/vvp/config.h.in @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: config.h.in,v 1.23 2007/02/02 04:33:01 steve Exp $" +#ident "$Id: config.h.in,v 1.24 2007/06/13 01:03:57 steve Exp $" #endif #if defined(__cplusplus) @@ -50,6 +50,7 @@ # undef HAVE_READLINE_HISTORY_H # undef HAVE_INTTYPES_H # undef HAVE_LROUND +# undef HAVE_NAN /* Figure if I can use readline. */ #undef USE_READLINE @@ -85,6 +86,8 @@ typedef unsigned long vvp_time64_t; # endif #endif +# include + /* getrusage, /proc/self/statm */ # undef HAVE_SYS_RESOURCE_H @@ -98,6 +101,13 @@ extern long lround(double x); #endif #endif +#if !defined(HAVE_NAN) +# define nan(x) (NAN) +#endif + +#if !defined(INFINITY) +# define INFINITY HUGE_VAL +#endif /* * When doing dynamic linking, we need a uniform way to identify the @@ -119,6 +129,9 @@ extern long lround(double x); /* * $Log: config.h.in,v $ + * Revision 1.24 2007/06/13 01:03:57 steve + * Detect and use the nan function. + * * Revision 1.23 2007/02/02 04:33:01 steve * Use inttypes.h instead of stdint.h for portability. * diff --git a/vvp/configure.in b/vvp/configure.in index b092c8c67..6d11b2a99 100644 --- a/vvp/configure.in +++ b/vvp/configure.in @@ -75,7 +75,7 @@ esac # Check that these functions exist. They are mostly C99 # functions that older compilers may not yet support. -AC_CHECK_FUNCS(lround) +AC_CHECK_FUNCS(lround nan) # see how we can give some resource usage stats with -v # Linux does not provide mem stats in rusage, use /proc/self/statm. diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 3523c03f6..283ca5dce 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vthread.cc,v 1.165 2007/06/12 02:36:58 steve Exp $" +#ident "$Id: vthread.cc,v 1.166 2007/06/13 01:03:57 steve Exp $" #endif # include "config.h" @@ -2207,7 +2207,7 @@ bool of_LOADI_WR(vthread_t thr, vvp_code_t cp) } // Detect NaN if ( (exp&0x3fff) == 0x3fff ) { - thr->words[idx].w_real = NAN; + thr->words[idx].w_real = nan(""); } double sign = (exp & 0x4000)? -1.0 : 1.0; @@ -3489,6 +3489,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp) /* * $Log: vthread.cc,v $ + * Revision 1.166 2007/06/13 01:03:57 steve + * Detect and use the nan function. + * * Revision 1.165 2007/06/12 02:36:58 steve * handle constant inf values. *