diff options
author | Karl Williamson <khw@cpan.org> | 2022-09-29 12:51:21 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-10-18 06:22:16 -0600 |
commit | 644641ff58ccf88bd860ef5517a40d1fb27bf022 (patch) | |
tree | ef894cfcba475a235aa64d806d1e1052e9695d9b /proto.h | |
parent | 1094750e0904f86121732c4af342fbdaccf70df3 (diff) | |
download | perl-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 'proto.h')
-rw-r--r-- | proto.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -7661,6 +7661,10 @@ PERL_CALLCONV SSize_t Perl_PerlIO_write(pTHX_ PerlIO *f, const void *vbuf, Size_ #define PERL_ARGS_ASSERT_PERLIO_WRITE \ assert(vbuf) #endif +#if defined(USE_PERL_SWITCH_LOCALE_CONTEXT) +PERL_CALLCONV void Perl_switch_locale_context(void); +#define PERL_ARGS_ASSERT_SWITCH_LOCALE_CONTEXT +#endif #if defined(USE_QUADMATH) PERL_CALLCONV bool Perl_quadmath_format_needed(const char* format) __attribute__visibility__("hidden"); |