From: Kito Cheng <kito.cheng@gmail.com>
To: newlib@sourceware.org
Subject: [PATCH] Add __packed to struct ldieee
Date: Sun, 16 Apr 2017 08:35:00 -0000 [thread overview]
Message-ID: <CA+yXCZCq2yh-0ftbF0D+3K=cDnFk0fSd=T38vZ-f=H-W815NNA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 175 bytes --]
I've seem struct ldieee issue reported[1] 1 years ago, and problem
still here, so here is the patch for this problem.
[1] https://sourceware.org/ml/newlib/2016/msg00043.html
[-- Attachment #2: 0001-Add-__packed-to-struct-ldieee.patch --]
[-- Type: text/x-patch, Size: 2071 bytes --]
From e722ad01d0c59368eacc88c9a380a524313b19eb Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng@gmail.com>
Date: Sun, 9 Apr 2017 00:06:06 +0800
Subject: [PATCH] Add __packed to struct ldieee
- We don't want any padding in struct ldieee, otherwise the offset
might wrong in most compiler.
---
newlib/libc/stdio/vfieeefp.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/newlib/libc/stdio/vfieeefp.h b/newlib/libc/stdio/vfieeefp.h
index 7169119..e85cabb 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 */
--
2.7.4
next reply other threads:[~2017-04-16 8:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-16 8:35 Kito Cheng [this message]
2017-04-18 10:27 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+yXCZCq2yh-0ftbF0D+3K=cDnFk0fSd=T38vZ-f=H-W815NNA@mail.gmail.com' \
--to=kito.cheng@gmail.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).