]> git.sur5r.net Git - u-boot/blobdiff - lib_generic/vsprintf.c
esd WUH405 and DU405 board updated
[u-boot] / lib_generic / vsprintf.c
index d7a766157696f8d8d4026496051b4109cc004583..2740f2e769be35347805218919db4631df221312 100644 (file)
@@ -17,7 +17,8 @@
 #include <common.h>
 #if !defined (CONFIG_PANIC_HANG)
 #include <command.h>
-#include <cmd_boot.h>          /* for do_reset() prototype */
+/*cmd_boot.c*/
+extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
 #endif
 
 unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
@@ -54,6 +55,36 @@ long simple_strtol(const char *cp,char **endp,unsigned int base)
        return simple_strtoul(cp,endp,base);
 }
 
+#ifdef CFG_64BIT_STRTOUL
+unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int base)
+{
+       unsigned long long result = 0, value;
+
+       if (*cp == '0') {
+               cp++;
+               if ((*cp == 'x') && isxdigit (cp[1])) {
+                       base = 16;
+                       cp++;
+               }
+               if (!base) {
+                       base = 8;
+               }
+       }
+       if (!base) {
+               base = 10;
+       }
+       while (isxdigit (*cp) && (value = isdigit (*cp)
+                               ? *cp - '0'
+                               : (islower (*cp) ? toupper (*cp) : *cp) - 'A' + 10) < base) {
+               result = result * base + value;
+               cp++;
+       }
+       if (endp)
+               *endp = (char *) cp;
+       return result;
+}
+#endif /* CFG_64BIT_STRTOUL */
+
 /* we use this so that we can do without the ctype library */
 #define is_digit(c)    ((c) >= '0' && (c) <= '9')
 
@@ -75,13 +106,17 @@ static int skip_atoi(const char **s)
 #define LARGE  64              /* use 'ABCDEF' instead of 'abcdef' */
 
 #define do_div(n,base) ({ \
-int __res; \
-__res = ((unsigned long) n) % (unsigned) base; \
-n = ((unsigned long) n) / (unsigned) base; \
-__res; })
-
-static char * number(char * str, long num, int base, int size, int precision
-       ,int type)
+       int __res; \
+       __res = ((unsigned long) n) % (unsigned) base; \
+       n = ((unsigned long) n) / (unsigned) base; \
+       __res; \
+})
+
+#ifdef CFG_64BIT_VSPRINTF
+static char * number(char * str, long long num, int base, int size, int precision ,int type)
+#else
+static char * number(char * str, long num, int base, int size, int precision ,int type)
+#endif
 {
        char c,sign,tmp[66];
        const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
@@ -153,7 +188,11 @@ int sprintf(char * buf, const char *fmt, ...);
 int vsprintf(char *buf, const char *fmt, va_list args)
 {
        int len;
+#ifdef CFG_64BIT_VSPRINTF
+       unsigned long long num;
+#else
        unsigned long num;
+#endif
        int i, base;
        char * str;
        const char *s;
@@ -163,7 +202,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
        int field_width;        /* width of output field */
        int precision;          /* min. # of digits for integers; max
                                   number of chars for from string */
-       int qualifier;          /* 'h', 'l', or 'L' for integer fields */
+       int qualifier;          /* 'h', 'l', or 'q' for integer fields */
 
        for (str=buf ; *fmt ; ++fmt) {
                if (*fmt != '%') {
@@ -214,7 +253,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
 
                /* get the conversion qualifier */
                qualifier = -1;
-               if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
+               if (*fmt == 'h' || *fmt == 'l' || *fmt == 'q') {
                        qualifier = *fmt;
                        ++fmt;
                }
@@ -298,6 +337,11 @@ int vsprintf(char *buf, const char *fmt, va_list args)
                                --fmt;
                        continue;
                }
+#ifdef CFG_64BIT_VSPRINTF
+               if (qualifier == 'q')  /* "quad" for 64 bit variables */
+                       num = va_arg(args, unsigned long long);
+               else
+#endif
                if (qualifier == 'l')
                        num = va_arg(args, unsigned long);
                else if (qualifier == 'h') {
@@ -329,7 +373,7 @@ void panic(const char *fmt, ...)
 {
        va_list args;
        va_start(args, fmt);
-       printf(fmt);
+       vprintf(fmt, args);
        putc('\n');
        va_end(args);
 #if defined (CONFIG_PANIC_HANG)