summaryrefslogtreecommitdiff
path: root/locale.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-11-30 10:11:01 -0700
committerKarl Williamson <khw@cpan.org>2020-12-08 06:44:20 -0700
commit7953f73fd803e53f20bdf0801f194691543b0f87 (patch)
treef878bb88c4abc11dbf96315da1283b57c1c6eecd /locale.c
parentd9e22c6a8a05aab7fffdbf810f74ddfcb4efd752 (diff)
downloadperl-7953f73fd803e53f20bdf0801f194691543b0f87.tar.gz
Name individual locale locks
These locks for different functions all use the same underlying mutex; but that may not always be the case. By creating separate names used only when we think they will be necessary, the compiler will complain if the conditions in the code that actually use them are the same. Doing this showed a misspelling in an #ifdef, fixed in 9289d4dc7a3d24b20c6e25045e687321ee3e8faf
Diffstat (limited to 'locale.c')
-rw-r--r--locale.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/locale.c b/locale.c
index 5dea47fcc1..e43de9f226 100644
--- a/locale.c
+++ b/locale.c
@@ -1227,10 +1227,10 @@ S_emulate_setlocale(const int category,
* correct locale for that thread. Any operation that was locale-sensitive
* would have to be changed so that it would look like this:
*
- * LOCALE_LOCK;
+ * SETLOCALE_LOCK;
* setlocale to the correct locale for this operation
* do operation
- * LOCALE_UNLOCK
+ * SETLOCALE_UNLOCK
*
* This leaves the global locale in the most recently used operation's, but it
* was locked long enough to get the result. If that result is static, it
@@ -1323,7 +1323,7 @@ S_locking_setlocale(pTHX_
/* It might be that this is called from an already-locked section of code.
* We would have to detect and skip the LOCK/UNLOCK if so */
- LOCALE_LOCK;
+ SETLOCALE_LOCK;
curlocales[index] = savepv(my_setlocale(category, new_locale));
@@ -1345,7 +1345,7 @@ S_locking_setlocale(pTHX_
#endif
- LOCALE_UNLOCK;
+ SETLOCALE_UNLOCK;
return curlocales[index];
}
@@ -2634,18 +2634,16 @@ S_my_nl_langinfo(const int item, bool toggle)
STORE_LC_NUMERIC_FORCE_TO_UNDERLYING();
}
- LOCALE_LOCK; /* Prevent interference from another thread executing
- this code section (the only call to nl_langinfo in
- the core) */
-
+ /* Prevent interference from another thread executing this code
+ * section. */
+ NL_LANGINFO_LOCK;
/* Copy to a per-thread buffer, which is also one that won't be
* destroyed by a subsequent setlocale(), such as the
* RESTORE_LC_NUMERIC may do just below. */
retval = save_to_buffer(nl_langinfo(item),
&PL_langinfo_buf, &PL_langinfo_bufsize, 0);
-
- LOCALE_UNLOCK;
+ NL_LANGINFO_UNLOCK;
if (toggle) {
RESTORE_LC_NUMERIC();
@@ -3041,7 +3039,7 @@ S_my_nl_langinfo(const int item, bool toggle)
case MON_5: case MON_6: case MON_7: case MON_8:
case MON_9: case MON_10: case MON_11: case MON_12:
- LOCALE_LOCK;
+ LOCALE_LOCK_;
init_tm(&tm); /* Precaution against core dumps */
tm.tm_sec = 30;
@@ -3052,7 +3050,7 @@ S_my_nl_langinfo(const int item, bool toggle)
tm.tm_mon = 0;
switch (item) {
default:
- LOCALE_UNLOCK;
+ LOCALE_UNLOCK_;
Perl_croak(aTHX_
"panic: %s: %d: switch case: %d problem",
__FILE__, __LINE__, item);
@@ -3228,7 +3226,7 @@ S_my_nl_langinfo(const int item, bool toggle)
* wday was chosen because its range is all a single digit.
* Things like tm_sec have two digits as the minimum: '00' */
- LOCALE_UNLOCK;
+ LOCALE_UNLOCK_;
retval = PL_langinfo_buf;
@@ -4844,12 +4842,12 @@ Perl__is_cur_LC_category_utf8(pTHX_ int category)
# else
- LOCALE_LOCK;
+ MBTOWC_LOCK;
PERL_UNUSED_RESULT(mbtowc(&wc, NULL, 0));/* Reset any shift state */
SETERRNO(0, 0);
len = mbtowc(&wc, STR_WITH_LEN(REPLACEMENT_CHARACTER_UTF8));
SAVE_ERRNO;
- LOCALE_UNLOCK;
+ MBTOWC_UNLOCK;
# endif
@@ -5357,7 +5355,7 @@ Perl_my_strerror(pTHX_ const int errnum)
* same code at the same time. (On thread-safe perls, the LOCK is a
* no-op.) Since this is the only place in core that changes LC_MESSAGES
* (unless the user has called setlocale(), this works to prevent races. */
- LOCALE_LOCK;
+ SETLOCALE_LOCK;
DEBUG_Lv(PerlIO_printf(Perl_debug_log,
"my_strerror called with errnum %d\n", errnum));
@@ -5401,7 +5399,7 @@ Perl_my_strerror(pTHX_ const int errnum)
}
}
- LOCALE_UNLOCK;
+ SETLOCALE_UNLOCK;
# endif /* End of doesn't have strerror_l */
# ifdef DEBUGGING