mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 10:39:08 +00:00
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>
This commit is contained in:
parent
5d3bd34545
commit
b8bcaa3ad3
3 changed files with 31 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue