diff options
author | Karl Williamson <khw@cpan.org> | 2023-03-04 19:19:14 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2023-03-13 08:14:56 -0600 |
commit | cb9df13091578d029ab318ba946310831d2e1912 (patch) | |
tree | bdfc557f644b788de70daf1a1eb924585e675fd6 /perl.h | |
parent | 2740baa993c22d700ed17566bbfddb5ac8173168 (diff) | |
download | perl-cb9df13091578d029ab318ba946310831d2e1912.tar.gz |
locale.c: Remove one use of nl_langinfo_l()
The limited POSIX guarantees of thread safety for nl_langinfo_l() aren't
enough for our uses, and I was naive to think that a simple Configure probe
could rule out all possible thread-safety issues that might exist in a
libc call. I don't remember what the platforms were that falsely tested
ok for the probe, but if it were necessary to find out, revert this
patch, and start a smoke-me test.
What that Configure probe did was find one particular point of
non-safety. And it turns out various platforms pass that, but don't
have a thread-safe nl_langinfo_l() generally.
There are two calls to nl_langinfo_l() in the code. This commit removes
one, where the major advantage of using nl_langinfo_l() over plain
nl_langinfo() was efficiency. There still had to be an alternate
implementation available that used plain nl_langinfo(). Since we can't
guarantee that the _l implementation doesn't have bugs, simply remove
it, and the existing alternative gets automatically used.
The remaining use of nl_langinfo_l() is only when using glibc, and is
disabled by default, requiring an explicit Configure parameter to
enable. I have never seen a case where the glibc implementation failed
to be thread-safe. This use may be enabled by default at some point,
but not until early in a development cycle.
Diffstat (limited to 'perl.h')
-rw-r--r-- | perl.h | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -1260,17 +1260,19 @@ violations are fatal. # include "perl_langinfo.h" /* Needed for _NL_LOCALE_NAME */ -/* Allow use of glibc's undocumented querylocale() equivalent if asked for, and - * appropriate */ # ifdef USE_POSIX_2008_LOCALE # if defined(HAS_QUERYLOCALE) \ - /* Has this internal undocumented item for nl_langinfo() */ \ + /* Use querylocale if has it, or has the glibc internal \ + * undocumented equivalent. */ \ || ( defined(_NL_LOCALE_NAME) \ /* And asked for */ \ && defined(USE_NL_LOCALE_NAME) \ - /* We need the below because we will be calling it within a \ - * macro, can't have it get messed up by another thread. */ \ - && defined(HAS_THREAD_SAFE_NL_LANGINFO_L) \ + /* nl_langinfo_l almost certainly will exist on systems that \ + * have _NL_LOCALE_NAME, so there is nothing lost by \ + * requiring it instead of also allowing plain nl_langinfo(). \ + * And experience indicates that its glibc implementation is \ + * thread-safe, eliminating code complications */ \ + && defined(HAS_NL_LANGINFO_L) \ /* On systems that accept any locale name, the real \ * underlying locale is often returned by this internal \ * item, so we can't use it */ \ |