summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2013-06-11 11:14:38 -0700
committerTom Rini <trini@ti.com>2013-06-26 10:16:41 -0400
commitb8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58 (patch)
tree459c6fbd20218790caffe466f6c9f4b84fb4d785 /lib/vsprintf.c
parent5d3bd34545061ec665e64d7f5162fb5eef1e3001 (diff)
downloadu-boot-imx-b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58.zip
u-boot-imx-b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58.tar.gz
u-boot-imx-b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58.tar.bz2
Add function to print a number with grouped digits
Move bootstage's numbering printing code into a generic place so that it can be used by tracing also. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 533a96b..82e5c13 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -870,3 +870,19 @@ char *simple_itoa(ulong i)
} while (i > 0);
return p + 1;
}
+
+/* We don't seem to have %'d in U-Boot */
+void print_grouped_ull(unsigned long long int_val, int digits)
+{
+ char str[21], *s;
+ int grab = 3;
+
+ digits = (digits + 2) / 3;
+ sprintf(str, "%*llu", digits * 3, int_val);
+ for (s = str; *s; s += grab) {
+ if (s != str)
+ putc(s[-1] != ' ' ? ',' : ' ');
+ printf("%.*s", grab, s);
+ grab = 3;
+ }
+}