From 5a53bf3882284a78c3cb93c541fb981f5e9bf4b8 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 18 Mar 2018 12:39:47 -0600 Subject: Fix locale problems on mingw Various symbols get exported (or not) by makedef.pl. The determination of some of the new ones is fairly complex in perl.h, and unfortunately in general the code logic to do so must be copied into makedef.pl (until a volunteer fixes this). I thought I could avoid a bunch of this by using the symbol ${^SAFE_LOCALES} which in fact was created so that programs wouldn't have to know about this complexity. The problem is that on Windows, miniperl is always compiled single-thread and so locales are always safe, and so makedef.pl (which is called by miniperl) got the wrong information. The solution, unfortunately, is to reproduce the complexity in makedef.pl Spotted by Daniel Dragan. --- makedef.pl | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'makedef.pl') diff --git a/makedef.pl b/makedef.pl index 88273e5305..f2beb94020 100644 --- a/makedef.pl +++ b/makedef.pl @@ -129,6 +129,32 @@ if ($define{USE_ITHREADS} && $ARGS{PLATFORM} ne 'win32' && $ARGS{PLATFORM} ne 'n $define{USE_REENTRANT_API} = 1; } +if ( $define{USE_ITHREADS} + && $define{HAS_SETLOCALE} + && ! $define{NO_LOCALE} + && ! $define{NO_POSIX_2008_LOCALE}) +{ + $define{HAS_POSIX_2008_LOCALE} = 1 if $define{HAS_NEWLOCALE} + && $define{HAS_FREELOCALE} + && $define{HAS_USELOCALE}; + my $cctype = $ARGS{CCTYPE} =~ s/MSVC//r; + if ( ! $define{NO_THREAD_SAFE_LOCALE} + && ( $define{HAS_POSIX_2008_LOCALE} + || ($ARGS{PLATFORM} eq 'win32' && ( $cctype !~ /\D/ + && $cctype >= 80)))) + { + $define{USE_THREAD_SAFE_LOCALE} = 1; + $define{USE_POSIX_2008_LOCALE} = 1 if $define{HAS_POSIX_2008_LOCALE}; + } + + if ( $ARGS{PLATFORM} eq 'win32' + && $define{USE_THREAD_SAFE_LOCALE} + && $cctype < 140) + { + $define{TS_W32_BROKEN_LOCALECONV} = 1; + } +} + # perl.h logic duplication ends print STDERR "Defines: (" . join(' ', sort keys %define) . ")\n" @@ -438,12 +464,12 @@ unless ($define{'PERL_IMPLICIT_CONTEXT'}) { ); } -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; +if ($define{USE_THREAD_SAFE_LOCALE}) { ++$skip{PL_lc_numeric_mutex}; ++$skip{PL_lc_numeric_mutex_depth}; + if (! $define{TS_W32_BROKEN_LOCALECONV}) { + ++$skip{PL_locale_mutex}; + } } unless ($define{'PERL_OP_PARENT'}) { -- cgit v1.2.1