Skip to content

Commit

Permalink
Experimentally enable per-thread locale emulation
Browse files Browse the repository at this point in the history
This is set to end in 5.39.10, but will give us field experience in the
meantime.
  • Loading branch information
khwilliamson committed Nov 20, 2023
1 parent dd2cfc0 commit 542b7ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 5 additions & 3 deletions locale.c
Expand Up @@ -133,9 +133,11 @@
* expects. The perl core has made those changes, so pure perl programs
* become thread-safe. Well-behaved XS code also keeps things thread-safe,
* either by not using locale-dependent system calls, or by changing to use
* the wrapper macros. This layer is not chosen if the platform has native
* thread-safe locale handling. Also, currently perl must have been
* Configured with "-Accflags=-DEMULATE_THREAD_SAFE_LOCALES".
* the wrapper macros. This layer is chosen on threaded perls where the
* platform doesn't have working native thread-safe locale handling, and
* there is no manual override in Configure. To turn if off add these to
* the Configuration options:
-Accflags='-DNO_THREAD_SAFE_LOCALE'" -Accflags='-DNO_POSIX_2008_LOCALE'"
*
* This implementation is based on the observation that the underlying
* locale matters only to relatively few libc calls, and only during their
Expand Down
6 changes: 5 additions & 1 deletion makedef.pl
Expand Up @@ -180,6 +180,9 @@ BEGIN
{
$define{USE_THREAD_SAFE_LOCALE} = 1;
}
else {
$define{EMULATE_THREAD_SAFE_LOCALES} = 1;
}
}

if ($define{USE_POSIX_2008_LOCALE} && $define{HAS_QUERYLOCALE})
Expand All @@ -189,7 +192,8 @@ BEGIN
# Don't need glibc only code from perl.h
}

if ($define{USE_POSIX_2008_LOCALE} && ! $define{USE_QUERYLOCALE})
if ( ($define{USE_POSIX_2008_LOCALE} && ! $define{USE_QUERYLOCALE})
|| $define{EMULATE_THREAD_SAFE_LOCALES})
{
$define{USE_PL_CURLOCALES} = 1;
}
Expand Down
2 changes: 2 additions & 0 deletions perl.h
Expand Up @@ -1251,6 +1251,8 @@ typedef enum {
# if defined(USE_POSIX_2008_LOCALE) \
|| (defined(WIN32) && (defined(_MSC_VER) || (defined(_UCRT))))
# define USE_THREAD_SAFE_LOCALE
# else
# define EMULATE_THREAD_SAFE_LOCALES
# endif
# endif

Expand Down

0 comments on commit 542b7ff

Please sign in to comment.