aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>2018-08-03 09:54:44 +1000
committerKugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>2018-09-10 09:09:39 +1000
commita49345b6625e455c9cd7f13c29e7279cc873af29 (patch)
treef7a7e62a29c72dcec363c66bd73084214aef937d
parent5351bf5cc793ea92911d868a16973871d5249563 (diff)
2018-08-03 Kugan Vivekanandarajah <kuganv@linaro.org>linaro-local/linaro-newlib-2_5_0
Backport from mainline. 2017-04-09 Kito Cheng <kito.cheng@gmail.com> * newlib/libc/stdio/vfieeefp.h : Add __packed to struct ldieee We don't want any padding in struct ldieee, otherwise the offset might wrong in most compiler. (Cherry picked from c23fbc3aedd0c25c0b0c34402e53328bffa692de) 2018-08-23 Kugan Vivekanandarajah <kuganv@linaro.org> Backport from mainline. 2017-06-03 Kito Cheng <kito.cheng@gmail.com> This patch let -NaN can print the right sign like glibc (Cherry picked from beb17b264b69e35763fbdf0a68fbf67343cfbb58) Change-Id: I97aa5795e09a884e52236442a584f2e42a6f7e87
-rw-r--r--newlib/libc/stdio/vfieeefp.h17
-rw-r--r--newlib/libc/stdio/vfprintf.c4
-rw-r--r--newlib/libc/stdio/vfwprintf.c4
3 files changed, 17 insertions, 8 deletions
diff --git a/newlib/libc/stdio/vfieeefp.h b/newlib/libc/stdio/vfieeefp.h
index 716911909..e85cabb3c 100644
--- a/newlib/libc/stdio/vfieeefp.h
+++ b/newlib/libc/stdio/vfieeefp.h
@@ -35,6 +35,7 @@
#include <float.h>
#include <errno.h>
#include <sys/config.h>
+#include <sys/cdefs.h>
#ifdef __IEEE_LITTLE_ENDIAN
#define IEEE_8087
@@ -71,7 +72,7 @@ struct ldieee
unsigned manh:23;
unsigned exp:8;
unsigned sign:1;
-};
+} __packed;
#elif LDBL_MANT_DIG == 53
struct ldieee
{
@@ -79,7 +80,7 @@ struct ldieee
unsigned manh:32;
unsigned exp:11;
unsigned sign:1;
-};
+} __packed;
#elif LDBL_MANT_DIG == 64
struct ldieee
{
@@ -87,7 +88,7 @@ struct ldieee
unsigned manh:32;
unsigned exp:15;
unsigned sign:1;
-};
+} __packed;
#elif LDBL_MANT_DIG > 64
struct ldieee
{
@@ -97,7 +98,7 @@ struct ldieee
unsigned manh:32;
unsigned exp:15;
unsigned sign:1;
-};
+} __packed;
#endif /* LDBL_MANT_DIG */
#else /* !IEEE_8087 */
#if LDBL_MANT_DIG == 24
@@ -106,7 +107,7 @@ struct ldieee
unsigned sign:1;
unsigned exp:8;
unsigned manh:23;
-};
+} __packed;
#elif LDBL_MANT_DIG == 53
struct ldieee
{
@@ -114,7 +115,7 @@ struct ldieee
unsigned exp:11;
unsigned manh:32;
unsigned manl:20;
-};
+} __packed;
#elif LDBL_MANT_DIG == 64
struct ldieee
{
@@ -122,7 +123,7 @@ struct ldieee
unsigned exp:15;
unsigned manh:32;
unsigned manl:32;
-};
+} __packed;
#elif LDBL_MANT_DIG > 64
struct ldieee
{
@@ -132,7 +133,7 @@ struct ldieee
unsigned manl:32;
unsigned manl2:32;
unsigned manl3:16;
-};
+} __packed;
#endif /* LDBL_MANT_DIG */
#endif /* !IEEE_8087 */
#endif /* _WANT_IO_LONG_DOUBLE */
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index ed92bb2f9..3585423af 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -1245,6 +1245,8 @@ reswitch: switch (ch) {
break;
}
if (isnan (_fpvalue)) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
cp = "NAN";
else
@@ -1276,6 +1278,8 @@ reswitch: switch (ch) {
break;
}
if (expt == 1) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
cp = "NAN";
else
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c
index f0179a014..4786ed6a9 100644
--- a/newlib/libc/stdio/vfwprintf.c
+++ b/newlib/libc/stdio/vfwprintf.c
@@ -970,6 +970,8 @@ reswitch: switch (ch) {
break;
}
if (isnan (_fpvalue)) {
+ if (signbit (_fpvalue))
+ sign = L'-';
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
cp = L"NAN";
else
@@ -1001,6 +1003,8 @@ reswitch: switch (ch) {
break;
}
if (expt == 1) {
+ if (signbit (_fpvalue))
+ sign = L'-';
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
cp = L"NAN";
else