973487fdad
Add support for 64 bit conversions in a uniformly expressable way by printing values backwards into a buffer on the stack first. This allows all operations to work on the low bits of the value and so the code doesn't need to care (beyond the size of that buffer) about the word size. This trick also doesn't care about the specifics of the base value, so in the process this unifies the decimal and hex printk conversion code to a single function. This comes at a mild cost in CPU cycles to the decimal converter and somewhat higher cost to hex (because it's now doing a full div/mod operation instead of shifting and masking). And stack usage has grown by a few words to hold the temporary. But the benefits in code size are substantial (e.g. ~250 bytes of .text on arm32). Note that this also contains a change to tests/kernel/common to address what appears to have been a bug in the original converters. The printk test uses a format string that looks like "%-4x%-2p" and feeds it the literal arguments "0xABCDEF" and "(char *)42". Now... clearly both those results are going to overflow the 4 and 2-byte field sizes, so there shouldn't be any whitespace between these fields. But the test was written to expect two spaces, inexplicably (yes, I checked: POSIX-compatible printf implementations don't have those spaces either). The new code is definitely doing the right thing, so fix the test instead. Signed-off-by: Andy Ross <andrew.j.ross@intel.com> |
||
---|---|---|
.. | ||
assert.c | ||
base64.c | ||
CMakeLists.txt | ||
crc7_sw.c | ||
crc8_sw.c | ||
crc16_sw.c | ||
crc32_sw.c | ||
dec.c | ||
fdtable.c | ||
heap-validate.c | ||
heap.c | ||
heap.h | ||
hex.c | ||
json.c | ||
Kconfig | ||
mempool.c | ||
mutex.c | ||
notify.c | ||
onoff.c | ||
printk.c | ||
rb.c | ||
ring_buffer.c | ||
sem.c | ||
thread_entry.c | ||
timeutil.c | ||
work_q.c |