From 69c5e0dbc1d307bce522321a107ca1670ec89f2c Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 9 Mar 2018 12:53:13 -0700 Subject: Work around Microsoft threaded locale bug for localeconv() Prior to Visual Studio 2015, the localeconv() function only looks at the global locale, not the per-thread one it should. This works around this by creating critical sections, switching to the global locale to call localeconv(), then switching back. For the most common usage, it avoids the switch by parsing a string it generates that should contain the desired substring. This leaves the switch required for retrieving the floating point grouping separator and the currency string, plus POSIX::localeconv(). The first two could be avoided by extra code as detailed in the pod for switch_to_global_locale(); patches welcome! --- makedef.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'makedef.pl') diff --git a/makedef.pl b/makedef.pl index 417fcd746b..a339059278 100644 --- a/makedef.pl +++ b/makedef.pl @@ -437,8 +437,10 @@ unless ($define{'PERL_IMPLICIT_CONTEXT'}) { ); } -if (${^SAFE_LOCALES}) { - ++$skip{PL_locale_mutex}; +if (${^SAFE_LOCALES}) { # Don't need mutexes if have thread-safe operations + # except early versions of Windows need this one + ++$skip{PL_locale_mutex} unless $ARGS{PLATFORM} eq 'win32' + && ($ARGS{CCTYPE} =~ s/MSVC//r) < 140; ++$skip{PL_lc_numeric_mutex}; } -- cgit v1.2.1