From 58b390f21b8cbcf54ebe4dfb3786c00da473edd5 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 14 Mar 2021 05:29:23 -0600 Subject: locale.c: Mitigate unsafe threaded locales This a new set of macros and functions to do locale changing and querying for platforms where perl is compiled with threads, but the platform doesn't have thread-safe locale handling. All it does is: 1) The return of setlocale() is always safely saved in a per-thread buffer, and 2) setlocale() is protected by a mutex from other threads which are using perl's locale functions. This isn't much, but it might be enough to get some programs to work on such platforms which rarely change or query the locale. --- embed.fnc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'embed.fnc') diff --git a/embed.fnc b/embed.fnc index 4d533195cc..4d95a82187 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3382,6 +3382,21 @@ S |const char*|update_PL_curlocales_i|const unsigned int index \ |recalc_lc_all_t recalc_LC_ALL S |const char *|find_locale_from_environment|const unsigned int index # endif +# else +# if defined(USE_LOCALE_THREADS) \ + && ! defined(USE_THREAD_SAFE_LOCALE) \ + && ! defined(USE_THREAD_SAFE_LOCALE_EMULATION) +S |const char *|less_dicey_setlocale_r \ + |const int category \ + |NULLOK const char * locale +S |bool |less_dicey_bool_setlocale_r \ + |const int cat \ + |NN const char * locale +S |void |less_dicey_void_setlocale_i \ + |const unsigned cat_index \ + |NN const char * locale \ + |const line_t line +# endif # endif # if defined(USE_POSIX_2008_LOCALE) && defined(USE_QUERYLOCALE) S |const char *|calculate_LC_ALL|const locale_t cur_obj -- cgit v1.2.1