diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2021-11-29 15:56:46 +0300 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2021-11-29 16:51:16 +0300 |
commit | 48f6c59332ee2970cd4b172278176dcfe32a328d (patch) | |
tree | 958c95110c5543b1e8f04b9b662fc21b4dcf706d /newlib/libc | |
parent | 3502a6ff2e2740afb6cce71a95c715e80edadff5 (diff) |
stdio: Fix issue of printing "%La" format with large exp part.
- Currently, printf("%La\n", 1e1000L) crashes with segv due to lack
of frexpl() function. With this patch, frexpl() function has been
implemented in libm to solve this issue.
Addresses: https://sourceware.org/pipermail/newlib/2021/018718.html
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/include/math.h | 1 | ||||
-rw-r--r-- | newlib/libc/stdio/vfprintf.c | 5 | ||||
-rw-r--r-- | newlib/libc/stdio/vfwprintf.c | 5 |
3 files changed, 3 insertions, 8 deletions
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 0b6494e6a..799ac494a 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -509,6 +509,7 @@ extern long double erfcl (long double); #else /* !_LDBL_EQ_DBL && !__CYGWIN__ */ extern long double hypotl (long double, long double); extern long double sqrtl (long double); +extern long double frexpl (long double, int *); #ifdef __i386__ /* Other long double precision functions. */ extern _LONG_DOUBLE rintl (_LONG_DOUBLE); diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 1aaf05aa4..c1483c0ac 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -517,10 +517,7 @@ extern int _ldcheck (_LONG_DOUBLE *); # define _PRINTF_FLOAT_TYPE _LONG_DOUBLE # define _DTOA_R _ldtoa_r -/* FIXME - frexpl is not yet supported; and cvt infloops if (double)f - converts a finite value into infinity. */ -/* # define FREXP frexpl */ -# define FREXP(f,e) ((_LONG_DOUBLE) frexp ((double)f, e)) +# define FREXP frexpl # endif /* !_NO_LONGDBL */ static char *cvt(struct _reent *, _PRINTF_FLOAT_TYPE, int, int, char *, int *, diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c index 980b31e3b..7384b37d3 100644 --- a/newlib/libc/stdio/vfwprintf.c +++ b/newlib/libc/stdio/vfwprintf.c @@ -243,10 +243,7 @@ extern int _ldcheck (_LONG_DOUBLE *); # define _PRINTF_FLOAT_TYPE _LONG_DOUBLE # define _DTOA_R _ldtoa_r -/* FIXME - frexpl is not yet supported; and cvt infloops if (double)f - converts a finite value into infinity. */ -/* # define FREXP frexpl */ -# define FREXP(f,e) ((_LONG_DOUBLE) frexp ((double)f, e)) +# define FREXP frexpl # endif /* !_NO_LONGDBL */ static wchar_t *wcvt(struct _reent *, _PRINTF_FLOAT_TYPE, int, int, wchar_t *, |