diff options
author | Karl Williamson <khw@cpan.org> | 2021-02-10 07:09:06 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-06-16 06:18:39 -0600 |
commit | 8751a11f7fafc4d656fe8f44ebc8b5233e437153 (patch) | |
tree | bcb103174a02cb8e30e5a361a769ab21b6a8ced0 | |
parent | 4fd76d49315684898364ca6c6de3d730748e85d4 (diff) | |
download | perl-8751a11f7fafc4d656fe8f44ebc8b5233e437153.tar.gz |
Add USE_LOCALE_THREADS #define
This is in preparation for supporting configurations where there threads
are available, but the locale handling code should ignore that fact.
This stems from the unusual locale handling of z/OS, where any attempt
is ignored to change locales after the first thread is created.
-rw-r--r-- | locale.c | 8 | ||||
-rw-r--r-- | makedef.pl | 8 | ||||
-rw-r--r-- | perl.h | 9 |
3 files changed, 15 insertions, 10 deletions
@@ -3540,7 +3540,7 @@ Perl_init_i18nl10n(pTHX_ int printwarn) for (i = 0; i < NOMINAL_LC_ALL_INDEX; i++) { -# if defined(USE_ITHREADS) && ! defined(USE_THREAD_SAFE_LOCALE) +# if defined(USE_LOCALE_THREADS) && ! defined(USE_THREAD_SAFE_LOCALE) /* This caches whether each category's locale is UTF-8 or not. This * may involve changing the locale. It is ok to do this at @@ -4440,7 +4440,7 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) int len; dSAVEDERRNO; -# if defined(HAS_MBRTOWC) && defined(USE_ITHREADS) +# if defined(HAS_MBRTOWC) && defined(USE_LOCALE_THREADS) mbstate_t ps; @@ -4450,7 +4450,7 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category) * character. Feed a byte string to one of them and check that the * result is the expected Unicode code point */ -# if defined(HAS_MBRTOWC) && defined(USE_ITHREADS) +# if defined(HAS_MBRTOWC) && defined(USE_LOCALE_THREADS) /* Prefer this function if available, as it's reentrant */ memzero(&ps, sizeof(ps));; @@ -4901,7 +4901,7 @@ Perl_my_strerror(pTHX_ const int errnum) const bool within_locale_scope = IN_LC(LC_MESSAGES); -# ifndef USE_ITHREADS +# ifndef USE_LOCALE_THREADS /* This function is trivial without threads. */ if (within_locale_scope) { diff --git a/makedef.pl b/makedef.pl index b1663b31e3..f5d98d1be1 100644 --- a/makedef.pl +++ b/makedef.pl @@ -140,11 +140,14 @@ if (! $define{NO_LOCALE}) { # https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering my $cctype = $ARGS{CCTYPE} =~ s/MSVC//r; +if ($define{USE_ITHREADS} && ! $define{NO_LOCALE_THREADS}) { + $define{USE_LOCALE_THREADS} = 1; +} if (! $define{HAS_SETLOCALE} && $define{HAS_POSIX_2008_LOCALE}) { $define{USE_POSIX_2008_LOCALE} = 1; $define{USE_THREAD_SAFE_LOCALE} = 1; } -elsif ( ($define{USE_ITHREADS} || $define{USE_THREAD_SAFE_LOCALE}) +elsif ( ($define{USE_LOCALE_THREADS} || $define{USE_THREAD_SAFE_LOCALE}) && ( $define{HAS_POSIX_2008_LOCALE} || ($ARGS{PLATFORM} eq 'win32' && ( $cctype !~ /\D/ && $cctype >= 80))) @@ -405,8 +408,7 @@ unless ($define{'USE_ITHREADS'}) { ); } -if ( $define{NO_LOCALE} - || (! $define{USE_ITHREADS} && ! $define{USE_THREAD_SAFE_LOCALE})) +unless ($define{USE_POSIX_2008_LOCALE}) { ++$skip{$_} foreach qw( PL_C_locale_obj @@ -1270,6 +1270,9 @@ violations are fatal. /* XXX The next few defines are unfortunately duplicated in makedef.pl, and * changes here MUST also be made there */ +# if defined(USE_ITHREADS) && ! defined(NO_LOCALE_THREADS) +# define USE_LOCALE_THREADS +# endif # if ! defined(HAS_SETLOCALE) && defined(HAS_POSIX_2008_LOCALE) # define USE_POSIX_2008_LOCALE # ifndef USE_THREAD_SAFE_LOCALE @@ -1278,7 +1281,7 @@ violations are fatal. /* If compiled with * -DUSE_THREAD_SAFE_LOCALE, will do so even * on unthreaded builds */ -# elif (defined(USE_ITHREADS) || defined(USE_THREAD_SAFE_LOCALE)) \ +# elif (defined(USE_LOCALE_THREADS) || defined(USE_THREAD_SAFE_LOCALE)) \ && ( defined(HAS_POSIX_2008_LOCALE) \ || (defined(WIN32) && defined(_MSC_VER))) \ && ! defined(NO_THREAD_SAFE_LOCALE) @@ -6842,7 +6845,7 @@ the plain locale pragma without a parameter (S<C<use locale>>) is in effect. /* Locale/thread synchronization macros. */ #if ! ( defined(USE_LOCALE) \ - && defined(USE_ITHREADS) \ + && defined(USE_LOCALE_THREADS) \ && ( ! defined(USE_THREAD_SAFE_LOCALE) \ || ( defined(HAS_LOCALECONV) \ && ( ! defined(HAS_LOCALECONV_L) \ @@ -7364,7 +7367,7 @@ cannot have changed since the precalculation. #endif /* !USE_LOCALE_NUMERIC */ -#ifdef USE_ITHREADS +#ifdef USE_LOCALE_THREADS # define ENV_LOCK PERL_WRITE_LOCK(&PL_env_mutex) # define ENV_UNLOCK PERL_WRITE_UNLOCK(&PL_env_mutex) # define ENV_READ_LOCK PERL_READ_LOCK(&PL_env_mutex) |