newlib-cygwin/newlib/libc/locale
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
..
Makefile.inc newlib: libc: merge build up a directory 2022-03-16 21:18:25 -04:00
duplocale.c locale: remove TRAD_SYNOPSIS 2017-12-01 03:41:50 -06:00
freelocale.c locale: remove TRAD_SYNOPSIS 2017-12-01 03:41:50 -06:00
lctype.c Cygwin: fix LC_CTYPE in global locale to be a real C.UTF-8 locale 2022-12-03 16:16:30 +01:00
lmessages.c Remove non-working __part_load_locale function and any related code 2016-08-15 10:56:57 +02:00
lmonetary.c Remove non-working __part_load_locale function and any related code 2016-08-15 10:56:57 +02:00
lnumeric.c Remove non-working __part_load_locale function and any related code 2016-08-15 10:56:57 +02:00
locale.c setlocale: create LC_ALL string when changing locale 2023-02-06 16:04:33 +01:00
locale.tex Fix mismatched parentheses in documentation. 2015-06-24 12:23:25 +01:00
localeconv.c ansification: remove _DEFUN 2018-01-17 11:47:26 -06:00
newlocale.c newlocale: fix crash when trying to write to __C_locale 2022-08-12 12:29:26 +02:00
nl_langinfo.3
nl_langinfo.c nl_langinfo: Add NL_LOCALE_NAME macro 2017-01-20 10:30:47 +01:00
setlocale.h Cygwin: fix LC_CTYPE in global locale to be a real C.UTF-8 locale 2022-12-03 16:16:30 +01:00
timelocal.c Remove non-working __part_load_locale function and any related code 2016-08-15 10:56:57 +02:00
uselocale.c Add _REENT_LOCALE(ptr) 2022-07-13 06:55:46 +02:00