# HG changeset patch # User John W. Eaton # Date 1289443971 18000 # Node ID 2718e1fdf82fd1284af5ec55f6cd5bdb6e6c7988 # Parent 1dfbcc9eee9272a177e0c18326680b927d12d483 IEEE math initialization tweaks diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,10 @@ +2010-11-10 John W. Eaton + + * configure.ac: Don't check for nan.h. + 2010-11-10 John W. Eaton * configure.ac (AH_BOTTOM): Eliminate special case for __DECCXX: - (WARN_CXXFLAGS): 2010-11-10 John W. Eaton diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1526,11 +1526,10 @@ ### C headers -AC_CHECK_HEADERS(curses.h direct.h dlfcn.h \ - floatingpoint.h grp.h ieeefp.h inttypes.h locale.h memory.h nan.h \ - ncurses.h poll.h pthread.h pwd.h sunmath.h sys/ioctl.h \ - sys/param.h sys/poll.h sys/resource.h sys/select.h \ - sys/utsname.h termcap.h) +AC_CHECK_HEADERS(curses.h direct.h dlfcn.h floatingpoint.h grp.h \ + ieeefp.h inttypes.h locale.h memory.h ncurses.h poll.h pthread.h \ + pwd.h sunmath.h sys/ioctl.h sys/param.h sys/poll.h sys/resource.h \ + sys/select.h sys/utsname.h termcap.h) ### C++ headers diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2010-11-10 John W. Eaton + + * lo-ieee.cc (octave_ieee_init): Don't initialize octave_Inf, + octave_NaN, and octave_NA to DBL_MAX. Don't initialize + octave_Float_Inf, octave_Float_NaN, and octave_Float_NA to FLT_MAX. + (octave_ieee_init): Simplify using std::numeric_limits template. + 2010-11-10 John W. Eaton * syswait.h: Delete special cases for NeXT systems. diff --git a/liboctave/lo-ieee.cc b/liboctave/lo-ieee.cc --- a/liboctave/lo-ieee.cc +++ b/liboctave/lo-ieee.cc @@ -25,37 +25,17 @@ #include #endif -#include #include -#if defined (HAVE_FLOATINGPOINT_H) -#include -#endif - -#if defined (HAVE_IEEEFP_H) -#include -#endif - -#if defined (HAVE_NAN_H) -#include -#endif +#include #include "lo-error.h" #include "lo-ieee.h" -#include "lo-math.h" #include "mach-info.h" void octave_ieee_init (void) { - // Default values. DBL_MAX is not right for NaN and NA, but do you - // have a better suggestion? If you don't have IEEE floating point - // values, there are many parts of Octave that will not work - // correctly. - - octave_Inf = octave_NaN = octave_NA = DBL_MAX; - octave_Float_Inf = octave_Float_NaN = octave_Float_NA = FLT_MAX; - oct_mach_info::float_format ff = oct_mach_info::native_float_format (); switch (ff) @@ -63,41 +43,13 @@ case oct_mach_info::flt_fmt_ieee_big_endian: case oct_mach_info::flt_fmt_ieee_little_endian: { - // Don't optimize away tmp_inf / tmp_inf to generate octave_NaN. - - volatile double tmp_inf; + octave_NaN = std::numeric_limits::quiet_NaN (); + octave_Inf = std::numeric_limits::infinity (); -#if defined (__alpha__) && defined (__osf__) - extern unsigned int DINFINITY[2]; - tmp_inf = (*(X_CAST(double *, DINFINITY))); -#else - double tmp = 1e+10; - tmp_inf = tmp; - for (;;) - { - tmp_inf *= 1e+10; - if (tmp_inf == tmp) - break; - tmp = tmp_inf; - } -#endif + octave_Float_NaN = std::numeric_limits::quiet_NaN (); + octave_Float_Inf = std::numeric_limits::infinity (); -#if defined (__alpha__) && defined (__osf__) - extern unsigned int DQNAN[2]; - octave_NaN = (*(X_CAST(double *, DQNAN))); -#elif defined (__NetBSD__) - octave_NaN = nan (""); -#else - octave_NaN = tmp_inf / tmp_inf; - // try to ensure that lo_ieee_sign gives false for a NaN. - if (lo_ieee_signbit (octave_NaN)) - octave_NaN = -octave_NaN; - -#endif - - octave_Inf = tmp_inf; - - // This is patterned after code in R. + // The following is patterned after code in R. if (ff == oct_mach_info::flt_fmt_ieee_big_endian) { @@ -116,25 +68,6 @@ octave_NA = t.value; - volatile float float_tmp_inf; - - float float_tmp = 1e+10; - float_tmp_inf = float_tmp; - for (;;) - { - float_tmp_inf *= 1e+10; - if (float_tmp_inf == float_tmp) - break; - float_tmp = float_tmp_inf; - } - -#if defined (__NetBSD__) - octave_Float_NaN = nanf (""); -#else - octave_Float_NaN = float_tmp_inf / float_tmp_inf; -#endif - octave_Float_Inf = float_tmp_inf; - lo_ieee_float tf; tf.word = LO_IEEE_NA_FLOAT; octave_Float_NA = tf.value; diff --git a/liboctave/lo-ieee.h b/liboctave/lo-ieee.h --- a/liboctave/lo-ieee.h +++ b/liboctave/lo-ieee.h @@ -70,7 +70,6 @@ #define LO_IEEE_NA_LW 0x40000000 #define LO_IEEE_NA_FLOAT 0x7FC207A2 - extern OCTAVE_API void octave_ieee_init (void); extern OCTAVE_API int __lo_ieee_isnan (double x); diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-11-10 John W. Eaton + + * octave.cc (octave_main): Call octave_ieee_init here. + * sysdep.cc (sysdep_init): Not here. + 2010-11-10 John W. Eaton * sysdep.cc: Eliminate special case for __DECCXX. diff --git a/src/octave.cc b/src/octave.cc --- a/src/octave.cc +++ b/src/octave.cc @@ -604,6 +604,8 @@ sysdep_init (); + octave_ieee_init (); + // The idea here is to force xerbla to be referenced so that we will // link to our own version instead of the one provided by the BLAS // library. But octave_NaN should never be -1, so we should never diff --git a/src/sysdep.cc b/src/sysdep.cc --- a/src/sysdep.cc +++ b/src/sysdep.cc @@ -245,8 +245,6 @@ #elif defined (_MSC_VER) MSVC_init (); #endif - - octave_ieee_init (); } void