From 48f6c59332ee2970cd4b172278176dcfe32a328d Mon Sep 17 00:00:00 2001 From: Takashi Yano Date: Mon, 29 Nov 2021 21:56:46 +0900 Subject: 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 --- newlib/libc/include/math.h | 1 + newlib/libc/stdio/vfprintf.c | 5 +---- newlib/libc/stdio/vfwprintf.c | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) (limited to 'newlib/libc') 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 *, -- cgit v1.2.3