1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-30 08:51:19 +01:00
RIOT/pkg/mpaland-printf/Makefile.include
Marian Buschsieweke 6d8233fa24
pkg/mpaland-printf: Add alternative stdio as package
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
2025-04-24 11:46:09 +02:00

18 lines
641 B
Makefile

# wrap stdio functions to use mpaland's printf instead of the one from the
# standard C lib
LINKFLAGS += -Wl,-wrap=printf
LINKFLAGS += -Wl,-wrap=sprintf
LINKFLAGS += -Wl,-wrap=snprintf
LINKFLAGS += -Wl,-wrap=vprintf
LINKFLAGS += -Wl,-wrap=vsnprintf
LINKFLAGS += -Wl,-wrap=putchar
LINKFLAGS += -Wl,-wrap=puts
# Workaround for bug in the newlib headers shipped with e.g. Ubuntu 24.04 LTS
# not defining PRId64 / PRIu64 / PRIx64 / PRIo64 in <inttypes.h> due to an issue
# in <machine/_default_types.h>. Tested to cause no regression on fixed newlib
# headers.
ifneq (,$(filter newlib,$(FEATURES_USED)))
CFLAGS += -D__int64_t_defined=1
endif