summaryrefslogtreecommitdiff
path: root/lib/tiny-printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tiny-printf.c')
-rw-r--r--lib/tiny-printf.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index ebef92fc9f..1138c7012a 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -157,7 +157,8 @@ static void ip4_addr_string(struct printf_info *info, u8 *addr)
* decimal).
*/
-static void pointer(struct printf_info *info, const char *fmt, void *ptr)
+static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
+ void *ptr)
{
#ifdef DEBUG
unsigned long num = (uintptr_t)ptr;
@@ -266,6 +267,21 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
div_out(info, &num, div);
}
break;
+ case 'p':
+#ifdef DEBUG
+ pointer(info, fmt, va_arg(va, void *));
+ /*
+ * Skip this because it pulls in _ctype which is
+ * 256 bytes, and we don't generally implement
+ * pointer anyway
+ */
+ while (isalnum(fmt[0]))
+ fmt++;
+ break;
+#else
+ islong = true;
+ /* no break */
+#endif
case 'x':
if (islong) {
num = va_arg(va, unsigned long);
@@ -287,11 +303,6 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
case 's':
p = va_arg(va, char*);
break;
- case 'p':
- pointer(info, fmt, va_arg(va, void *));
- while (isalnum(fmt[0]))
- fmt++;
- break;
case '%':
out(info, '%');
default:
@@ -366,6 +377,22 @@ int sprintf(char *buf, const char *fmt, ...)
return ret;
}
+#if CONFIG_IS_ENABLED(LOG)
+/* Note that size is ignored */
+int vsnprintf(char *buf, size_t size, const char *fmt, va_list va)
+{
+ struct printf_info info;
+ int ret;
+
+ info.outstr = buf;
+ info.putc = putc_outstr;
+ ret = _vprintf(&info, fmt, va);
+ *info.outstr = '\0';
+
+ return ret;
+}
+#endif
+
/* Note that size is ignored */
int snprintf(char *buf, size_t size, const char *fmt, ...)
{
@@ -382,3 +409,9 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
return ret;
}
+
+void print_grouped_ull(unsigned long long int_val, int digits)
+{
+ /* Don't try to print the upper 32-bits */
+ printf("%ld ", (ulong)int_val);
+}