Skip to content

Commit

Permalink
locale.c: Create STDIZED_SETLOCALE_LOCK
Browse files Browse the repository at this point in the history
Its best to use a mutex associated with the operation.  This creates one
for stdized_setlocale(), which is just an alias for another mutex.
  • Loading branch information
khwilliamson committed May 22, 2023
1 parent 5d2b0d6 commit 27615c6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions locale.c
Expand Up @@ -1369,6 +1369,8 @@ S_parse_LC_ALL_string(pTHX_ const char * string,
* on
*/

#define STDIZED_SETLOCALE_LOCK POSIX_SETLOCALE_LOCK
#define STDIZED_SETLOCALE_UNLOCK POSIX_SETLOCALE_UNLOCK
#if ! defined(USE_LOCALE) \
|| ! ( defined(HAS_LF_IN_SETLOCALE_RETURN) \
|| defined(HAS_BROKEN_SETLOCALE_QUERY_LC_ALL))
Expand Down Expand Up @@ -1628,13 +1630,13 @@ S_less_dicey_setlocale_r(pTHX_ const int category, const char * locale)

PERL_ARGS_ASSERT_LESS_DICEY_SETLOCALE_R;

POSIX_SETLOCALE_LOCK;
STDIZED_SETLOCALE_LOCK;

retval = save_to_buffer(stdized_setlocale(category, locale),
&PL_less_dicey_locale_buf,
&PL_less_dicey_locale_bufsize);

POSIX_SETLOCALE_UNLOCK;
STDIZED_SETLOCALE_UNLOCK;

return retval;
}
Expand Down Expand Up @@ -8034,9 +8036,9 @@ Perl_sync_locale(pTHX)
* category. */
const char * current_globals[LC_ALL_INDEX_];
for (unsigned i = 0; i < LC_ALL_INDEX_; i++) {
POSIX_SETLOCALE_LOCK;
STDIZED_SETLOCALE_LOCK;
current_globals[i] = savepv(stdized_setlocale(categories[i], NULL));
POSIX_SETLOCALE_UNLOCK;
STDIZED_SETLOCALE_UNLOCK;
}

/* Now we have to convert the current thread to use them */
Expand Down

0 comments on commit 27615c6

Please sign in to comment.