From: Florian Weimer Date: Thu, 10 May 2018 09:49:03 +0000 (+0200) Subject: Avoid use GLIBC_PRIVATE symbols in the implementation of nan* functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e2c360c90d61b2f573d19b5cb991e9644fc0458;p=thirdparty%2Fglibc.git Avoid use GLIBC_PRIVATE symbols in the implementation of nan* functions --- diff --git a/math/s_nan_template.c b/math/s_nan_template.c index fe390474e41..575d72dc5b4 100644 --- a/math/s_nan_template.c +++ b/math/s_nan_template.c @@ -23,11 +23,50 @@ #include #include +/* 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 1af4c74e4b0..a4b5dafef1d 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 + #include #ifndef declare_mgen_alias diff --git a/sysdeps/generic/math-type-macros-float.h b/sysdeps/generic/math-type-macros-float.h index 9273bdee0ef..529c5534b98 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 + #include #ifndef declare_mgen_alias diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h index 605996e0ba7..264d34e7fee 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 + #include #ifndef declare_mgen_alias diff --git a/sysdeps/generic/math-type-macros-ldouble.h b/sysdeps/generic/math-type-macros-ldouble.h index 5fe1600231a..726ac87a10a 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 + #include #ifndef declare_mgen_alias diff --git a/sysdeps/ieee754/float128/strtod_nan_float128.h b/sysdeps/ieee754/float128/strtod_nan_float128.h index c3eaca4c806..44a8d18e5ab 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 . */ +#include + #define FLOAT _Float128 #define SET_MANTISSA(flt, mant) \ do \