From 05078517652ce875de9e5406b20ccfe92c714ec3 Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Thu, 18 Jan 2024 16:41:07 +0100 Subject: output/printhex: Allow to print 64-bit hex value on 64-bit make Signed-off-by: Helge Deller --- src/output.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index 9892ea7..351e91e 100644 --- a/src/output.c +++ b/src/output.c @@ -185,8 +185,12 @@ putsinglehex(struct putcinfo *action, u32 val, int uc) // Output an integer in hexadecimal with a specified width. static void -puthex(struct putcinfo *action, u32 val, int width, int uc) +puthex(struct putcinfo *action, u64 val, int width, int uc) { + if (width > 8) { + width -= 8; + puthex(action, val >> 32, width, uc); + } switch (width) { default: putsinglehex(action, (val >> 28) & 0xf, uc); case 7: putsinglehex(action, (val >> 24) & 0xf, uc); @@ -246,7 +250,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) const char *n = s+1; int field_width = 0; char padchar = ' '; +#ifdef __LP64__ + u8 is64 = 1; +#else u8 is64 = 0; +#endif for (;;) { c = GET_GLOBAL(*(u8*)n); if (!isdigit(c)) @@ -267,7 +275,7 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) n++; c = GET_GLOBAL(*(u8*)n); } - s32 val; + s32 val = 0; s64 val64; const char *sarg; switch (c) { @@ -293,7 +301,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) putuint(action, val64); break; case 'p': +#ifdef __LP64__ + val64 = va_arg(args, s64); +#else val = va_arg(args, s32); +#endif if (!MODESEGMENT && GET_GLOBAL(*(u8*)(n+1)) == 'P') { // %pP is 'struct pci_device' printer put_pci_device(action, (void*)val); @@ -302,7 +314,11 @@ bvprintf(struct putcinfo *action, const char *fmt, va_list args) } putc(action, '0'); putc(action, 'x'); +#ifdef __LP64__ + puthex(action, val64, 16, 0); +#else puthex(action, val, 8, 0); +#endif break; case 'X': case 'x': -- cgit v1.1