summaryrefslogtreecommitdiff
path: root/embed.fnc
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-03-14 05:29:23 -0600
committerKarl Williamson <khw@cpan.org>2022-09-21 14:34:41 -0600
commit58b390f21b8cbcf54ebe4dfb3786c00da473edd5 (patch)
tree682dc59ec979dd16fdda052f516842cc8e49d9d2 /embed.fnc
parentf1de0f2a33b57c805290af7c97098f49fe272711 (diff)
downloadperl-58b390f21b8cbcf54ebe4dfb3786c00da473edd5.tar.gz
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.
Diffstat (limited to 'embed.fnc')
-rw-r--r--embed.fnc15
1 files changed, 15 insertions, 0 deletions
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