changeset 32857:00e493a27de2

Deprecate lo_ieee_ functions that are part of C99 or C++11. * lo-ieee.h (__lo_ieee_isnan, __lo_ieee_isfinite, __lo_ieee_isinf, __lo_ieee_signbit, __lo_ieee_float_isnan, __lo_ieee_float_isfinite, __lo_ieee_float_isinf, __lo_ieee_float_signbit): Mark functions as deprecated. * lo-ieee.cc, mex.cc, oct-stream.cc, pr-output.cc, ov-complex.h, ov-float.h, ov-flt-complex.h, ov-scalar.h, dSparse.h, Faddeeva.cc, lo-mappers.cc, oct-norm.cc, randgamma.cc, randpoisson.cc, lo-utils.cc: Avoid using deprecated functions.
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 25 Jan 2024 20:15:37 +0100
parents abeeee47f25b
children b70b005c145f
files libinterp/corefcn/mex.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/pr-output.cc libinterp/octave-value/ov-complex.h libinterp/octave-value/ov-float.h libinterp/octave-value/ov-flt-complex.h libinterp/octave-value/ov-scalar.h liboctave/array/dSparse.cc liboctave/external/Faddeeva/Faddeeva.cc liboctave/numeric/lo-mappers.cc liboctave/numeric/oct-norm.cc liboctave/numeric/randgamma.cc liboctave/numeric/randpoisson.cc liboctave/util/lo-ieee.cc liboctave/util/lo-ieee.h liboctave/util/lo-utils.cc
diffstat 16 files changed, 47 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/mex.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/corefcn/mex.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -47,7 +47,6 @@
 #include <string>
 
 #include "f77-fcn.h"
-#include "lo-ieee.h"
 #include "oct-locbuf.h"
 #include "quit.h"
 
@@ -3559,19 +3558,19 @@
 bool
 mxIsFinite (const double v)
 {
-  return lo_ieee_isfinite (v) != 0;
+  return octave::math::isfinite (v) != 0;
 }
 
 bool
 mxIsInf (const double v)
 {
-  return lo_ieee_isinf (v) != 0;
+  return octave::math::isinf (v) != 0;
 }
 
 bool
 mxIsNaN (const double v)
 {
-  return lo_ieee_isnan (v) != 0;
+  return octave::math::isnan (v) != 0;
 }
 
 double
