diff options
author | Simon Glass <sjg@chromium.org> | 2013-06-11 11:14:38 -0700 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2013-06-26 10:16:41 -0400 |
commit | b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58 (patch) | |
tree | 459c6fbd20218790caffe466f6c9f4b84fb4d785 /lib | |
parent | 5d3bd34545061ec665e64d7f5162fb5eef1e3001 (diff) | |
download | u-boot-midas-b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58.tar.gz u-boot-midas-b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58.tar.bz2 u-boot-midas-b8bcaa3ad393c34b7cdd9c8dcd9e9b82e2a34c58.zip |
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')
-rw-r--r-- | lib/vsprintf.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 533a96b85e..82e5c13653 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; + } +} |