zephyr/lib
Andy Ross 973487fdad lib/os: Rework/shrink printk conversions, add 64 bit support
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>
2020-06-24 13:43:40 -07:00
..
cmsis_rtos_v1 zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
cmsis_rtos_v2 zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
fnmatch ext: lib: Move fnmatch to lib/ 2020-03-20 22:56:19 -04:00
gui zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
libc libc: newlib: libc-hooks: Provide our own implementation of __chk_fail() 2020-06-17 17:06:47 +02:00
open-amp lib: open-amp: add helper to add resource table in project 2020-04-01 09:21:15 -05:00
os lib/os: Rework/shrink printk conversions, add 64 bit support 2020-06-24 13:43:40 -07:00
posix lib: posix: eventfd: support build with !POSIX_API 2020-06-15 16:52:29 +02:00
updatehub lib: updatehub: Add download block check 2020-06-23 19:22:31 +02:00
CMakeLists.txt lib: open-amp: add helper to add resource table in project 2020-04-01 09:21:15 -05:00
Kconfig lib: open-amp: add helper to add resource table in project 2020-04-01 09:21:15 -05:00