From 759c7595c906e336e398850cb0725ed9dc1e11e7 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 4 Apr 2023 16:18:58 -0600 Subject: [PATCH] XXX experimental: Define setlocale_i() on unsafe threaded builds On threaded Configurations where thread-safe locale handling is not available, perl automatically does a modicum of prevention of races by executing locale changes in a critical section, and copying the results to a thread-safe location. This commit defines setlocale_i() on such builds. This macro is used to bypass more complex handling required in fully thread-safe builds. I don't see how this changes thread-safeness on the unsafe builds, and it passes the tests, but I'm considering it experimental for now, until later in the development cycle. --- locale.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/locale.c b/locale.c index 46bb6bb36c19..1cc000314e88 100644 --- a/locale.c +++ b/locale.c @@ -2180,6 +2180,14 @@ S_less_dicey_bool_setlocale_r(pTHX_ const int cat, const char * locale) # define void_setlocale_c(cat, locale) void_setlocale_r(cat, locale) # define void_setlocale_i(i, locale) void_setlocale_r(categories[i], locale) +/*---------------------------------------------------------------------------*/ + +/* XXX unclear if should define this + * setlocale_i is only defined for Configurations where the libc setlocale() + * doesn't need any further tweaking (beyond that just above). It allows for + * some shortcuts */ +# define setlocale_i(i, locale) less_dicey_setlocale_r(categories[i], locale) + /*===========================================================================*/ #elif defined(USE_POSIX_2008_LOCALE)