From c764fb20122e7f6cb88855d4f671611aeb76df76 Mon Sep 17 00:00:00 2001 From: Jacob Garber Date: Wed, 3 Jul 2019 12:38:46 -0600 Subject: console: Implement j specifier in vtxprintf() It is occasionally useful to print a uintmax_t or intmax_t, so add support for the j specifier. This also makes defining the PRI* macros in simpler. Change-Id: I656e3992029199b48e62a9df2d56f54c34e4e10f Signed-off-by: Jacob Garber Reviewed-on: https://review.coreboot.org/c/coreboot/+/34027 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber Reviewed-by: Paul Menzel Reviewed-by: HAOUAS Elyes --- src/console/vtxprintf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/console') diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c index 2d4953d013..b50f3987a5 100644 --- a/src/console/vtxprintf.c +++ b/src/console/vtxprintf.c @@ -18,6 +18,7 @@ #include #include #include +#include #define call_tx(x) tx_byte(x, data) @@ -136,7 +137,7 @@ int vtxprintf(void (*tx_byte)(unsigned char byte, void *data), int field_width; /* width of output field */ int precision; /* min. # of digits for integers; max number of chars for from string */ - int qualifier; /* 'h', 'H', 'l', or 'L' for integer fields */ + int qualifier; /* 'h', 'H', 'l', 'L', 'z', or 'j' for integer fields */ int count; @@ -190,7 +191,7 @@ repeat: /* get the conversion qualifier */ qualifier = -1; - if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'z') { + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'z' || *fmt == 'j') { qualifier = *fmt; ++fmt; if (*fmt == 'l') { @@ -291,6 +292,8 @@ repeat: num = va_arg(args, unsigned long); } else if (qualifier == 'z') { num = va_arg(args, size_t); + } else if (qualifier == 'j') { + num = va_arg(args, uintmax_t); } else if (qualifier == 'h') { num = (unsigned short) va_arg(args, int); if (flags & SIGN) -- cgit v1.2.3