summaryrefslogtreecommitdiff
path: root/lib_generic
diff options
context:
space:
mode:
authorJames Yang <james.yang@freescale.com>2008-01-10 16:02:07 -0600
committerWolfgang Denk <wd@denx.de>2008-01-12 00:31:01 +0100
commitbf05293973b348f6946c9df92cd3c65ece42d0be (patch)
tree88e3204457132705db487fb7107bbe66789f2443 /lib_generic
parent92fa37eac530860643afa26ae347af3d23d67309 (diff)
downloadu-boot-bf05293973b348f6946c9df92cd3c65ece42d0be.tar.gz
u-boot-bf05293973b348f6946c9df92cd3c65ece42d0be.tar.bz2
u-boot-bf05293973b348f6946c9df92cd3c65ece42d0be.zip
Fix 64-bit vsprintf.
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>
Diffstat (limited to 'lib_generic')
-rw-r--r--lib_generic/vsprintf.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib_generic/vsprintf.c b/lib_generic/vsprintf.c
index 2740f2e769..3db6c3f936 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;
}