summaryrefslogtreecommitdiff
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-10-21 18:51:33 +0000
committerWolfgang Denk <wd@denx.de>2011-10-26 21:32:15 +0200
commit3cce8a5496452285e1828984ad3945417205cfc3 (patch)
treeef8158e41e224c5446c70fe888e69f8d969d58ed /lib/vsprintf.c
parent70d52f9a4e661f00814ed2160bdedd3cc49aa44c (diff)
downloadu-boot-imx-3cce8a5496452285e1828984ad3945417205cfc3.zip
u-boot-imx-3cce8a5496452285e1828984ad3945417205cfc3.tar.gz
u-boot-imx-3cce8a5496452285e1828984ad3945417205cfc3.tar.bz2
Move simple_itoa to vsprintf
This function is generally useful and shouldn't hide away in hush. It has been moved as is. 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 79dead3..e497a86 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -7,6 +7,8 @@
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
+ *
+ * from hush: simple_itoa() was lifted from boa-0.93.15
*/
#include <stdarg.h>
@@ -738,3 +740,17 @@ void __assert_fail(const char *assertion, const char *file, unsigned line,
panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
assertion);
}
+
+char *simple_itoa(ulong i)
+{
+ /* 21 digits plus null terminator, good for 64-bit or smaller ints */
+ static char local[22];
+ char *p = &local[21];
+
+ *p-- = '\0';
+ do {
+ *p-- = '0' + i % 10;
+ i /= 10;
+ } while (i > 0);
+ return p + 1;
+}