Skip to content
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

pkg/mpaland-printf: Add alternative stdio as package #20664

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maribu
Copy link
Member

@maribu maribu commented May 11, 2024

Contribution description

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.

Testing procedure

A test application has been added in tests/sys/snprintf. This will use the package if newlib is used. It should pass, but removing Makefile.board.dep (which pulls in the mpaland-printf package) should a failing test.

Issues/PRs references

#20361

@maribu maribu added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 11, 2024
@github-actions github-actions bot added Area: doc Area: Documentation Area: build system Area: Build system labels May 11, 2024
@riot-ci
Copy link

riot-ci commented May 11, 2024

Murdock results

✔️ PASSED

a8ffaeb tests/sys/snprintf: Test format specifiers

Success Failures Total Runtime
10103 0 10104 14m:28s

Artifacts

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
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label May 11, 2024
@maribu maribu marked this pull request as ready for review May 11, 2024 20:56
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: doc Area: Documentation Area: pkg Area: External package ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants