Bruno Haible [Tue, 28 Apr 2026 09:06:24 +0000 (11:06 +0200)]
c-strtod tests: Improve last patch.
* tests/test-c-strtof-mt.c: Revert addition of dead code.
* tests/test-c-strtod-mt.c: Likewise.
* tests/test-c-strtold-mt.c: Likewise.
* tests/test-c-strtof-mt.sh: Don't assume that if one invocation of the
test program has exit code 77, the other invocation will have exit code
77 as well.
* tests/test-c-strtod-mt.sh: Likewise.
* tests/test-c-strtold-mt.sh: Likewise.
Paul Eggert [Mon, 27 Apr 2026 21:55:39 +0000 (14:55 -0700)]
regex: port to non-GNU malloc
This is for Gawk, which does not use malloc-gnu.
* lib/regex.c (_GL_USE_STDLIB_ALLOC) [!_LIBC]:
Define, since this module is now safe for AIX-like malloc.
* lib/regex_internal.h (re_malloc) [!_LIBC && !HAVE_MALLOC_0_NONNULL]:
Don’t pass 0 to malloc.
Paul Eggert [Mon, 27 Apr 2026 21:15:40 +0000 (14:15 -0700)]
regex: SSIZE_MAX porting
* lib/regex_internal.h (IDX_MAX) [_REGEX_LARGE_OFFSETS]:
Port to non-POSIX platforms where limits.h does not define SSIZE_MAX.
This is for Gawk, which does not use Gnulib limits.h.
Paul Eggert [Mon, 27 Apr 2026 20:05:32 +0000 (13:05 -0700)]
idx: cleaner namespace on GNU
* lib/idx.h: Include <stddef.h>, <stdint.h> only if needed.
(idx_t, IDX_MAX): Rely on builtin macros __PTRDIFF_TYPE__,
__PTRDIFF_MAX__ if present; this avoids polluting the namespace on
GNUish systems.
Paul Eggert [Sun, 26 Apr 2026 22:09:00 +0000 (15:09 -0700)]
localename-unsafe: respect --disable-threads
Respect --disable-threads on native MS-Windows.
* lib/localename-unsafe.c (GLWTHREAD_MUTEX_INIT, glwthread_mutex_t)
(glwthread_mutex_lock, glwthread_mutex_unlock)
[AVOID_ANY_THREADS && _WIN32 && !__CYGWIN]:
Instead of including "windows-mutex.h", provide no-op substitutes
for its symbols used here.
Paul Eggert [Sat, 25 Apr 2026 22:25:09 +0000 (15:25 -0700)]
c-strtod-tests: port to single-threaded builds
* tests/test-c-strtod-mt.c:
* tests/test-c-strtof-mt.c:
* tests/test-c-strtold-mt.c:
(main): The tests make no sense when single-threaded, so skip them
by exiting with status 77.
* tests/test-c-strtod-mt.sh:
* tests/test-c-strtof-mt.sh:
* tests/test-c-strtold-mt.sh:
Exit with the failing test’s status, so that if it exits with
status 77 then we do too.
Paul Eggert [Sat, 25 Apr 2026 22:19:27 +0000 (15:19 -0700)]
cond: always include glthread/lock.h
* lib/glthread/cond.h: Revert my 2026-03-31 namespace cleanup
patch, which was incorrect because this header’s
gl_cond_timedwait_func function uses lock_t even when threading is
disabled.
Paul Eggert [Sat, 25 Apr 2026 22:15:48 +0000 (15:15 -0700)]
thread: better nonreturn fix for gl_thread_create
* lib/glthread/thread.c (gl_thread_create):
Define as a function only if multithreading.
This is cleaner than my previous patch today that sometimes made
it _Noreturn, as the function’s definition and declaration now always
agree on noreturnedness, and it pushes the noreturnedness issue up
to the caller. Also, it suppresses GCC’s “warning: function
declared 'noreturn' has a 'return' statement”.
Paul Eggert [Sat, 25 Apr 2026 16:40:41 +0000 (09:40 -0700)]
thread: pacify gcc -Wunused-value
* lib/glthread/thread.h (glthread_atfork, glthread_sigmask)
(glthread_create, glthread_join): Evaluate arguments even when
these macros are no-ops. Type-check the arguments too. This is
cleaner anyway, in case the args have the wrong types (or have
side effects!).
Bruno Haible [Sat, 25 Apr 2026 09:26:37 +0000 (11:26 +0200)]
regex: Fix link error on macOS and FreeBSD (regression yesterday).
* modules/regex (Link): Add $(LIBUNISTRING), $(LIBC32CONV).
* modules/regex-tests (Makefile.am): Link test-regex with
$(LIBUNISTRING) and $(LIBC32CONV).
Paul Eggert [Sat, 25 Apr 2026 00:28:58 +0000 (17:28 -0700)]
regex: be consistent with dfa
In the regex code, use the char32_t functions instead of the
wchar_t functions, so that regex stays in sync with dfa.
This should fix a bug in Gnu grep reported by Dennis Clarke for
OpenBSD <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=80774#47>.
A similar bug occurs in some macOS releases.
* modules/regex (Depends-on): Replace btowc, iswctype, mbrtowc,
wchar-h, wcrtomb, wctype-h, and wctype with btoc32,
c32_apply_type_test, c32_get_type_test, c32isalnum, c32rtomb,
c32tolower, c32toupper, mbrtoc32-regular, uchar-h.
* lib/regex_internal.h [!_LIBC]: Do not include <wchar.h>, <wctype.h>.
Instead, include <uchar.h> and #define wchar_t, wctype_t,
__wctype, __iswalnum, __iswctype, __towlower, __towupper, __btowc,
__mbrtowc, and __wcrtomb to their char32_t counterparts.
Paul Eggert [Sat, 25 Apr 2026 00:14:22 +0000 (17:14 -0700)]
dfa: always use char32_t not wchar_t
This should help merges changes from Gawk, which always uses the
char32_t API though that’s sometimes implemented with the wchar_t
API even on platforms where wchar_t and char32_t act differently.
The idea is to use char32_t uniformly in both the dfa and regex
modules, so that they get consistent answers on all platforms.
* lib/dfa.c, lib/localeinfo.c, lib/localeinfo.h: If GAWK, do not
include <wctype.h> or redefine the Gnulib char32_t types and
functions to be wchar.h and wctype.h functions or define mbszero
and streq, as I think I have a better way to do this with Gawk
that is less intrusive here; instead, always include <uchar.h>.
* lib/dfa.c: Do not include <wchar.h>. Include "getext.h" before
including "xalloc.h" and "localinfo.h", as Gnulib doesn’t care
about the order and this works better with Gawk’s way of overriding Gnulib.
(parse_bracket_exp): Use && instead of &; either is correct and
both are equally fast nowadays but && triggers a warning in some
Gawk compiles.
* lib/dfa.h (_GL_ATTRIBUTE_MALLOC, _GL_ATTRIBUTE_DEALLOC)
(_GL_ATTRIBUTE_DEALLOC_FREE)
(_GL_ATTRIBUTE_RETURNS_NONNULL) [!_GL_ATTRIBUTE_MALLOC]:
Remove, as Gawk’s custom.h can define them.
* lib/localeinfo.c: Go back to using <verify.h> and ‘verify’
instead of using static_assert which Gawk can’t easily use because
it does not use Gnulib’s assert-h module.
* lib/localeinfo.h: Do not include <limits.h>, avoding some
namespace pollution.
(struct localeinfo): Use (unsigned char) -1 instead of UCHAR_MAX
to avoid the need to include <limits.h>.
* modules/dfa (Depends-on): Remove wchar-h.
Paul Eggert [Fri, 24 Apr 2026 23:00:34 +0000 (16:00 -0700)]
uchar-h: <string.h> etc. namespace cleanup
This is only a partial cleanup; to be cleaner we’d need to
move declarations of Gnulib extensions like c32isalpha
into a separate .h file. However, if no Gnulib modules that
extend <uchar.h> are used, Gnulib <uchar.h> is now pretty clean on
recent GNUish platforms.
* lib/uchar.in.h: On GNUish platforms, include <stdint.h>,
<wchar.h>, <wctype.h> only if needed. Do not include <string.h>,
as we never need it directly: even if we use <string.h>’s memset
via mbszero, <wchar.h> should include <string.h> if needed, as
<wchar.h> defines mbszero. Move a static_assert from here to tests,
as the static_assert uses a symbol that is no longer guaranteed
to be visible.
* modules/uchar-h (Depends-on): Do not depend on assert-h.
* tests/test-uchar-h.c: Move a static_assert here from lib/uchar.in.h,
and include <wchar.h> so that wchar_t is guaranteed to be visible.
Paul Eggert [Fri, 24 Apr 2026 21:09:31 +0000 (14:09 -0700)]
doc: document namespace pollution allowed by POSIX
In the manual, document where POSIX.1-2024 allows namespace pollution.
Although it might be nice to add something like GNULIB_POSIXCHECK to
detect when Gnulib-using code is unportable in this area, I don’t
offhand see a good way to do that.
Bruno Haible [Fri, 24 Apr 2026 13:31:00 +0000 (15:31 +0200)]
version-etc: Optionally emit another line for the man page.
* lib/version-etc.c: Include <stdlib.h>.
(emit_bug_reporting_address): Terminate the "Report bugs to" sentence,
as suggested in
https://www.gnu.org/software/gettext/manual/html_node/Bug-Report-Address.html.
Add a "Report any translation bugs to" sentence, but only when producing
a man page.
Bruno Haible [Fri, 24 Apr 2026 13:57:52 +0000 (15:57 +0200)]
bcp47: Fix handling of variants of length 4.
Reported by Patrice Dumas <pertusus@gnu.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2026-04/msg00154.html>.
* lib/bcp47.c (bcp47_to_xpg): Don't parse a variant of length 4 that
contains some digits as a script.
* tests/test-bcp47.c (main): Add a test case with a variant of length 4.
Paul Eggert [Thu, 23 Apr 2026 19:59:52 +0000 (12:59 -0700)]
wchar-h: <string.h> namespace cleanup
Do not pollute <wchar.h> includers with <string.h> names
on GCC-compatible platforms.
* lib/wchar.in.h (_GL_WCHAR_MEMSET) [@GNULIB_MBSZERO@]: New macro.
(mbszero): Use it.
Jim Meyering [Mon, 20 Apr 2026 02:36:03 +0000 (19:36 -0700)]
maint.mk: fix sc_Wundef_boolean race with parallel syntax-check
With highly parallel "make syntax-check", sc_Wundef_boolean's
in_files='config.h' was matched as an unanchored, unescaped regex
by "find | grep -E", so the '.' matched any character and the lack
of anchoring matched anywhere in a path. This made it match the
.sc-start-sc_*config_h* marker files created by parallel rules.
Symptom: I saw see these go by:
grep: ./.sc-start-sc_require_config_h_first: No such file or directory
grep: ./.sc-start-sc_prohibit_have_config_h: No such file or directory
grep: ./.sc-start-sc_require_config_h: No such file or directory
* top/maint.mk (sc_Wundef_boolean): Use '(^|/)config\.h$' rather
than bare 'config.h' as the in_files ERE.
Paul Eggert [Sun, 19 Apr 2026 18:12:16 +0000 (11:12 -0700)]
readutmp: greeters are not users
* lib/readutmp.c (read_utmp_from_systemd):
Do not merely treat a "manager*" class as a login process.
Instead, treat all non-"user*" processes as login processes.
With current systemd, this changes the treatment of "greeter",
"lock-screen", "background", "background-light", and "none"
classes so that they are now considered to be login processes, not
user processes.
Jim Meyering [Sun, 19 Apr 2026 16:52:26 +0000 (09:52 -0700)]
regex: avoid a UBSAN failure: remove an unnecessary DEBUG_ASSERT
* lib/regex_internal.c (re_node_set_insert): Remove the DEBUG_ASSERT
and instead return early for an attempt to insert an ELEM that is
already present in the set. Relax the function's comment that says
there should be no duplicate. This function is called from many
places and has been working fine. With its nontrivial backrefs,
the sample regexp apparently elicits enough backtracking retries
and state-set merges to trigger this duplicate insertion attempt.
Reported by Bruno Haible in
https://lists.gnu.org/r/bug-gnulib/2026-04/msg00138.html
Paul Eggert [Fri, 17 Apr 2026 16:14:49 +0000 (09:14 -0700)]
doc: doc FTS_NOSTAT with FIFO, not directory
* lib/fts.in.h (FTS_NOSTAT): Use a FIFO, not a directory,
in the commentary’s example. This is a better example
because directories never have FTS_NSOK.
Bruno Haible [Wed, 15 Apr 2026 11:45:58 +0000 (13:45 +0200)]
sigdelay: Add tests.
* tests/test-sigdelay1.c: New file, based on
tests/test-pthread_sigmask1.c.
* tests/test-sigdelay2.c: New file, based on
tests/test-pthread_sigmask2.c.
* modules/sigdelay-tests: New file.
Bruno Haible [Wed, 15 Apr 2026 11:45:44 +0000 (13:45 +0200)]
pthread_sigmask tests: Enhance test.
* tests/test-pthread_sigmask2.c (killer_thread1): Renamed from
killer_thread.
(killer_thread2): New variable.
(killer_thread1_func): Renamed from killer_thread_func.
(killer_thread2_func): New function.
(main): Add a second test with killer_thread2.
Bruno Haible [Mon, 13 Apr 2026 21:44:24 +0000 (23:44 +0200)]
stdbit-h: Port to Intel icpx C++ compiler.
* lib/stdbit.in.h: With the Intel icpx C++ compiler, include <stddef.h>
and <stdint.h>, and define the __STDC_ENDIAN_* macros.
* doc/posix-headers/stdbit.texi: Document the Intel icpx bug.
Paul Eggert [Mon, 13 Apr 2026 21:01:36 +0000 (14:01 -0700)]
error-h: port to Intel OneAPI icx 2026.0.0
Problem reported by Harmen Stoppels in:
https://lists.gnu.org/r/bug-gnulib/2026-04/msg00085.html
* m4/error_h.m4 (gl_ERROR_H): Plant an alarm in case error infloops.
Jim Meyering [Mon, 13 Apr 2026 06:07:09 +0000 (23:07 -0700)]
regex: small simplification
* lib/regexec.c (re_search_internal): Use only one copy
of the 5-line reg-initialization code, removing that else block,
at the tiny cost of moving a small test into the loop.
Jim Meyering [Sun, 12 Apr 2026 19:36:45 +0000 (12:36 -0700)]
regex: fix missed short match with backrefs
With a backref pattern like ^(.?)(.?).?\2\1 (no $), the engine
could miss valid short matches. For example, "ab" should match
via all-empty groups, yet regexec returned no-match because
set_regs failed at the longest structural match (match_last=2)
and never retried at a shorter match_last.
* lib/regexec.c (re_search_internal): When set_regs fails for a
backref pattern, retry prune_impossible_nodes and set_regs at
progressively shorter match lengths. Save a copy of state_log
before pruning so shorter retries can re-sift from the original
states.
* m4/regex.m4: Also reject system regex with this bug.
* tests/test-regex.c (main): Add a test for this bug.
Reported by Ed Morton in https://bugs.gnu.org/68725 Co-authored-by: Claude <noreply@anthropic.com>
Jim Meyering [Sun, 12 Apr 2026 17:27:03 +0000 (10:27 -0700)]
regex: fix false match with backrefs and $ anchor
Use of sed or grep with both backreferences and an end-of-line
anchor could get false matches. For example, this grep command
would falsely declare "ab" to be a palindrome:
grep -E '^(.?)(.?).?\2\1$' <<< ab
In prune_impossible_nodes, falling back to a shorter match
skipped the halt-state context check, so $ was not verified.
* lib/regexec.c (prune_impossible_nodes): Also require
check_halt_state_context to succeed in the loop that searches
for an earlier halt state.
* m4/regex.m4: Bump serial to 82. Reject any system regex
implementation with this bug.
* tests/test-regex.c (main): Add a test for this bug.
Reported by Ed Morton in https://bugs.gnu.org/68725
Paul Eggert [Sat, 11 Apr 2026 21:06:09 +0000 (14:06 -0700)]
tempname: call ‘clock’ only if !CLOCK_REALTIME
* lib/tempname.c (random_bits) [CLOCK_REALTIME]: Do not call
‘clock’, as an optimization. There is no need to call ‘clock’, as
it likely gives us less info than clock_gettime, and if
clock_gettime fails then ‘clock’ will likely fail too.
This patch is a simplified version of the patch made in glibc commit 5f62cf88c4530c11904482775b7582bd7f6d80d2 dated 2024-09-25,
and Gnulib lib/tempname.c should now be suitable as-is for
replacing Glibc sysdeps/posix/tempname.c.
Paul Eggert [Sat, 11 Apr 2026 20:19:43 +0000 (13:19 -0700)]
doc: be more like POSIX in threading terms
In documentation and comments, be more like POSIX in terminology
involving multithreading. Explain the distinction between
multithreaded process vs multithreaded program. Change “program”
to “process” when the latter wording is more accurate or informative.
Simplify the wording for the constraints on processes that use
unlocked I/O. Change “multithread-safe” to “thread-safe”.
Change “thread-safety” to “thread safety”.
However, do not change “multithreaded” to “multi-threaded” even
though there are some uses of both spellinga, as there are a whole
bunch of uses of “multithreaded”, also in identifier names;
perhaps Gnulib should even standardize on “multithreaded”
(not “multi-threaded”), contra POSIX.
* lib/sigprocmask.c (glwthread_spin_lock, glwthread_spin_unlock): Define
to empty if GNULIB_SIGPROCMASK_SINGLE_THREAD is defined.
(overrides_mt_lock, overrides_handler_lock): Don't define if
GNULIB_SIGPROCMASK_SINGLE_THREAD is defined.
* doc/multithread.texi (Multithreading Optimizations): Document
GNULIB_SIGPROCMASK_SINGLE_THREAD instead of
GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD.
Bruno Haible [Fri, 10 Apr 2026 20:57:04 +0000 (22:57 +0200)]
sigprocmask: Fix a signal-handler hang in case of a race condition.
* lib/sigprocmask.c (overrides_handler_lock): Renamed from
overrides_lock.
(overrides_mt_lock): New variable.
(pthread_sigmask): Lock both locks.
(rpl_signal): Lock overrides_mt_lock, not overrides_lock.
Bruno Haible [Fri, 10 Apr 2026 15:22:07 +0000 (17:22 +0200)]
sigprocmask: Support multithreaded applications on native Windows.
* lib/signal.in.h (WIN_PTHREADS_SIGNAL_H): New macro.
* lib/sigprocmask.c: Include windows-spin.h.
(thread_local): New macro.
(blocked_set, pending_array): Mark as thread-local.
(blocked_handler): Remove function.
(struct override): New type.
(overrides, overrides_lock): New variables.
(override_handler): New function.
(pthread_sigmask): New function, borrowing from the previous sigprocmask
definition.
(sigprocmask): Now a wrapper around pthread_sigmask.
(rpl_signal): Use the overrides_lock to make it multithread-safe.
(_gl_raise_SIGPIPE): Add comments.
* modules/sigprocmask (Depends-on): Add windows-spin.
* lib/pthread_sigmask.c: Revert last change. On native Windows, don't
define pthread_sigmask here.
* modules/pthread_sigmask (Depends-on): Remove lock.
* NEWS: Remove the last entry.
Paul Eggert [Sun, 5 Apr 2026 18:29:48 +0000 (11:29 -0700)]
term-style-control: use pthread_sigmask
* lib/term-style-control.c (block_relevant_signals)
(unblock_relevant_signals): Prefer pthread_sigmask to sigprocmask.
* modules/term-style-control (Depends-on):
Depend on pthread_sigmask, not on sigprocmask.
Paul Eggert [Sun, 5 Apr 2026 18:28:19 +0000 (11:28 -0700)]
fatal-signal: use pthread_sigmask
* lib/fatal-signal.c (block_fatal_signals)
(unblock_fatal_signals): Prefer pthread_sigmask to sigprocmask.
* modules/fatal-signal (Depends-on):
Depend on pthread_sigmask, not on sigprocmask.
Paul Eggert [Sun, 5 Apr 2026 18:26:56 +0000 (11:26 -0700)]
sigaction: use pthread_sigmask
* lib/sigaction.c (sigaction_handler, sigaction):
Use pthread_sigmask, not sigprocmask.
* modules/sigaction (Depends-on):
Depend on pthread_sigmask, not on sigprocmask.
Paul Eggert [Sun, 5 Apr 2026 18:25:05 +0000 (11:25 -0700)]
pthread_sigmask: lock here, not in sigprocmask
Since sigprocmask should now be used only in single-threaded processes,
move the locking from lib/sigprocmask.c to lib/pthread_sigmask.c.
* lib/pthread_sigmask.c: If !HAVE_SIGPROCMASK &&
!GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD, replace Gnulib sigprocmask
with a thread-safe subsitute sigprocmask_r.
Include glthread/lock.h to implement this.
* lib/sigprocmask.c (gl_lock_define_initialized, gl_lock_lock)
(gl_lock_unlock, sig_lock): Remove. All uses removed.
Do not include glthread/lock.h.
* m4/signalblocking.m4 (gl_SIGNALBLOCKING):
Define HAVE_SIGPROCMASK, for the benefit of pthread_sigmask.c.
* modules/pthread_sigmask (Depends-on): Add ‘lock’.
* modules/sigprocmask (Depends-on): Remove ‘lock’.
This is a performance win on GLIBC,
as tested on the coreutils multi-byte update to cut(1):
$ yes $(yes éééááé | head -n9 | paste -s -d,) |
head -n1M > mb.in
$ time LC_ALL=C.UTF-8 src/cut-before -c1 mb.in >/dev/null
real 0m1.582s
$ time LC_ALL=C.UTF-8 src/cut-after -c1 mb.in >/dev/null
real 0m0.592s
* lib/mcel.h: While GLIBC's mbrtoc32 is functional for mcel,
it is seen to be 2.6x slower than gnulib's implementation
due to GLIBC's per call locale handling.
Bruno Haible [Sat, 4 Apr 2026 20:44:10 +0000 (22:44 +0200)]
asyncsafe-spin: Prefer pthread_sigmask over sigprocmask.
Suggested by Paul Eggert.
* lib/asyncsafe-spin.c (asyncsafe_spin_lock, asyncsafe_spin_unlock): Use
pthread_sigmask instead of sigprocmask.
* modules/asyncsafe-spin (Depends-on): Add pthread_sigmask. Remove
sigprocmask.
(Link): New section.
* modules/asyncsafe-spin-tests (Makefile.am): Link test-asyncsafe-spin1
with $(PTHREAD_SIGMASK_LIB).
* modules/jit/cache-tests (Makefile.am): Link test-cache with
$(PTHREAD_SIGMASK_LIB).
Bruno Haible [Sat, 4 Apr 2026 13:16:44 +0000 (15:16 +0200)]
pthread_sigmask: Make it usable without -lpthread on most platforms.
* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Define
PTHREAD_SIGMASK_LIB to empty, except on AIX. Define
PTHREAD_SIGMASK_NOT_IN_LIBC if a workaround is needed.
* lib/pthread_sigmask.c (pthread_sigmask): If
PTHREAD_SIGMASK_NOT_IN_LIBC, just use sigprocmask.
* doc/posix-functions/pthread_sigmask.texi: Mention the dropped link
requirement. Mention that the NetBSD 9 bug is fixed.
* doc/posix-functions/sigprocmask.texi: Update note relating to
pthread_sigmask.
Paul Eggert [Sat, 4 Apr 2026 02:55:48 +0000 (19:55 -0700)]
sigprocmask: document race bugs on macOS
In documentation and comments, mention macOS sigprocmask
incompatibility with GNU and most other systems, and note Gnulib
uses of sigprocmask that can cause subtle race condition bugs on
macOS. Although an obvious fix is to switch to pthread_sigmask as
POSIX suggests, that will require some changing to linking
instructions, and the first step is documentation.
Bruno Haible [Thu, 2 Apr 2026 19:59:58 +0000 (21:59 +0200)]
mbrtoc32: Optimize single-locale case on glibc systems.
Suggested by Pádraig Brady.
* lib/mbrtoc32.c (is_locale_utf8, cached_is_locale_utf8,
is_locale_utf8_cached): New functions/variable, copied from
lib/wcwidth.c.
(mbrtoc32): If GNULIB_WCHAR_SINGLE_LOCALE is defined, optimize the
frequent case of an UTF-8 locale on glibc systems.
Bruno Haible [Thu, 2 Apr 2026 19:58:36 +0000 (21:58 +0200)]
mbrtowc: Optimize single-locale case on glibc systems.
Suggested by Pádraig Brady.
* lib/mbrtowc.c (is_locale_utf8, cached_is_locale_utf8,
is_locale_utf8_cached): New functions/variable, copied from
lib/wcwidth.c.
(rpl_mbrtowc): If GNULIB_WCHAR_SINGLE_LOCALE is defined, optimize the
frequent case of an UTF-8 locale on glibc systems.
Bruno Haible [Wed, 1 Apr 2026 20:45:55 +0000 (22:45 +0200)]
sigprocmask: Allow single-thread optimization in a more reliable way.
* modules/sigprocmask: Revert last change.
* lib/sigprocmask.c: Test GNULIB_SIGPROCMASK_SINGLE_THREAD before
including glthread/lock.h.
* doc/multithread.texi: Document GNULIB_SIGPROCMASK_SINGLE_THREAD.
Paul Eggert [Wed, 1 Apr 2026 18:34:42 +0000 (11:34 -0700)]
yesno: treat unlocking similarly if !ENABLE_NLS
If the application is using unlocked-io, do that in the
!ENABLE_NLS case too. This is more for consistency than for
performance in the typical case.
* lib/yesno.c [USE_UNLOCKED_IO]: Include unlocked-io.h.
Paul Eggert [Wed, 1 Apr 2026 02:54:46 +0000 (19:54 -0700)]
sigprocmask: allow --avoid=lock
* modules/sigprocmask (Files): Add lib/glthread/lock.h,
so that this module works even if the lock module is avoided.
This is useful for gzip, which does not use multithreading.
Paul Eggert [Wed, 1 Apr 2026 02:51:36 +0000 (19:51 -0700)]
thread: lessen glthread namespace pollution
In lib/glthread/*.h, avoid including files if it’s easy, and if
the files are not needed in the .h file to implement the module.
* lib/glthread/cond.h: Include glthread/lock.h only if needed.
* lib/glthread/lock.c, lib/glthread/once.c: Include <errno.h> here ...
* lib/glthread/lock.h, lib/glthread/once.h: ... instead of here.
* lib/glthread/lock.h: Include glthread/once.h only if needed.
* lib/glthread/yield.h: Don’t include <errno.h>.