--- a/libinterp/corefcn/oct-stream.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/corefcn/oct-stream.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -110,7 +110,7 @@
 
   if (! conv_err)
     {
-      if (! lo_ieee_isnan (dval))
+      if (! math::isnan (dval))
         {
           int ival = math::nint (dval);
 
@@ -131,7 +131,7 @@
 {
   octave_idx_type retval = -1;
 
-  if (lo_ieee_isnan (d))
+  if (math::isnan (d))
     ::error ("%s: NaN invalid as size specification", who.c_str ());
 
   if (math::isinf (d))
@@ -5817,7 +5817,7 @@
         }
 
       const char *tval;
-      if (lo_ieee_isinf (dval))
+      if (math::isinf (dval))
         {
           if (elt->flags.find ('+') != std::string::npos)
             tval = (dval < 0 ? "-Inf" : "+Inf");
--- a/libinterp/corefcn/pr-output.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/corefcn/pr-output.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -1546,7 +1546,7 @@
   if (! bank_format)
     {
       T i = cval.imag ();
-      if (! (hex_format || bit_format) && lo_ieee_signbit (i))
+      if (! (hex_format || bit_format) && std::signbit (i))
         {
           os << " - ";
           i = -i;
--- a/libinterp/octave-value/ov-complex.h	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/octave-value/ov-complex.h	Thu Jan 25 20:15:37 2024 +0100
@@ -33,7 +33,6 @@
 #include <iosfwd>
 #include <string>
 
-#include "lo-ieee.h"
 #include "mx-base.h"
 #include "str-vec.h"
 
@@ -85,8 +84,8 @@
   octave_value any (int = 0) const
   {
     return (scalar != Complex (0, 0)
-            && ! (lo_ieee_isnan (scalar.real ())
-                  || lo_ieee_isnan (scalar.imag ())));
+            && ! (octave::math::isnan (scalar.real ())
+                  || octave::math::isnan (scalar.imag ())));
   }
 
   builtin_type_t builtin_type () const { return btyp_complex; }
--- a/libinterp/octave-value/ov-float.h	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/octave-value/ov-float.h	Thu Jan 25 20:15:37 2024 +0100
@@ -33,7 +33,6 @@
 #include <iosfwd>
 #include <string>
 
-#include "lo-ieee.h"
 #include "lo-mappers.h"
 #include "lo-utils.h"
 #include "mx-base.h"
@@ -81,7 +80,7 @@
   { return octave::idx_vector (scalar); }
 
   octave_value any (int = 0) const
-  { return (scalar != 0 && ! lo_ieee_isnan (scalar)); }
+  { return (scalar != 0 && ! octave::math::isnan (scalar)); }
 
   builtin_type_t builtin_type () const { return btyp_float; }
 
--- a/libinterp/octave-value/ov-flt-complex.h	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/octave-value/ov-flt-complex.h	Thu Jan 25 20:15:37 2024 +0100
@@ -33,7 +33,6 @@
 #include <iosfwd>
 #include <string>
 
-#include "lo-ieee.h"
 #include "mx-base.h"
 #include "str-vec.h"
 
@@ -81,8 +80,8 @@
   octave_value any (int = 0) const
   {
     return (scalar != FloatComplex (0, 0)
-            && ! (lo_ieee_isnan (scalar.real ())
-                  || lo_ieee_isnan (scalar.imag ())));
+            && ! (octave::math::isnan (scalar.real ())
+                  || octave::math::isnan (scalar.imag ())));
   }
 
   builtin_type_t builtin_type () const { return btyp_float_complex; }
--- a/libinterp/octave-value/ov-scalar.h	Fri Jan 26 08:40:11 2024 +0100
+++ b/libinterp/octave-value/ov-scalar.h	Thu Jan 25 20:15:37 2024 +0100
@@ -33,7 +33,6 @@
 #include <iosfwd>
 #include <string>
 
-#include "lo-ieee.h"
 #include "lo-mappers.h"
 #include "lo-utils.h"
 #include "mx-base.h"
@@ -80,7 +79,7 @@
   { return octave::idx_vector (scalar); }
 
   octave_value any (int = 0) const
-  { return (scalar != 0 && ! lo_ieee_isnan (scalar)); }
+  { return (scalar != 0 && ! octave::math::isnan (scalar)); }
 
   builtin_type_t builtin_type () const { return btyp_double; }
 
--- a/liboctave/array/dSparse.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/array/dSparse.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -7186,7 +7186,7 @@
   if (neg_zero)
     {
       for (octave_idx_type i = 0; i < nel; i++)
-        if (lo_ieee_signbit (data (i)))
+        if (octave::math::signbit (data (i)))
           return true;
     }
   else
--- a/liboctave/external/Faddeeva/Faddeeva.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/external/Faddeeva/Faddeeva.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -184,10 +184,7 @@
 #  define FADDEEVA_RE(name) Faddeeva::name
 
 // isnan/isinf were introduced in C++11
-#  if defined (lo_ieee_isnan) && defined (lo_ieee_isinf)
-#    define isnan lo_ieee_isnan
-#    define isinf lo_ieee_isinf
-#  elif (__cplusplus < 201103L) && (!defined(HAVE_ISNAN) || !defined(HAVE_ISINF))
+#  if (__cplusplus < 201103L) && (!defined(HAVE_ISNAN) || !defined(HAVE_ISINF))
 static inline bool my_isnan(double x) { return x != x; }
 #    define isnan my_isnan
 static inline bool my_isinf(double x) { return 1/x == 0.; }
--- a/liboctave/numeric/lo-mappers.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/numeric/lo-mappers.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -178,9 +178,9 @@
 }
 
 bool
-negative_sign (double x) { return __lo_ieee_signbit (x); }
+negative_sign (double x) { return signbit (x); }
 bool
-negative_sign (float x) { return __lo_ieee_float_signbit (x); }
+negative_sign (float x) { return signbit (x); }
 
 // Sometimes you need a large integer, but not always.
 
--- a/liboctave/numeric/oct-norm.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/numeric/oct-norm.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -357,7 +357,7 @@
     FCN_NAME (v, res, norm_accumulator_2<R> ());              \
   else if (p == 1)                                            \
     FCN_NAME (v, res, norm_accumulator_1<R> ());              \
-  else if (lo_ieee_isinf (p))                                 \
+  else if (math::isinf (p))                                   \
     {                                                         \
       if (p > 0)                                              \
         FCN_NAME (v, res, norm_accumulator_inf<R> ());        \
@@ -551,7 +551,7 @@
     }
   else if (p == 1)
     res = xcolnorms (m, static_cast<R> (1)).max ();
-  else if (lo_ieee_isinf (p) && p > 1)
+  else if (math::isinf (p) && p > 1)
     res = xrownorms (m, static_cast<R> (1)).max ();
   else if (p > 1)
     {
@@ -573,7 +573,7 @@
   R res = 0;
   if (p == 1)
     res = xcolnorms (m, static_cast<R> (1)).max ();
-  else if (lo_ieee_isinf (p) && p > 1)
+  else if (math::isinf (p) && p > 1)
     res = xrownorms (m, static_cast<R> (1)).max ();
   else if (p > 1)
     {
--- a/liboctave/numeric/randgamma.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/numeric/randgamma.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -87,6 +87,7 @@
 #include <cmath>
 
 #include "lo-ieee.h"
+#include "lo-mappers.h"
 #include "randgamma.h"
 #include "randmtzig.h"
 
@@ -100,7 +101,7 @@
   const T c = 1./std::sqrt (9.*d);
 
   /* Handle invalid cases */
-  if (a <= 0 || lo_ieee_isinf (a))
+  if (a <= 0 || math::isinf (a))
     {
       for (i=0; i < n; i++)
         r[i] = numeric_limits<T>::NaN ();
--- a/liboctave/numeric/randpoisson.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/numeric/randpoisson.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -36,6 +36,7 @@
 #include "f77-fcn.h"
 #include "lo-error.h"
 #include "lo-ieee.h"
+#include "lo-mappers.h"
 #include "randmtzig.h"
 #include "randpoisson.h"
 
@@ -404,7 +405,7 @@
 {
   double L = L_arg;
   octave_idx_type i;
-  if (L < 0.0 || lo_ieee_isinf (L))
+  if (L < 0.0 || math::isinf (L))
     {
       for (i=0; i<n; i++)
         p[i] = numeric_limits<T>::NaN ();
@@ -461,7 +462,7 @@
       /* numerical recipes */
       poisson_rejection<T> (L, &ret, 1);
     }
-  else if (lo_ieee_isinf (L))
+  else if (math::isinf (L))
     {
       /* FIXME: R uses NaN, but the normal approximation suggests that
        * limit should be Inf.  Which is correct? */
--- a/liboctave/util/lo-ieee.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/util/lo-ieee.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -60,7 +60,7 @@
 {
   lo_ieee_double t;
   t.value = x;
-  return (__lo_ieee_isnan (x) && t.word[lo_ieee_hw] == LO_IEEE_NA_HW
+  return (std::isnan (x) && t.word[lo_ieee_hw] == LO_IEEE_NA_HW
           && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0;
 }
 
@@ -93,7 +93,7 @@
 {
   lo_ieee_float t;
   t.value = x;
-  return (__lo_ieee_float_isnan (x) && (t.word == LO_IEEE_NA_FLOAT)) ? 1 : 0;
+  return (std::isnan (x) && (t.word == LO_IEEE_NA_FLOAT)) ? 1 : 0;
 }
 
 float
--- a/liboctave/util/lo-ieee.h	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/util/lo-ieee.h	Thu Jan 25 20:15:37 2024 +0100
@@ -72,28 +72,44 @@
 extern OCTAVE_API void octave_ieee_init (void);
 
 #if defined (__cplusplus)
+OCTAVE_DEPRECATED (10, "use std::isnan instead")
 inline int __lo_ieee_isnan (double x) { return std::isnan (x); }
+OCTAVE_DEPRECATED (10, "use std::isfinite instead")
 inline int __lo_ieee_isfinite (double x) { return std::isfinite (x); }
+OCTAVE_DEPRECATED (10, "use std::isinf instead")
 inline int __lo_ieee_isinf (double x) { return std::isinf (x); }
 
+OCTAVE_DEPRECATED (10, "use std::signbit instead")
 inline int __lo_ieee_signbit (double x) { return std::signbit (x); }
 
+OCTAVE_DEPRECATED (10, "use std::isnan instead")
 inline int __lo_ieee_float_isnan (float x) { return std::isnan (x); }
+OCTAVE_DEPRECATED (10, "use std::isfinite instead")
 inline int __lo_ieee_float_isfinite (float x) { return std::isfinite (x); }
+OCTAVE_DEPRECATED (10, "use std::isinf instead")
 inline int __lo_ieee_float_isinf (float x) { return std::isinf (x); }
 
+OCTAVE_DEPRECATED (10, "use std::signbit instead")
 inline int __lo_ieee_float_signbit (float x) { return std::signbit (x); }
 #else
+OCTAVE_DEPRECATED (10, "use isnan instead")
 inline int __lo_ieee_isnan (double x) { return isnan (x); }
+OCTAVE_DEPRECATED (10, "use isfinite instead")
 inline int __lo_ieee_isfinite (double x) { return isfinite (x); }
+OCTAVE_DEPRECATED (10, "use isinf instead")
 inline int __lo_ieee_isinf (double x) { return isinf (x); }
 
+OCTAVE_DEPRECATED (10, "use signbit instead")
 inline int __lo_ieee_signbit (double x) { return signbit (x); }
 
+OCTAVE_DEPRECATED (10, "use isnan instead")
 inline int __lo_ieee_float_isnan (float x) { return isnan (x); }
+OCTAVE_DEPRECATED (10, "use isfinite instead")
 inline int __lo_ieee_float_isfinite (float x) { return isfinite (x); }
+OCTAVE_DEPRECATED (10, "use isinf instead")
 inline int __lo_ieee_float_isinf (float x) { return isinf (x); }
 
+OCTAVE_DEPRECATED (10, "use signbit instead")
 inline int __lo_ieee_float_signbit (float x) { return signbit (x); }
 #endif
 
--- a/liboctave/util/lo-utils.cc	Fri Jan 26 08:40:11 2024 +0100
+++ b/liboctave/util/lo-utils.cc	Thu Jan 25 20:15:37 2024 +0100
@@ -446,9 +446,9 @@
 {
   if (lo_ieee_is_NA (value))
     os << "NA";
-  else if (lo_ieee_isnan (value))
+  else if (math::isnan (value))
     os << "NaN";
-  else if (lo_ieee_isinf (value))
+  else if (math::isinf (value))
     os << (value < 0 ? "-Inf" : "Inf");
   else
     os << value;
@@ -474,9 +474,9 @@
 {
   if (lo_ieee_is_NA (value))
     os << "NA";
-  else if (lo_ieee_isnan (value))
+  else if (math::isnan (value))
     os << "NaN";
-  else if (lo_ieee_isinf (value))
+  else if (math::isinf (value))
     os << (value < 0 ? "-Inf" : "Inf");
   else
     os << value;