newlib-cygwin/newlib/libc
Corinna Vinschen 23e49b18ce setlocale: create LC_ALL string when changing locale
This patch is for the sake of gnulib.

gnulib implements some form of a thread-safe setlocale variant
called setlocale_null_r, which is supposed to return the locale
strings in a thread-safe manner.  This only succeeds if the system's
setlocale already handles this thread-safe, otherwise gnulib adds
some locking on its own.

Newlib's setlocale always writes the global string array holding the
LC_ALL value anew on each invocation of setlocale(LC_ALL, NULL).
Since that doesn't allow to call setlocale(LC_ALL, NULL) in a
thread-safe manner, so locking in gnulib is required.

And here's the problem...

The lock is decorated as dllexport when building for Cygwin.  This
collides with the default behaviour of ld to export all symbols.
If it finds one decorated symbol, it will only export this symbol
to the DLL import lib.

Change setlocale so that it writes the global string array
holding the LC_ALL value at the time the locale gets changed.
On setlocale(LC_ALL, NULL), just return the pointer to the
global LC_ALL string array, just as in GLibc.  The burden of
doing so is negligibly for all targets, but adds thread-safety
for gnulib's setlocal_null_r() function, and gnulib can drop
the lock entirely when building for Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-06 16:04:33 +01:00
..
argz newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
ctype Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
errno Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
iconv newlib: info: tweak iconv node to avoid collisions 2022-12-13 05:22:09 -05:00
include libc: arm: fix setjmp abi non-conformance 2022-12-13 15:50:35 +00:00
locale setlocale: create LC_ALL string when changing locale 2023-02-06 16:04:33 +01:00
machine libc: arm: Implement setjmp GCC backwards compatibility. 2023-02-03 13:07:08 +00:00
misc Remove __sinit_locks / __sinit_recursive_mutex 2022-05-13 12:31:56 +02:00
posix Fix some Coverity Scan errors. 2022-08-31 15:18:08 -04:00
reent Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
search newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
signal Add --enable-newlib-reent-thread-local option 2022-07-13 06:55:46 +02:00
ssp nvptx: Don't use global constructor for SSP setup 2023-01-19 21:51:09 +01:00
stdio Fix some Coverity Scan errors. 2022-08-31 15:18:08 -04:00
stdio64 Add _REENT_ERRNO(ptr) 2022-07-13 06:55:41 +02:00
stdlib Implement sysconf for Arm 2022-09-19 15:35:55 -04:00
string Fix memccpy to handle end char >= x80 2023-01-03 14:52:47 -05:00
sys libgloss: arm: break newlib dependency 2023-01-11 01:00:15 -05:00
syscalls newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
time strftime/wcsftime: use STRLEN, not strlen 2022-10-29 20:15:58 +02:00
unix newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
xdr newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
Makefile.inc Silence xsltproc when writing manpages 2022-05-04 17:05:52 -04:00
Makefile.unidata cleanup Unicode data files after generating updated tables 2021-11-16 11:24:29 +01:00
acinclude.m4 newlib: drop phoenix support 2022-03-28 23:17:06 -04:00
libc.in.xml Generate manpages for functions in chapter sys.tex 2022-05-04 17:06:19 -04:00
libc.texi newlib: info: tweak iconv node to avoid collisions 2022-12-13 05:22:09 -05:00
sys.tex Don't include stdio64 functions in reentrant syscalls menu when not bulding stdio64. 2015-08-03 09:54:33 +01:00