public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Fix 64-bit vsprintf.
@ 2008-01-10 22:02 Jon Loeliger
  2008-01-11 23:31 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Jon Loeliger @ 2008-01-10 22:02 UTC (permalink / raw)
  To: u-boot

From: James Yang <james.yang@freescale.com>

There were some size and unsigned problems.
Also add support for "ll" size modifier in format string like glibc

Signed-off-by: James Yang <James.Yang@freescale.com>
Acked-by: Jon Loeliger <jdl@freescale.com>
---
 lib_generic/vsprintf.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/lib_generic/vsprintf.c b/lib_generic/vsprintf.c
index 2740f2e..3db6c3f 100644
--- a/lib_generic/vsprintf.c
+++ b/lib_generic/vsprintf.c
@@ -105,17 +105,26 @@ static int skip_atoi(const char **s)
 #define SPECIAL	32		/* 0x */
 #define LARGE	64		/* use 'ABCDEF' instead of 'abcdef' */
 
+#ifdef CFG_64BIT_VSPRINTF
+#define do_div(n,base) ({ \
+	unsigned int __res; \
+	__res = ((unsigned long long) n) % base; \
+	n = ((unsigned long long) n) / base; \
+	__res; \
+})
+#else
 #define do_div(n,base) ({ \
 	int __res; \
-	__res = ((unsigned long) n) % (unsigned) base; \
-	n = ((unsigned long) n) / (unsigned) base; \
+	__res = ((unsigned long) n) % base; \
+	n = ((unsigned long) n) / base; \
 	__res; \
 })
+#endif
 
 #ifdef CFG_64BIT_VSPRINTF
-static char * number(char * str, long long num, int base, int size, int precision ,int type)
+static char * number(char * str, long long num, unsigned int base, int size, int precision ,int type)
 #else
-static char * number(char * str, long num, int base, int size, int precision ,int type)
+static char * number(char * str, long num, unsigned int base, int size, int precision ,int type)
 #endif
 {
 	char c,sign,tmp[66];
@@ -255,6 +264,10 @@ int vsprintf(char *buf, const char *fmt, va_list args)
 		qualifier = -1;
 		if (*fmt == 'h' || *fmt == 'l' || *fmt == 'q') {
 			qualifier = *fmt;
+			if (qualifier == 'l' && *(fmt+1) == 'l') {
+				qualifier = 'q';
+				++fmt;
+			}
 			++fmt;
 		}
 
-- 
1.5.2.1.126.g6abd0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot-Users] [PATCH] Fix 64-bit vsprintf.
  2008-01-10 22:02 [U-Boot-Users] [PATCH] Fix 64-bit vsprintf Jon Loeliger
@ 2008-01-11 23:31 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2008-01-11 23:31 UTC (permalink / raw)
  To: u-boot

In message <1200002527.22619.51.camel@ld0161-tx32> you wrote:
> From: James Yang <james.yang@freescale.com>
> 
> There were some size and unsigned problems.
> Also add support for "ll" size modifier in format string like glibc
> 
> Signed-off-by: James Yang <James.Yang@freescale.com>
> Acked-by: Jon Loeliger <jdl@freescale.com>

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Systems programmers are the high priests of a low cult.
                                                       -- R.S. Barton

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-11 23:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-10 22:02 [U-Boot-Users] [PATCH] Fix 64-bit vsprintf Jon Loeliger
2008-01-11 23:31 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox