about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-05-10 11:49:03 +0200
committerFlorian Weimer <fweimer@redhat.com>2018-05-10 12:42:05 +0200
commit8e2c360c90d61b2f573d19b5cb991e9644fc0458 (patch)
tree91243d9c88ba7739abad1310fd35e1337f11636e
parent9e9dccb635991aa70187253bc188c87d3e139ed0 (diff)
downloadglibc-8e2c360c90d61b2f573d19b5cb991e9644fc0458.tar.gz
glibc-8e2c360c90d61b2f573d19b5cb991e9644fc0458.tar.xz
glibc-8e2c360c90d61b2f573d19b5cb991e9644fc0458.zip
Avoid use GLIBC_PRIVATE symbols in the implementation of nan* functions
-rw-r--r--math/s_nan_template.c41
-rw-r--r--sysdeps/generic/math-type-macros-double.h2
-rw-r--r--sysdeps/generic/math-type-macros-float.h2
-rw-r--r--sysdeps/generic/math-type-macros-float128.h2
-rw-r--r--sysdeps/generic/math-type-macros-ldouble.h2
-rw-r--r--sysdeps/ieee754/float128/strtod_nan_float128.h2
6 files changed, 50 insertions, 1 deletions
diff --git a/math/s_nan_template.c b/math/s_nan_template.c
index fe390474e4..575d72dc5b 100644
--- a/math/s_nan_template.c
+++ b/math/s_nan_template.c
@@ -23,11 +23,50 @@
 #include <string.h>
 #include <ieee754.h>
 
+/* See stdlib/strtod_nan_main.c.  */
+
+#define STRING_TYPE char
+#define STRTOD_NAN strtod_nan_internal
+#define L_(ch) ch
+#define STRTOULL(str, endp, endc) \
+  __strtoull_internal (str, endp, endc, /* group */ 0)
+
+static
+FLOAT
+STRTOD_NAN (const STRING_TYPE *str, STRING_TYPE **endptr, STRING_TYPE endc)
+{
+  const STRING_TYPE *cp = str;
+
+  while ((*cp >= L_('0') && *cp <= L_('9'))
+         || (*cp >= L_('A') && *cp <= L_('Z'))
+         || (*cp >= L_('a') && *cp <= L_('z'))
+         || *cp == L_('_'))
+    ++cp;
+
+  FLOAT retval = NAN;
+  if (*cp != endc)
+    goto out;
+
+  /* This is a system-dependent way to specify the bitmask used for
+     the NaN.  We expect it to be a number which is put in the
+     mantissa of the number.  */
+  STRING_TYPE *endp;
+  unsigned long long int mant;
+
+  mant = STRTOULL (str, &endp, 0);
+  if (endp == cp)
+    SET_MANTISSA (retval, mant);
+
+ out:
+  if (endptr != NULL)
+    *endptr = (STRING_TYPE *) cp;
+  return retval;
+}
 
 FLOAT
 M_DECL_FUNC (__nan) (const char *tagp)
 {
-  return M_STRTO_NAN (tagp, NULL, 0);
+  return strtod_nan_internal (tagp, NULL, 0);
 }
 
 declare_mgen_alias (__nan, nan)
diff --git a/sysdeps/generic/math-type-macros-double.h b/sysdeps/generic/math-type-macros-double.h
index 1af4c74e4b..a4b5dafef1 100644
--- a/sysdeps/generic/math-type-macros-double.h
+++ b/sysdeps/generic/math-type-macros-double.h
@@ -27,6 +27,8 @@
 #define CFLOAT _Complex double
 #define M_STRTO_NAN __strtod_nan
 
+#include <stdlib/strtod_nan_double.h>
+
 #include <libm-alias-double.h>
 
 #ifndef declare_mgen_alias
diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h
index 9273bdee0e..529c5534b9 100644
--- a/sysdeps/generic/math-type-macros-float.h
+++ b/sysdeps/generic/math-type-macros-float.h
@@ -30,6 +30,8 @@
    the double macro constants.  */
 #define M_MLIT(c) c
 
+#include <stdlib/strtod_nan_float.h>
+
 #include <libm-alias-float.h>
 
 #ifndef declare_mgen_alias
diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h
index 605996e0ba..264d34e7fe 100644
--- a/sysdeps/generic/math-type-macros-float128.h
+++ b/sysdeps/generic/math-type-macros-float128.h
@@ -32,6 +32,8 @@
 
 #define M_MLIT(c) c ## f128
 
+#include <strtod_nan_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..726ac87a10 100644
--- a/sysdeps/generic/math-type-macros-ldouble.h
+++ b/sysdeps/generic/math-type-macros-ldouble.h
@@ -27,6 +27,8 @@
 #define CFLOAT _Complex long double
 #define M_STRTO_NAN __strtold_nan
 
+#include <strtod_nan_ldouble.h>
+
 #include <libm-alias-ldouble.h>
 
 #ifndef declare_mgen_alias
diff --git a/sysdeps/ieee754/float128/strtod_nan_float128.h b/sysdeps/ieee754/float128/strtod_nan_float128.h
index c3eaca4c80..44a8d18e5a 100644
--- a/sysdeps/ieee754/float128/strtod_nan_float128.h
+++ b/sysdeps/ieee754/float128/strtod_nan_float128.h
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <ieee754_float128.h>
+
 #define FLOAT		_Float128
 #define SET_MANTISSA(flt, mant)				\
   do							\