-
Notifications
You must be signed in to change notification settings - Fork 2.1k
pkg/mpaland-printf: Add alternative stdio as package #20664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
11a1309
to
817c8ff
Compare
817c8ff
to
27a620b
Compare
cf84d13
to
a8ffaeb
Compare
I'll try and take a look at this later since I am familiar with the pkg already. |
Started looking this over, but ran out of time. I'll pick it up another night. |
For me, the new test would not build when doing diff --git a/tests/sys/snprintf/main.c b/tests/sys/snprintf/main.c
index 151966c0d5..0d27dca3cb 100644
--- a/tests/sys/snprintf/main.c
+++ b/tests/sys/snprintf/main.c
@@ -19,6 +19,7 @@
* @}
*/
+#define __int64_t_defined 1
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h> |
Thx for reporting. I can reproduce the issue on my Ubuntu machine. Can you give it another try with the fixup commit? |
pkg/mpaland-printf/patches/0003-RIOT-integration-Enable-floating-support-based-on-mo.patch
Outdated
Show resolved
Hide resolved
Indeed |
The newlib's stdio comes in two flavors: "super bloated" (stdio-nano), and "supermassive black hole of bloat" (regular stdio). The latter would pass the stido unit tests (try disabled newlib_nano), if it would even fit your MCU's flash and RAM. The former is a stripped down version of the latter, trading features (in other words compatibility with format specifiers) for size. Both are way too large to be a sane option on MCUs. That is why the picolibs fork of newlib just trashed the stdio and replaces it with something that does make sense on MCUs. |
848fa62
to
16dc151
Compare
16dc151
to
557ff9e
Compare
This packs the stdio implementation from [1] as alternative to what the used standard C lib provides with the intent to provide a thread-safe, smaller, and more feature-complete alternative on newlib targets. Compared to `newlib_nano` this reduces `.text` by a bit more than 200 B while adding support for standard format specifiers such as `RPIu8`, `PRIu16`, `PRIu64`, `%z`, and `%t`. Note that `newlib_nano`'s stdio can be thread-safe in reentrant mode at the cost of RAM (per thread) and latency. Especially the increase in latency can be prohibitive when real time requirements need to be met. [1]: https://github.com/mpaland/printf
This adds a simple test applications that runs snprintf on standard format specifiers and compares the output with the expected output. The assumption is that internally every stdio implementation uses the same formatting code for each member of the printf functions family, so testing snprintf only is sufficient.
533fa86
to
42dacd7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having patches in git is giving me Quilt-PTSD, but I get why. I just hate it.
Thx :-) |
Contribution description
This packs the stdio implementation from https://github.com/mpaland/printf as alternative to what the used standard C lib provides with the intent to provide a thread-safe, smaller, and more feature-complete alternative on newlib targets.
Compared to
newlib_nano
this reduces.text
by a bit more than 200 B while adding support for standard format specifiers such asRPIu8
,PRIu16
,PRIu64
,%z
, and%t
.Note that
newlib_nano
's stdio can be thread-safe in reentrant mode at the cost of RAM (per thread) and latency. Especially the increase in latency can be prohibitive when real time requirements need to be met.Testing procedure
A test application has been added in
tests/sys/snprintf
. This will use the package ifnewlib
is used. It should pass, but removingMakefile.board.dep
(which pulls in thempaland-printf
package) should a failing test.Issues/PRs references
#20361