From e4b22cb7fc00a50270d8d791b4e67f718697b2dc Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 11 Jan 2023 16:08:02 -0700 Subject: [PATCH] Rename SETLOCALE_LOCK to LOCALE_LOCK This mutex isn't just about the setlocale function; it applies to all locale related critical sections. There are no uses of SETLOCALE_LOCK in CPAN --- locale.c | 8 ++++---- perl.h | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/locale.c b/locale.c index b005110982..9a3da0a595 100644 --- a/locale.c +++ b/locale.c @@ -6827,7 +6827,7 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness) } else { - SETLOCALE_LOCK; + LOCALE_LOCK; const char * orig_locale = toggle_locale_i(WHICH_LC_INDEX, "C"); @@ -6835,7 +6835,7 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness) restore_toggled_locale_i(WHICH_LC_INDEX, orig_locale); - SETLOCALE_UNLOCK; + LOCALE_UNLOCK; *utf8ness = UTF8NESS_IMMATERIAL; @@ -6865,7 +6865,7 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness) : "C"; /* XXX Can fail on z/OS */ - SETLOCALE_LOCK; + LOCALE_LOCK; const char* orig_CTYPE_locale = toggle_locale_c(LC_CTYPE, desired_locale); const char* orig_MESSAGES_locale = toggle_locale_c(LC_MESSAGES, @@ -6875,7 +6875,7 @@ Perl_my_strerror(pTHX_ const int errnum, utf8ness_t * utf8ness) restore_toggled_locale_c(LC_MESSAGES, orig_MESSAGES_locale); restore_toggled_locale_c(LC_CTYPE, orig_CTYPE_locale); - SETLOCALE_UNLOCK; + LOCALE_UNLOCK; *utf8ness = get_locale_string_utf8ness_i(errstr, LOCALE_UTF8NESS_UNKNOWN, NULL, LC_MESSAGES_INDEX_); diff --git a/perl.h b/perl.h index e001c8bd0e..f672053b72 100644 --- a/perl.h +++ b/perl.h @@ -7146,8 +7146,8 @@ the plain locale pragma without a parameter (S>) is in effect. /* By definition, a thread-unsafe locale means we need a critical * section. */ -# define SETLOCALE_LOCK LOCALE_LOCK_(0) -# define SETLOCALE_UNLOCK LOCALE_UNLOCK_ +# define LOCALE_LOCK LOCALE_LOCK_(0) +# define LOCALE_UNLOCK LOCALE_UNLOCK_ # ifdef USE_LOCALE_NUMERIC # define LC_NUMERIC_LOCK(cond_to_panic_if_already_locked) \ LOCALE_LOCK_(cond_to_panic_if_already_locked) @@ -7233,23 +7233,23 @@ the plain locale pragma without a parameter (S>) is in effect. * could change out from under us, we use an exclusive LOCALE lock to prevent * that, and a read ENV lock to prevent other threads that have nothing to do * with locales here from changing the environment. */ -#ifdef SETLOCALE_LOCK +#ifdef LOCALE_LOCK # define gwENVr_LOCALEr_LOCK \ - STMT_START { SETLOCALE_LOCK; ENV_READ_LOCK; } STMT_END + STMT_START { LOCALE_LOCK; ENV_READ_LOCK; } STMT_END # define gwENVr_LOCALEr_UNLOCK \ - STMT_START { ENV_READ_UNLOCK; SETLOCALE_UNLOCK; } STMT_END + STMT_START { ENV_READ_UNLOCK; LOCALE_UNLOCK; } STMT_END #else # define gwENVr_LOCALEr_LOCK ENV_LOCK # define gwENVr_LOCALEr_UNLOCK ENV_UNLOCK #endif /* Now that we have defined gwENVr_LOCALEr_LOCK, we can finish defining - * SETLOCALE_LOCK, which we kept undefined until here on a thread-safe system + * LOCALE_LOCK, which we kept undefined until here on a thread-safe system * so that we could use that fact to calculate what gwENVr_LOCALEr_LOCK should * be */ -#ifndef SETLOCALE_LOCK -# define SETLOCALE_LOCK NOOP -# define SETLOCALE_UNLOCK NOOP +#ifndef LOCALE_LOCK +# define LOCALE_LOCK NOOP +# define LOCALE_UNLOCK NOOP #endif @@ -7259,8 +7259,8 @@ the plain locale pragma without a parameter (S>) is in effect. * exclusive lock. By defining it here with this name, we can, for the * most part, hide this detail from the rest of the code */ /* Currently, the read lock is an exclusive lock */ -#define LOCALE_READ_LOCK SETLOCALE_LOCK -#define LOCALE_READ_UNLOCK SETLOCALE_UNLOCK +#define LOCALE_READ_LOCK LOCALE_LOCK +#define LOCALE_READ_UNLOCK LOCALE_UNLOCK #ifndef LC_NUMERIC_LOCK @@ -7288,8 +7288,8 @@ the plain locale pragma without a parameter (S>) is in effect. # define WCRTOMB_LOCK_ NOOP # define WCRTOMB_UNLOCK_ NOOP -# define LC_COLLATE_LOCK SETLOCALE_LOCK -# define LC_COLLATE_UNLOCK SETLOCALE_UNLOCK +# define LC_COLLATE_LOCK LOCALE_LOCK +# define LC_COLLATE_UNLOCK LOCALE_UNLOCK # define STRFTIME_LOCK ENV_LOCK # define STRFTIME_UNLOCK ENV_UNLOCK