about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-05-16 06:03:08 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-05-16 06:03:08 +0200
commit9761bf4dfae04016bccaa82414719523b090dd60 (patch)
tree1abcf3d350f8540e87f3850cb111a13cfaf66d8f /sysdeps/generic
parent69a01461ee1417578d2ba20aac935828b50f1118 (diff)
downloadglibc-9761bf4dfae04016bccaa82414719523b090dd60.tar.gz
glibc-9761bf4dfae04016bccaa82414719523b090dd60.tar.xz
glibc-9761bf4dfae04016bccaa82414719523b090dd60.zip
math: Merge strtod_nan_*.h into math-type-macros-*.h
This change will eventually make it possible to compile
stdlib/strtod_nan_main.c as part of math/s_nan_template.c.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/math-nan-payload-double.h29
-rw-r--r--sysdeps/generic/math-nan-payload-float.h28
-rw-r--r--sysdeps/generic/math-type-macros-double.h3
-rw-r--r--sysdeps/generic/math-type-macros-float.h3
-rw-r--r--sysdeps/generic/math-type-macros-float128.h1
-rw-r--r--sysdeps/generic/math-type-macros-ldouble.h3
-rw-r--r--sysdeps/generic/math-type-macros.h9
7 files changed, 72 insertions, 4 deletions
diff --git a/sysdeps/generic/math-nan-payload-double.h b/sysdeps/generic/math-nan-payload-double.h
new file mode 100644
index 0000000000..cfcc53a7b6
--- /dev/null
+++ b/sysdeps/generic/math-nan-payload-double.h
@@ -0,0 +1,29 @@
+/* NaN payload handling for double.
+   Copyright (C) 1997-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define SET_NAN_PAYLOAD(flt, mant)			\
+  do							\
+    {							\
+      union ieee754_double u;				\
+      u.d = (flt);					\
+      u.ieee_nan.mantissa0 = (mant) >> 32;		\
+      u.ieee_nan.mantissa1 = (mant);			\
+      if ((u.ieee.mantissa0 | u.ieee.mantissa1) != 0)	\
+	(flt) = u.d;					\
+    }							\
+  while (0)
diff --git a/sysdeps/generic/math-nan-payload-float.h b/sysdeps/generic/math-nan-payload-float.h
new file mode 100644
index 0000000000..2a4ff8ca64
--- /dev/null
+++ b/sysdeps/generic/math-nan-payload-float.h
@@ -0,0 +1,28 @@
+/* NaN payload handling for float.
+   Copyright (C) 1997-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define SET_NAN_PAYLOAD(flt, mant)		\
+  do						\
+    {						\
+      union ieee754_float u;			\
+      u.f = (flt);				\
+      u.ieee_nan.mantissa = (mant);		\
+      if (u.ieee.mantissa != 0)			\
+	(flt) = u.f;				\
+    }						\
+  while (0)
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
index 1af4c74e4b..156418221d 100644
--- a/sysdeps/generic/math-type-macros-double.h
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -27,6 +27,7 @@
 #define CFLOAT _Complex double
 #define M_STRTO_NAN __strtod_nan
 
+#include <math-nan-payload-double.h>
 #include <libm-alias-double.h>
 
 #ifndef declare_mgen_alias
@@ -42,7 +43,7 @@
 
 /* Do not use the type-generic wrapper templates if compatibility with
    SVID error handling is needed.  */
-#include <math-svid-compat.h>
+#include <math/math-svid-compat.h>
 #define __USE_WRAPPER_TEMPLATE !LIBM_SVID_COMPAT
 
 #endif
diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h
index 9273bdee0e..7dd0b74e24 100644
--- a/sysdeps/generic/math-type-macros-float.h
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -30,6 +30,7 @@
    the double macro constants.  */
 #define M_MLIT(c) c
 
+#include <math-nan-payload-float.h>
 #include <libm-alias-float.h>
 
 #ifndef declare_mgen_alias
@@ -45,7 +46,7 @@
 
 /* Do not use the type-generic wrapper templates if compatibility with
    SVID error handling is needed.  */
-#include <math-svid-compat.h>
+#include <math/math-svid-compat.h>
 #define __USE_WRAPPER_TEMPLATE !LIBM_SVID_COMPAT
 
 #endif
diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h
index 485c13bb88..6144bc047a 100644
--- a/sysdeps/generic/math-type-macros-float128.h
+++ b/sysdeps/generic/math-type-macros-float128.h
@@ -29,6 +29,7 @@
 
 #define M_MLIT(c) c ## f128
 
+#include <math-nan-payload-float128.h>
 #include <libm-alias-float128.h>
 
 #ifndef declare_mgen_alias
diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h
index 5fe1600231..db411998eb 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -27,6 +27,7 @@
 #define CFLOAT _Complex long double
 #define M_STRTO_NAN __strtold_nan
 
+#include <math-nan-payload-ldouble.h>
 #include <libm-alias-ldouble.h>
 
 #ifndef declare_mgen_alias
@@ -42,7 +43,7 @@
 
 /* Do not use the type-generic wrapper templates if compatibility with
    SVID error handling is needed.  */
-#include <math-svid-compat.h>
+#include <math/math-svid-compat.h>
 #define __USE_WRAPPER_TEMPLATE !LIBM_SVID_COMPAT
 
 #endif
diff --git a/sysdeps/generic/math-type-macros.h b/sysdeps/generic/math-type-macros.h
index ffcf7b80b6..0e8ef16d7a 100644
--- a/sysdeps/generic/math-type-macros.h
+++ b/sysdeps/generic/math-type-macros.h
@@ -40,7 +40,11 @@
 
   declare_mgen_alias_r(from,to)
       This exposes the appropriate symbol(s) for a
-      function f_r of type FLOAT.  */
+      function f_r of type FLOAT.
+
+  SET_NAN_PAYLOAD(flt, mant)
+      Set the NaN payload bits of the variable FLT of type FLOAT to
+      the mantissa MANT.  */
 
 #ifndef M_PFX
 # error "M_PFX must be defined."
@@ -66,6 +70,9 @@
 #ifndef declare_mgen_alias_r
 # error "declare_mgen_alias_r must be defined."
 #endif
+#ifndef SET_NAN_PAYLOAD
+# error "SET_NAN_PAYLOAD must be defined."
+#endif
 
 #define __M_CONCAT(a,b) a ## b
 #define __M_CONCATX(a,b) __M_CONCAT(a,b)