Re: [PATCH] Fix stdio init handling
Sebastian Huber <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
Hello Hans-Peter,
sorry for breaking your Newlib configuration. I was able to reproduce
the issue in RTEMS with a corresponding configuration. The problem
didn't show up in our tests since in RTEMS __getreent() returns a
thread-specific reentrancy structure. With
struct _reent *
__getreent (void)
{
return _impure_ptr;
}
your test case reproduced the issue. Could you please try the attached
patch?
We would like to introduce a configuration option for Newlib to use
thread-local storage for the members of struct _reent:
https://sourceware.org/pipermail/newlib/2022/018855.html
With this option, struct _reent is not defined, so using members of
_GLOBAL_REENT to maintain global Newlib state would not work. This is
why we tried to use dedicated global objects for the FILE object list
and the exit handlers.
We also would like to make the _REENT_GLOBAL_STDIO_STREAMS option the
default Newlib behaviour:
https://sourceware.org/pipermail/newlib/2022/019735.html
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: [email protected]
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
0001-Fix-__sglue-inititialization.patch
(text/x-patch, 991 B)
From 9629ec0b7a2e657d693960269506fcc6c715c6ff Mon Sep 17 00:00:00 2001 From: Sebastian Huber <[email protected]> Date: Tue, 7 Jun 2022 07:55:02 +0200 Subject: [PATCH] Fix __sglue inititialization Do not initialize __sglue with the FILE objects of _GLOBAL_REENT to avoid a double use in the !_REENT_SMALL and !_REENT_GLOBAL_STDIO_STREAMS configurations which didn't use a thread-specific reentrancy structure. --- newlib/libc/stdio/findfp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index 6933ff1db..ff6804d19 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -41,11 +41,7 @@ const struct __sFILE_fake __sf_fake_stderr = __FILE __sf[3]; struct _glue __sglue = {NULL, 3, &__sf[0]}; #else -#ifdef _REENT_SMALL struct _glue __sglue = {NULL, 0, NULL}; -#else -struct _glue __sglue = {NULL, 3, &_GLOBAL_REENT->__sf[0]}; -#endif #endif #ifdef _STDIO_BSD_SEMANTICS -- 2.35.3