[PATCH] Fix stdio init handling

Sebastian Huber sebastian.huber@embedded-brains.de
Tue Jun 7 06:18:49 GMT 2022


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: sebastian.huber@embedded-brains.de
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/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-__sglue-inititialization.patch
Type: text/x-patch
Size: 991 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/newlib/attachments/20220607/3179b8c3/attachment.bin>


More information about the Newlib mailing list