summaryrefslogtreecommitdiff
path: root/intrpvar.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-12-13 13:06:42 -0700
committerKarl Williamson <khw@cpan.org>2022-06-11 15:21:39 -0600
commitc3c9077b28cc7017aecd9764ab49af9662ce9b0b (patch)
treeace4a261fffacbfccb390bd86fcede8d02b59ee7 /intrpvar.h
parent12865d70b33295cc1e31678404f5aef517d3a97b (diff)
downloadperl-c3c9077b28cc7017aecd9764ab49af9662ce9b0b.tar.gz
Make fc(), qr//i thread-safe on participating platforms
A long standing bug in Perl that has gone undetected is that the array is global that is created when changing locales and tells fc() and qr//i matching what the folds are in the new locale. What this means is that any program only has one set of fold definitions that apply to all threads within it, even if we claim that the locales are thread-safe on the given platform. One possibility for this going undetected so long is that no one is using locales on multi-threaded systems much. Another possibility is that modern UTF-8 locales have the same set of folds as any other one. It is a simple matter to make the fold array per-thread instead of per-process, and that solves the problem transparently to other code. I discovered this stress-testing locale handling under threads. That test will be added in a future commit. In order to keep from having a dTHX inside foldEQ_locale, it has to have a pTHX_ parameter. This means that the other functions that function pointer variables get assigned to point to have to have an identical signature, which means adding pTHX_ to functions that don't require it. The bodies of all these are known to the compiler, since they are all in inline.h or in the same .c file as where they are called. Hence the compiler can optimize out the unused parameter. Two calls of STR_WITH_LEN also have to be changed because of C preprocessor limitations; perhaps there is another way to do it that I'm unfamiliar with.
Diffstat (limited to 'intrpvar.h')
-rw-r--r--intrpvar.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/intrpvar.h b/intrpvar.h
index 2ff67a8e0f..20ef1fc3aa 100644
--- a/intrpvar.h
+++ b/intrpvar.h
@@ -998,6 +998,8 @@ PERLVAR(I, SB_invlist, SV *)
PERLVAR(I, SCX_invlist, SV *)
PERLVAR(I, UpperLatin1, SV *) /* Code points 128 - 255 */
+PERLVARA(I, fold_locale, 256, U8)
+
/* List of characters that participate in any fold defined by Unicode */
PERLVAR(I, in_some_fold, SV *)