diff --git a/src/acconfig.h b/src/acconfig.h index 96d45b68a1f66abfd42c27f2e95e8e6f529e7991..bc394581eb3954508cc517667bf5bc20cd9d9d39 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -1,5 +1,5 @@ /* - * $Id: acconfig.h,v 1.85 2001/05/27 16:58:57 grubba Exp $ + * $Id: acconfig.h,v 1.86 2001/05/28 18:15:06 marcus Exp $ */ #ifndef MACHINE_H #define MACHINE_H @@ -156,6 +156,9 @@ /* So has True64, but no useful information in prstatus_t */ #undef GETRUSAGE_THROUGH_PROCFS_PRS +/* Define if you have infnan */ +#undef HAVE_INFNAN + /* Define if you have fork */ #undef HAVE_FORK diff --git a/src/configure.in b/src/configure.in index 036bfe1c53c2734847246d195f3186716d9263ea..4bb4d8bf33589632d45bf5e0da4bd5a67049d748 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1,4 +1,4 @@ -AC_REVISION("$Id: configure.in,v 1.520 2001/05/27 16:58:58 grubba Exp $") +AC_REVISION("$Id: configure.in,v 1.521 2001/05/28 18:15:06 marcus Exp $") AC_INIT(interpret.c) AC_CONFIG_HEADER(machine.h) @@ -2523,6 +2523,7 @@ AC_CHECK_FUNCS( \ iszero \ finite \ signbit \ + nan \ nice \ __priocntl \ sched_setscheduler \ @@ -2668,6 +2669,17 @@ if test $ac_cv_func_crypt$ac_cv_func__crypt = nono ; then fi +############################################################################# +MY_CHECK_FUNCTION(infnan, +[ +#include <errno.h> +#include <math.h> +], [ + double pinf = infnan(ERANGE); + double ninf = infnan(-ERANGE); + double nan = infnan(EDOM); + exit(!(isinf(pinf)>0 && isinf(ninf)<0 && isnan(nan))); +]) ############################################################################# # FreeBSD 3.0 has broken F_SETFD when running with threads. diff --git a/src/opcodes.c b/src/opcodes.c index f18ccc4a597801ab89b6e42f9f928776d2603113..38be41398e43ba09a9f0f3d991a2614b5dd0f8dc 100644 --- a/src/opcodes.c +++ b/src/opcodes.c @@ -5,6 +5,7 @@ \*/ /**/ #include "global.h" +#include <errno.h> #include <math.h> #include <ctype.h> #include "interpret.h" @@ -26,7 +27,7 @@ #include "bignum.h" #include "operators.h" -RCSID("$Id: opcodes.c,v 1.107 2001/05/15 04:33:58 hubbe Exp $"); +RCSID("$Id: opcodes.c,v 1.108 2001/05/28 18:15:07 marcus Exp $"); void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind) { @@ -881,12 +882,21 @@ static INLINE FLOAT_TYPE low_parse_IEEE_float(char *b, int sz) if(e>=9999) if(f||extra_f) { /* NAN */ - - /* Hmm... No idea how to generate NaN in a portable way. */ - /* Let's turn it into a 0 for now... */ +#ifdef HAVE_INFNAN + return (FLOAT_TYPE)infnan(EDOM); +#else +#ifdef HAVE_NAN + /* C99 provides a portable way of generating NaN */ + return (FLOAT_TYPE)nan(""); +#else return (FLOAT_TYPE)0.0; +#endif /* HAVE_NAN */ +#endif /* HAVE_INFNAN */ } else { /* +/- Infinity */ +#ifdef HAVE_INFNAN + return (FLOAT_TYPE)infnan(s? -ERANGE:ERANGE); +#else #ifdef HUGE_VAL return (FLOAT_TYPE)(s? -HUGE_VAL:HUGE_VAL); #else @@ -894,7 +904,8 @@ static INLINE FLOAT_TYPE low_parse_IEEE_float(char *b, int sz) e = 1024; f = 1; extra_f = 0; -#endif +#endif /* HUGE_VAL */ +#endif /* HAVE_INFNAN */ } r = (double)f;