Skip to content

Commit

Permalink
XXX experimental: Define setlocale_i() on unsafe threaded builds
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
khwilliamson committed May 21, 2023
1 parent c25ee55 commit 759c759
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions locale.c
Expand Up @@ -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)
Expand Down

0 comments on commit 759c759

Please sign in to comment.