summaryrefslogtreecommitdiff
path: root/embed.fnc
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-09-29 12:51:21 -0600
committerKarl Williamson <khw@cpan.org>2022-10-18 06:22:16 -0600
commit644641ff58ccf88bd860ef5517a40d1fb27bf022 (patch)
treeef894cfcba475a235aa64d806d1e1052e9695d9b /embed.fnc
parent1094750e0904f86121732c4af342fbdaccf70df3 (diff)
downloadperl-644641ff58ccf88bd860ef5517a40d1fb27bf022.tar.gz
Switch libc per-interpreter data when tTHX changes
As noted in the previous commit, some library functions now keep per-thread state. So far the only ones we care about are libc locale-changing ones. When perl changes threads by swapping out tTHX, those library functions need to be informed about the new value so that they remain in sync with what perl thinks the locale should be. This commit creates a function to do this, and changes the thread-changing macros to also call this as part of the change. For POSIX 2008, the function just calls uselocale() using the per-interpreter object introduced previously. For Windows, this commit adds a per-interpreter string of the current LC_ALL, and the function calls setlocale on that. We keep the same string for POSIX 2008 implementations that lack querylocale(), so this commit just enables that variable on Windows as well. The code is already in place to free the memory the string occupies when done. The commit also creates a mechanism to skip this during thread destruction. A thread in its death throes doesn't need to have accurate locale information, and the information needed to map from thread to what libc needs to know gets destroyed as part of those throes, while relics of the thread remain. I couldn't find a way to accurately know if we are dealing with a relic or not, so the solution I adopted was to just not switch during destruction. This commit completes fixing #20155.
Diffstat (limited to 'embed.fnc')
-rw-r--r--embed.fnc3
1 files changed, 3 insertions, 0 deletions
diff --git a/embed.fnc b/embed.fnc
index 7623b3c455..5aa07e1415 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1665,6 +1665,9 @@ Apd |void |switch_to_global_locale
Apd |bool |sync_locale
Apx |void |thread_locale_init
Apx |void |thread_locale_term
+#ifdef USE_PERL_SWITCH_LOCALE_CONTEXT
+CopT |void |switch_locale_context
+#endif
ApdO |void |require_pv |NN const char* pv
Apd |void |packlist |NN SV *cat|NN const char *pat|NN const char *patend|NN SV **beglist|NN SV **endlist
#if defined(PERL_USES_PL_PIDSTATUS) && defined(PERL_IN_UTIL_C)