You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/04/15 01:41:12 UTC
incubator-mynewt-core git commit: Fix for 64-bit types passed to
*printf.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop ed1401a7f -> 09e50c6a0
Fix for 64-bit types passed to *printf.
The va_arg macro from newlib seems to have issues with 64-bit values; it
was reading from the wrong memory location. The temporary fix is to
pull the 64-bit number off the stack as a pair of 32-bit integers.
We need to look into why this is necessary. It may just be an incorrect
setting specified when the compiler / newlib was built.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/09e50c6a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/09e50c6a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/09e50c6a
Branch: refs/heads/develop
Commit: 09e50c6a08883bdc284fca54e13995b9a4b1a799
Parents: ed1401a
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Apr 14 16:37:26 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Apr 14 16:41:06 2016 -0700
----------------------------------------------------------------------
libs/baselibc/src/tinyprintf.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/09e50c6a/libs/baselibc/src/tinyprintf.c
----------------------------------------------------------------------
diff --git a/libs/baselibc/src/tinyprintf.c b/libs/baselibc/src/tinyprintf.c
index 42bd7cd..e48be4a 100644
--- a/libs/baselibc/src/tinyprintf.c
+++ b/libs/baselibc/src/tinyprintf.c
@@ -209,11 +209,15 @@ intarg(int lng, int sign, va_list *va)
case 2:
default:
- if (sign) {
- val = va_arg(*va, long long);
- } else {
- val = va_arg(*va, unsigned long long);
- }
+ /* Pull the 64-bit number off the stack as a pair of 32-bit integers.
+ * The va_arg macro was reading from the wrong location when a 64-bit
+ * type was specified.
+ */
+ /* XXX: Look into this; may just be an incorrect setting when the
+ * compiler / newlib was built.
+ */
+ val = va_arg(*va, unsigned long);
+ val |= (unsigned long long)(va_arg(*va, unsigned long)) << 32;
break;
}
@@ -226,7 +230,7 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va)
struct param p;
char bf[23];
char ch;
- char lng = 0;
+ char lng;
p.bf = bf;
@@ -239,6 +243,7 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va)
p.alt = 0;
p.width = 0;
p.sign = 0;
+ lng = 0;
/* Flags */
while ((ch = *(fmt++))) {