]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Avoid use GLIBC_PRIVATE symbols in the implementation of nan* functions
authorFlorian Weimer <fweimer@redhat.com>
Thu, 10 May 2018 09:49:03 +0000 (11:49 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 10 May 2018 10:42:05 +0000 (12:42 +0200)
math/s_nan_template.c
sysdeps/generic/math-type-macros-double.h
sysdeps/generic/math-type-macros-float.h
sysdeps/generic/math-type-macros-float128.h
sysdeps/generic/math-type-macros-ldouble.h
sysdeps/ieee754/float128/strtod_nan_float128.h

index fe390474e41a25b21b5b17156433a179f8c9e7c5..575d72dc5b4a4e188af608f2ed79017f111720d6 100644 (file)
 #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)
index 1af4c74e4b0019324b7062011649a1b24bf95865..a4b5dafef1d9fcb1801b41a878defc4aaa99f10d 100644 (file)
@@ -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
index 9273bdee0efba7afab80207aae9bb344a011e571..529c5534b98870058111bf0eb01535d90f6ac39a 100644 (file)
@@ -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
index 605996e0ba73f3ad1e421f516396442b2c2b1e25..264d34e7fee4b7e0e85060d0358ef9b9bcff4928 100644 (file)
@@ -32,6 +32,8 @@
 
 #define M_MLIT(c) c ## f128
 
+#include <strtod_nan_float128.h>
+
 #include <libm-alias-float128.h>
 
 #ifndef declare_mgen_alias
index 5fe1600231a0465cca52f2d7ce5bea699aebc6cb..726ac87a10a408cde65159bb102f52fa14fbdb50 100644 (file)
@@ -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
index c3eaca4c80615fdf301154841d080324494306b5..44a8d18e5ab91176d55dd89847ab23faf17d923f 100644 (file)
@@ -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                                                   \