changeset 29366:8224cb664385

maint: merge stable to default.
author Rik <rik@octave.org>
date Sat, 13 Feb 2021 11:13:10 -0800
parents 1ea1cfb0b9bf (current diff) e9b7ac7031fb (diff)
children 8608b7e50720
files configure.ac m4/acinclude.m4
diffstat 3 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Feb 12 15:08:16 2021 +0100
+++ b/configure.ac	Sat Feb 13 11:13:10 2021 -0800
@@ -1187,6 +1187,9 @@
     [Define to 1 if C++ allows overload of char, int8_t, and uint8_t types.])
 fi
 
+## Check for MIPS-specific non-standard encoding of NaN value
+OCTAVE_MIPS_NAN
+
 ### Checks for functions and variables.
 
 dnl The list of functions is short because we use gnulib to guarantee
--- a/liboctave/util/lo-ieee.h	Fri Feb 12 15:08:16 2021 +0100
+++ b/liboctave/util/lo-ieee.h	Sat Feb 13 11:13:10 2021 -0800
@@ -69,7 +69,11 @@
 
 #define LO_IEEE_NA_HW_OLD 0x7ff00000
 #define LO_IEEE_NA_LW_OLD 1954
-#define LO_IEEE_NA_HW 0x7FF840F4
+#if defined (HAVE_MIPS_NAN)
+  #define LO_IEEE_NA_HW 0x7FF040F4
+#else
+  #define LO_IEEE_NA_HW 0x7FF840F4
+#endif
 #define LO_IEEE_NA_LW 0x40000000
 #define LO_IEEE_NA_FLOAT   0x7FC207A2
 
--- a/m4/acinclude.m4	Fri Feb 12 15:08:16 2021 +0100
+++ b/m4/acinclude.m4	Sat Feb 13 11:13:10 2021 -0800
@@ -2785,6 +2785,40 @@
   fi
 ])
 dnl
+dnl Check if MIPS processor is target and quiet signalling NaN value is
+dnl opposite of IEEE 754-2008 standard used by all other architectures.
+dnl
+AC_DEFUN([OCTAVE_MIPS_NAN], [
+  AC_CACHE_CHECK([whether MIPS processor is using non-standard NaN encoding],
+    [octave_cv_mips_nan],
+    [AC_LANG_PUSH(C++)
+    AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+        #include <cmath>
+        #include <limits>
+        ]], [[
+        /* FIXME: Only test is that MIPS is the target architecture.
+         * This should be AND'ed with a test for whether the actual NaN
+         * value for the high word (LO_IEEE_NA_HW) has the value
+         * 0x7FF840F4 (normal) or 0x7FF040F4 (non-standard).  Template code
+         * that could work is in liboctave/utils/lo-ieee.cc but it also
+         * depends on knowing whether the architecture is big-endian or
+         * little-endian.  */
+        #if defined (__mips__)
+          return (0);
+        #else
+          return (1);
+        #endif
+      ]])],
+      octave_cv_mips_nan=yes,
+      octave_cv_mips_nan=no)
+    AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_mips_nan = yes; then
+    AC_DEFINE(HAVE_MIPS_NAN, 1,
+      [Define to 1 if MIPS processor is using non-standard NaN encoding.])
+  fi
+])
+dnl
 dnl OCTAVE_CHECK_FORTRAN_SYMBOL_AND_CALLING_CONVENTIONS
 dnl
 dnl Set variables related to Fortran symbol names (append underscore,