aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2024-01-18 16:41:07 +0100
committerHelge Deller <deller@gmx.de>2024-01-18 16:41:07 +0100
commit05078517652ce875de9e5406b20ccfe92c714ec3 (patch)
tree3c14ce0d39fbe9737f39d64da99316dcbac2ab4b
parentebd2a659c729c53451e6296ffa4cae5e36b58b64 (diff)
downloadseabios-hppa-05078517652ce875de9e5406b20ccfe92c714ec3.zip
seabios-hppa-05078517652ce875de9e5406b20ccfe92c714ec3.tar.gz
seabios-hppa-05078517652ce875de9e5406b20ccfe92c714ec3.tar.bz2
output/printhex: Allow to print 64-bit hex value on 64-bit make
Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r--src/output.c20
1 files 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':