mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-28 08:35:38 +00:00
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>
This commit is contained in:
parent
92fa37eac5
commit
bf05293973
1 changed files with 18 additions and 5 deletions
|
@ -105,17 +105,26 @@ static int skip_atoi(const char **s)
|
||||||
#define SPECIAL 32 /* 0x */
|
#define SPECIAL 32 /* 0x */
|
||||||
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
|
||||||
|
|
||||||
|
#ifdef CFG_64BIT_VSPRINTF
|
||||||
#define do_div(n,base) ({ \
|
#define do_div(n,base) ({ \
|
||||||
int __res; \
|
unsigned int __res; \
|
||||||
__res = ((unsigned long) n) % (unsigned) base; \
|
__res = ((unsigned long long) n) % base; \
|
||||||
n = ((unsigned long) n) / (unsigned) base; \
|
n = ((unsigned long long) n) / base; \
|
||||||
__res; \
|
__res; \
|
||||||
})
|
})
|
||||||
|
#else
|
||||||
|
#define do_div(n,base) ({ \
|
||||||
|
int __res; \
|
||||||
|
__res = ((unsigned long) n) % base; \
|
||||||
|
n = ((unsigned long) n) / base; \
|
||||||
|
__res; \
|
||||||
|
})
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_64BIT_VSPRINTF
|
#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
|
#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
|
#endif
|
||||||
{
|
{
|
||||||
char c,sign,tmp[66];
|
char c,sign,tmp[66];
|
||||||
|
@ -255,6 +264,10 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
||||||
qualifier = -1;
|
qualifier = -1;
|
||||||
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'q') {
|
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'q') {
|
||||||
qualifier = *fmt;
|
qualifier = *fmt;
|
||||||
|
if (qualifier == 'l' && *(fmt+1) == 'l') {
|
||||||
|
qualifier = 'q';
|
||||||
|
++fmt;
|
||||||
|
}
|
||||||
++fmt;
|
++fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue