summaryrefslogtreecommitdiff
path: root/makedef.pl
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2018-03-09 12:53:13 -0700
committerKarl Williamson <khw@cpan.org>2018-03-12 10:22:01 -0600
commit69c5e0dbc1d307bce522321a107ca1670ec89f2c (patch)
treeb35d1255f5a3464b9a6efdaae219ec001a34dc31 /makedef.pl
parent6470dfd24226b0307246dd4530b5acd43c2ec134 (diff)
downloadperl-69c5e0dbc1d307bce522321a107ca1670ec89f2c.tar.gz
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!
Diffstat (limited to 'makedef.pl')
-rw-r--r--makedef.pl6
1 files changed, 4 insertions, 2 deletions
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};
}