Re: [PATCH v2] x86, boot: add hex output for debugging
From: Joe Perches
Date: Fri Oct 31 2014 - 20:03:30 EST
On Fri, 2014-10-31 at 16:45 -0700, Josh Triplett wrote:
> I don't think we need the full generality of printf in the decompression
> stub. I prefer Kees' patch, though I'd still like to see __puthex made
> conditional.
Maybe use a statement expression macro instead?
Something like this could emit the right number of bits for any type
#define __puthex(val) \
({ \
typeof(val) value = val; \
char alpha[2] = {}; \
int bits; \
\
__putstr("0x"); \
for (bits = sizeof(value) * 8 - 4; bits >= 0; bits -= 4) { \
int digit = (value >> bits) & 0xf; \
\
if (digit < 10) \
alpha[0] = '0' + digit; \
else \
alpha[0] = 'a' + (digit - 10); \
\
__putstr(alpha); \
} \
})
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/