printf shrinkery


Andy Ross
 

Inspired by the printf discussion last week and no one's explicit
rejection of a quick code-size-reduction patch I threw out, I spent a
little more time in the minimal libc printf implementation, finding
stuff that can be removed or unified. Patch series in gerrit:

https://gerrit.zephyrproject.org/r/4007 libc/printf: Unify & simplify number printing
https://gerrit.zephyrproject.org/r/4102 libc/printf: Remove vestigial "full" parameter to _to_float()
https://gerrit.zephyrproject.org/r/4103 libc/printf: Use compiler-provided 64 bit math, phase 1
https://gerrit.zephyrproject.org/r/4104 libc/printf: Use compiler-provided 64 bit math, phase 2

There's the unified number-formatting code from before, and I
discovered that the floating point generation had a hand-coded 64 bit
math implementation that can be pretty easily replaced with
compiler-provied uint64_t math. Still passes sanitycheck, which
includes our existing sprintf test, plus all the stuff I could find or
hack to use as a unit test. Please review.

Total code savings for the whole patch series is ~400 bytes with no
loss of functionality, so not earthshattering but IMHO worth it. And
floating point output is almost certainly significantly faster, though
unmeasured.

Andy

Join devel@lists.zephyrproject.org to automatically receive all group messages.