From b651b297513c3dfdaaccab2534ff5ab5efbaacf3 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 20 Oct 2021 11:21:57 +0200 Subject: [PATCH] sys/picolibc_syscalls_default: make stdin and stderr strong refs --- sys/picolibc_syscalls_default/syscalls.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/picolibc_syscalls_default/syscalls.c b/sys/picolibc_syscalls_default/syscalls.c index a28ec23678..2e4c430852 100644 --- a/sys/picolibc_syscalls_default/syscalls.c +++ b/sys/picolibc_syscalls_default/syscalls.c @@ -236,9 +236,18 @@ FILE picolibc_stdio = FDEV_SETUP_STREAM(picolibc_put, picolibc_get, picolibc_flush, _FDEV_SETUP_RW); #ifdef PICOLIBC_STDIO_GLOBALS -FILE *const stdout = &picolibc_stdio; +#ifdef __strong_reference +/* This saves two const pointers. + * See https://github.com/RIOT-OS/RIOT/pull/17001#issuecomment-945936918 + */ +#define STDIO_ALIAS(x) __strong_reference(stdin, x); +#else +#define STDIO_ALIAS(x) FILE *const x = &__picolibc_stdio; +#endif + FILE *const stdin = &picolibc_stdio; -FILE *const stderr = &picolibc_stdio; +STDIO_ALIAS(stdout); +STDIO_ALIAS(stderr); #else FILE *const __iob[] = { &picolibc_stdio, /* stdin */