From 9e419c309287fe41ebd658cee626c86194cc6fd0 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 18 Jan 2020 23:42:03 -0500 Subject: [PATCH] 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. --- .../libroot/posix/glibc/stdio-common/printf_fp.c | 16 +++++++--------- .../posix/glibc/stdio-common/printf_size.c | 16 ++++++++-------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/system/libroot/posix/glibc/stdio-common/printf_fp.c b/src/system/libroot/posix/glibc/stdio-common/printf_fp.c index 0abbed9e55..a425b3312c 100644 --- a/src/system/libroot/posix/glibc/stdio-common/printf_fp.c +++ b/src/system/libroot/posix/glibc/stdio-common/printf_fp.c @@ -65,7 +65,7 @@ # define PAD(f, c, n) __printf_pad (f, c, n) ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ #endif /* USE_IN_LIBIO */ - + /* Macros for doing the actual output. */ #define outchar(ch) \ @@ -107,7 +107,7 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ done += len; \ } \ while (0) - + /* We use the GNU MP library to handle large numbers. 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) \ (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, int *expt, int *is_neg, double value); @@ -328,7 +326,7 @@ hack_digit_end: fpnum.ldbl = *(const long double *) args[0]; /* Check for special values: not a number or infinity. */ - if (__isnanl (fpnum.ldbl)) + if (isnan (fpnum.ldbl)) { if (isupper (info->spec)) { @@ -342,7 +340,7 @@ hack_digit_end: } is_neg = 0; } - else if (__isinfl (fpnum.ldbl)) + else if (isinf (fpnum.ldbl)) { if (isupper (info->spec)) { @@ -372,7 +370,7 @@ hack_digit_end: fpnum.dbl = *(const double *) args[0]; /* Check for special values: not a number or infinity. */ - if (__isnan (fpnum.dbl)) + if (isnan (fpnum.dbl)) { if (isupper (info->spec)) { @@ -386,7 +384,7 @@ hack_digit_end: } is_neg = 0; } - else if (__isinf (fpnum.dbl)) + else if (isinf (fpnum.dbl)) { if (isupper (info->spec)) { @@ -1162,7 +1160,7 @@ hack_digit_callee3: } return done; } - + /* Return the number of extra grouping characters that will be inserted into a number with INTDIG_MAX integer digits. */ diff --git a/src/system/libroot/posix/glibc/stdio-common/printf_size.c b/src/system/libroot/posix/glibc/stdio-common/printf_size.c index 9837356e62..0c934d0ce4 100644 --- a/src/system/libroot/posix/glibc/stdio-common/printf_size.c +++ b/src/system/libroot/posix/glibc/stdio-common/printf_size.c @@ -45,7 +45,7 @@ # define PAD(f, c, n) __printf_pad (f, c, n) ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ #endif /* USE_IN_LIBIO */ - + /* Macros for doing the actual output. */ #define outchar(ch) \ @@ -87,12 +87,12 @@ ssize_t __printf_pad __P ((FILE *, char pad, int n)); /* In vfprintf.c. */ done += len; \ } \ while (0) - + /* Prototype for helper functions. */ extern int __printf_fp (FILE *fp, const struct printf_info *info, const void *const *args); - + int 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]; /* Check for special values: not a number or infinity. */ - if (__isnanl (fpnum.ldbl.d)) + if (isnan (fpnum.ldbl.d)) { special = "nan"; wspecial = L"nan"; negative = 0; } - else if (__isinfl (fpnum.ldbl.d)) + else if (isinf (fpnum.ldbl.d)) { special = "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]; /* Check for special values: not a number or infinity. */ - if (__isnan (fpnum.dbl.d)) + if (isnan (fpnum.dbl.d)) { special = "nan"; wspecial = L"nan"; negative = 0; } - else if (__isinf (fpnum.dbl.d)) + else if (isinf (fpnum.dbl.d)) { special = "inf"; wspecial = L"inf"; @@ -250,7 +250,7 @@ printf_size (FILE *fp, const struct printf_info *info, const void *const *args) return done; } - + /* This is the function used by `vfprintf' to determine number and type of the arguments. */ int