newlib-cygwin/newlib/libc/include/sys
Sebastian Huber b0cb9f85ca Use global stdio streams for all configurations
The _REENT_GLOBAL_STDIO_STREAMS was introduced by commit
668a4c8722 in 2017.  Since then it was enabled by
default for RTEMS.  Recently, the option was enabled for Cygwin which
previously used an alternative implementation to use global stdio streams.

In Newlib, the stdio streams are defined to thread-specific pointers
_reent::_stdin, _reent::_stdout and _reent::_stderr.  If the option is disabled
(the default for most systems), then these pointers are initialized to
thread-specific FILE objects which use file descriptors 0, 1, and 2,
respectively.  There are at least three problems with this:

(1) The thread-specific FILE objects are closed by _reclaim_reent().  This
    leads to problems with language run-time libraries that provide wrappers to
    the C/POSIX stdio streams (for example C++ and Ada), since they use the
    thread-specific FILE objects of the initialization thread.  In case the
    initialization thread is deleted, then they use freed memory.

(2) Since thread-specific FILE objects are used with a common output device via
    file descriptors 0, 1 and 2, the locking at FILE object level cannot ensure
    atomicity of the output, e.g. a call to printf().

(3) There are resource managment issues, see:

    https://sourceware.org/pipermail/newlib/2022/019558.html

    https://bugs.linaro.org/show_bug.cgi?id=5841

This patch enables the _REENT_GLOBAL_STDIO_STREAMS behaviour for all Newlib
configurations and removes the option.  This removes a couple of #ifdef blocks.
2022-06-10 20:13:52 +02:00
..
_default_fcntl.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
_intsup.h Support calculation of pointer size for __int20__ type in _intsup.h 2019-06-25 13:37:16 -04:00
_locale.h Rename <xlocale.h> back to <sys/_locale.h> 2019-06-14 10:02:08 +02:00
_pthreadtypes.h Fix guard for siginfo_t and pthread_t definition 2017-06-19 13:00:05 +02:00
_sigset.h FreeBSD compatibility for <sys/select.h> 2015-12-14 15:39:44 +01:00
_stdint.h Provide __intmax_t and __uintmax_t 2016-10-25 16:24:05 +02:00
_timespec.h Synchronize <sys/_timespec.h> with FreeBSD 2019-11-04 07:03:15 +01:00
_timeval.h Move timeval macros to <sys/time.h> 2019-11-04 07:03:15 +01:00
_types.h Fix <sys/_types.h> issues with <stddef.h> 2019-06-03 10:20:15 +02:00
_tz_structs.h libc/time: Move internal newlib tz-structs into own header 2020-10-15 16:59:51 +02:00
cdefs.h amd64: prevent KCSan false positives on LAPIC mapping 2020-10-26 14:18:46 +01:00
config.h Use global stdio streams for all configurations 2022-06-10 20:13:52 +02:00
custom_file.h
dir.h * libc/include/sys/dir.h: New BSD-compatibility header. 2010-08-11 18:14:54 +00:00
dirent.h
errno.h ansification: remove _PARAMS 2018-01-17 11:47:13 -06:00
fcntl.h
features.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
fenv.h Add default implementation of fenv.h and all methods 2019-08-09 17:49:16 +02:00
file.h
iconvnls.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
lock.h ansification: remove _CAST_VOID 2018-01-17 11:47:17 -06:00
param.h Move fd_stuff from sys/types.h to sys/select.h 2015-12-07 16:28:22 +01:00
queue.h This commit brings in a new refactored TCP stack called Rack. 2018-08-24 15:00:04 +02:00
reent.h Use global stdio streams for all configurations 2022-06-10 20:13:52 +02:00
resource.h ansification: remove _EXFUN, _EXFUN_NOTHROW 2018-01-17 11:47:29 -06:00
sched.h Add and use latest <sys/timespec.h> from FreeBSD 2015-03-11 15:45:38 +01:00
select.h select.h: update FD macros to latest FreeBSD, fix type conversion warning 2020-08-03 12:41:45 +02:00
signal.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
stat.h Cygwin: simplify some function names 2022-05-29 17:45:52 -04:00
stdio.h ansification: remove _CAST_VOID 2018-01-17 11:47:17 -06:00
string.h
syslimits.h Use remove-advertising-clause script to edit BSD licenses 2020-01-29 19:03:31 +01:00
time.h Revert "sys/types.h: Don't include sys/_stdint.h" 2022-05-04 15:08:44 +02:00
timeb.h ansification: remove _PARAMS 2018-01-17 11:47:13 -06:00
times.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00
timespec.h Add and use latest <sys/timespec.h> from FreeBSD 2015-03-11 15:45:38 +01:00
tree.h sys/tree.h: Red child with black sibling rotations 2021-10-07 17:58:36 +02:00
types.h Revert "sys/types.h: Don't include sys/_stdint.h" 2022-05-04 15:08:44 +02:00
unistd.h Cygwin: simplify some function names 2022-05-29 17:45:52 -04:00
utime.h
wait.h change _COMPILING_NEWLIB to _LIBC 2021-11-15 19:32:23 -05:00