zephyr/lib/os
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
..
assert.c assert: Completely remove file info and condition expression 2020-01-13 13:59:55 +01:00
base64.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
CMakeLists.txt lib/os: Add sys_heap, a new/simpler/faster memory allocator 2020-04-14 10:05:55 -07:00
crc7_sw.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
crc8_sw.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
crc16_sw.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
crc32_sw.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
dec.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
fdtable.c fdtable: init fd context objects 2020-06-03 22:33:32 +02:00
heap-validate.c sys_heap: reduce the size of struct z_heap_bucket by half 2020-06-21 19:25:35 +02:00
heap.c lib/os/heap: some code simplification in sys_heap_aligned_alloc() 2020-06-24 11:53:50 -07:00
heap.h lib/os/heap: Add sys_heap_aligned_alloc() 2020-06-22 14:54:04 -04:00
hex.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
json.c json: Add top-level array encoding support 2020-06-19 18:21:27 +02:00
Kconfig lib/os: Rework/shrink printk conversions, add 64 bit support 2020-06-24 13:43:40 -07:00
mempool.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
mutex.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
notify.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
onoff.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
printk.c lib/os: Rework/shrink printk conversions, add 64 bit support 2020-06-24 13:43:40 -07:00
rb.c cleanup: include/: move misc/rb.h to sys/rb.h 2019-06-27 22:55:49 -04:00
ring_buffer.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
sem.c kernel/timeout: Make timeout arguments an opaque type 2020-03-31 19:40:47 -04:00
thread_entry.c lib: os: remove dead code 2019-06-18 09:08:01 -04:00
timeutil.c zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
work_q.c global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00