libroot: Avoid glibc-internal math function usage in printf.

There's no reason for this, and we'd like to not export
these functions anymore (under non-x86/x86_64), so just use
the public macros.
This commit is contained in:
Augustin Cavalier 2020-01-18 23:42:03 -05:00
parent aee487519d
commit 9e419c3092
2 changed files with 15 additions and 17 deletions

View File

@ -65,7 +65,7 @@
# define PAD(f, c, n) __printf_pad (f, c, n) # define PAD(f, c, n) __printf_pad (f, c, n)
ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
#endif /* USE_IN_LIBIO */ #endif /* USE_IN_LIBIO */
/* Macros for doing the actual output. */ /* Macros for doing the actual output. */
#define outchar(ch) \ #define outchar(ch) \
@ -107,7 +107,7 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
done += len; \ done += len; \
} \ } \
while (0) while (0)
/* We use the GNU MP library to handle large numbers. /* We use the GNU MP library to handle large numbers.
An MP variable occupies a varying number of entries in its array. We keep An MP variable occupies a varying number of entries in its array. We keep
@ -120,8 +120,6 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
#define MPN_GE(u,v) \ #define MPN_GE(u,v) \
(u##size > v##size || (u##size == v##size && __mpn_cmp (u, v, u##size) >= 0)) (u##size > v##size || (u##size == v##size && __mpn_cmp (u, v, u##size) >= 0))
extern int __isinfl (long double), __isnanl (long double);
extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size, extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
int *expt, int *is_neg, int *expt, int *is_neg,
double value); double value);
@ -328,7 +326,7 @@ hack_digit_end:
fpnum.ldbl = *(const long double *) args[0]; fpnum.ldbl = *(const long double *) args[0];
/* Check for special values: not a number or infinity. */ /* Check for special values: not a number or infinity. */
if (__isnanl (fpnum.ldbl)) if (isnan (fpnum.ldbl))
{ {
if (isupper (info->spec)) if (isupper (info->spec))
{ {
@ -342,7 +340,7 @@ hack_digit_end:
} }
is_neg = 0; is_neg = 0;
} }
else if (__isinfl (fpnum.ldbl)) else if (isinf (fpnum.ldbl))
{ {
if (isupper (info->spec)) if (isupper (info->spec))
{ {
@ -372,7 +370,7 @@ hack_digit_end:
fpnum.dbl = *(const double *) args[0]; fpnum.dbl = *(const double *) args[0];
/* Check for special values: not a number or infinity. */ /* Check for special values: not a number or infinity. */
if (__isnan (fpnum.dbl)) if (isnan (fpnum.dbl))
{ {
if (isupper (info->spec)) if (isupper (info->spec))
{ {
@ -386,7 +384,7 @@ hack_digit_end:
} }
is_neg = 0; is_neg = 0;
} }
else if (__isinf (fpnum.dbl)) else if (isinf (fpnum.dbl))
{ {
if (isupper (info->spec)) if (isupper (info->spec))
{ {
@ -1162,7 +1160,7 @@ hack_digit_callee3:
} }
return done; return done;
} }
/* Return the number of extra grouping characters that will be inserted /* Return the number of extra grouping characters that will be inserted
into a number with INTDIG_MAX integer digits. */ into a number with INTDIG_MAX integer digits. */

View File

@ -45,7 +45,7 @@
# define PAD(f, c, n) __printf_pad (f, c, n) # define PAD(f, c, n) __printf_pad (f, c, n)
ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
#endif /* USE_IN_LIBIO */ #endif /* USE_IN_LIBIO */
/* Macros for doing the actual output. */ /* Macros for doing the actual output. */
#define outchar(ch) \ #define outchar(ch) \
@ -87,12 +87,12 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */
done += len; \ done += len; \
} \ } \
while (0) while (0)
/* Prototype for helper functions. */ /* Prototype for helper functions. */
extern int __printf_fp (FILE *fp, const struct printf_info *info, extern int __printf_fp (FILE *fp, const struct printf_info *info,
const void *const *args); const void *const *args);
int int
printf_size (FILE *fp, const struct printf_info *info, const void *const *args) printf_size (FILE *fp, const struct printf_info *info, const void *const *args)
{ {
@ -134,13 +134,13 @@ printf_size (FILE *fp, const struct printf_info *info, const void *const *args)
fpnum.ldbl.d = *(const long double *) args[0]; fpnum.ldbl.d = *(const long double *) args[0];
/* Check for special values: not a number or infinity. */ /* Check for special values: not a number or infinity. */
if (__isnanl (fpnum.ldbl.d)) if (isnan (fpnum.ldbl.d))
{ {
special = "nan"; special = "nan";
wspecial = L"nan"; wspecial = L"nan";
negative = 0; negative = 0;
} }
else if (__isinfl (fpnum.ldbl.d)) else if (isinf (fpnum.ldbl.d))
{ {
special = "inf"; special = "inf";
wspecial = L"inf"; wspecial = L"inf";
@ -160,13 +160,13 @@ printf_size (FILE *fp, const struct printf_info *info, const void *const *args)
fpnum.dbl.d = *(const double *) args[0]; fpnum.dbl.d = *(const double *) args[0];
/* Check for special values: not a number or infinity. */ /* Check for special values: not a number or infinity. */
if (__isnan (fpnum.dbl.d)) if (isnan (fpnum.dbl.d))
{ {
special = "nan"; special = "nan";
wspecial = L"nan"; wspecial = L"nan";
negative = 0; negative = 0;
} }
else if (__isinf (fpnum.dbl.d)) else if (isinf (fpnum.dbl.d))
{ {
special = "inf"; special = "inf";
wspecial = L"inf"; wspecial = L"inf";
@ -250,7 +250,7 @@ printf_size (FILE *fp, const struct printf_info *info, const void *const *args)
return done; return done;
} }
/* This is the function used by `vfprintf' to determine number and /* This is the function used by `vfprintf' to determine number and
type of the arguments. */ type of the arguments. */
int int