From 542b7ff2f2228a6ad0aad47b34f55522781f912d Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 3 Nov 2023 12:45:11 -0600 Subject: [PATCH] Experimentally enable per-thread locale emulation This is set to end in 5.39.10, but will give us field experience in the meantime. --- locale.c | 8 +++++--- makedef.pl | 6 +++++- perl.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/locale.c b/locale.c index 158057ca17b7..e3e5724a89a0 100644 --- a/locale.c +++ b/locale.c @@ -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 diff --git a/makedef.pl b/makedef.pl index 5f335b40cc2e..74ad8d77ad57 100644 --- a/makedef.pl +++ b/makedef.pl @@ -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}) @@ -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; } diff --git a/perl.h b/perl.h index d1aac447387b..62bbc12f2b76 100644 --- a/perl.h +++ b/perl.h @@ -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