changeset 32855:47e095a78a97 stable

lo-ieee.h: Restore compatibility with C. * 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): Restore ability to include this header in C code. Use functions from C++11 or C99 depending on whether header is included in C or C++ code.
author Markus Mützel <markus.muetzel@gmx.de>
date Fri, 26 Jan 2024 08:38:18 +0100
parents 023a561eafd6
children abeeee47f25b 0847c124488a
files liboctave/util/lo-ieee.h
diffstat 1 files changed, 26 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/util/lo-ieee.h	Thu Jan 25 20:36:24 2024 +0100
+++ b/liboctave/util/lo-ieee.h	Fri Jan 26 08:38:18 2024 +0100
@@ -28,10 +28,12 @@
 
 #include "octave-config.h"
 
-#include <cmath>
+#if defined (__cplusplus)
+#  include <cmath>
 
-#if defined (__cplusplus)
 extern "C" {
+#else
+#  include <math.h>
 #endif
 
 /*  Octave's idea of infinity.  */
@@ -69,30 +71,44 @@
 
 extern OCTAVE_API void octave_ieee_init (void);
 
+#if defined (__cplusplus)
 inline int __lo_ieee_isnan (double x) { return std::isnan (x); }
 inline int __lo_ieee_isfinite (double x) { return std::isfinite (x); }
 inline int __lo_ieee_isinf (double x) { return std::isinf (x); }
 
+inline int __lo_ieee_signbit (double x) { return std::signbit (x); }
+
+inline int __lo_ieee_float_isnan (float x) { return std::isnan (x); }
+inline int __lo_ieee_float_isfinite (float x) { return std::isfinite (x); }
+inline int __lo_ieee_float_isinf (float x) { return std::isinf (x); }
+
+inline int __lo_ieee_float_signbit (float x) { return std::signbit (x); }
+#else
+inline int __lo_ieee_isnan (double x) { return isnan (x); }
+inline int __lo_ieee_isfinite (double x) { return isfinite (x); }
+inline int __lo_ieee_isinf (double x) { return isinf (x); }
+
+inline int __lo_ieee_signbit (double x) { return signbit (x); }
+
+inline int __lo_ieee_float_isnan (float x) { return isnan (x); }
+inline int __lo_ieee_float_isfinite (float x) { return isfinite (x); }
+inline int __lo_ieee_float_isinf (float x) { return isinf (x); }
+
+inline int __lo_ieee_float_signbit (float x) { return signbit (x); }
+#endif
+
 extern OCTAVE_API int __lo_ieee_is_NA (double);
 
 extern OCTAVE_API double lo_ieee_inf_value (void);
 extern OCTAVE_API double lo_ieee_na_value (void);
 extern OCTAVE_API double lo_ieee_nan_value (void);
 
-inline int __lo_ieee_signbit (double x) { return std::signbit (x); }
-
-inline int __lo_ieee_float_isnan (float x) { return std::isnan (x); }
-inline int __lo_ieee_float_isfinite (float x) { return std::isfinite (x); }
-inline int __lo_ieee_float_isinf (float x) { return std::isinf (x); }
-
 extern OCTAVE_API int __lo_ieee_float_is_NA (float);
 
 extern OCTAVE_API float lo_ieee_float_inf_value (void);
 extern OCTAVE_API float lo_ieee_float_na_value (void);
 extern OCTAVE_API float lo_ieee_float_nan_value (void);
 
-inline int __lo_ieee_float_signbit (float x) { return std::signbit (x); }
-
 #if defined (__cplusplus)
 }
 #endif