Linking with -lpthread is not needed on musl libc, macOS, NetBSD,
Solaris, Cygwin, Haiku, Android.
Reported by Michael Osipov <michael.osipov@innomotics.com> and
Tijl Coosemans <tijl@FreeBSD.org> in
<https://lists.gnu.org/archive/html/bug-gettext/2025-09/msg00019.html>.
* m4/pthread-once.m4 (gl_PTHREAD_ONCE): Require gl_PTHREADLIB. Set
PTHREAD_ONCE_LIB.
* modules/pthread-once (Link): Link with $(PTHREAD_ONCE_LIB) instead of
$(LIBPMULTITHREAD).
* modules/pthread-once-tests (Makefile.am): Update accordingly.
* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Set NL_LANGINFO_MTSAFE to 0
on macOS.
* lib/nl_langinfo.c (ITEMS): Define appropriately on macOS.
* doc/posix-functions/nl_langinfo.texi: Document the macOS bug.
* lib/fchownat.c (rpl_fchownat) [CHOWN_TRAILING_SLASH_BUG]:
Do the right thing if fstatat fails with EOVERFLOW.
This matters only on obsolete platforms like Solaris 9,
but it’s easy to do it right. Simplify neighboring code.
* m4/fchownat.m4 (gl_FUNC_FCHOWNAT): Use AC_CHECK_FUNCS instead of
AC_CHECK_FUNC, so that we define HAVE_FCHOWNAT if fchownat
exists. lib/fchownat.c uses HAVE_FCHOWNAT in some cases.
* m4/stringeq.m4: New file.
* modules/stringeq (Files): Add it.
(configure.ac): Don't set HAVE_DECL_MEMEQ, HAVE_DECL_STREQ. Instead,
invoke gl_FUNC_STREQ and gl_FUNC_MEMEQ.
* lib/cpu-supports.h (gcc_feature_to_glibc_hwcap): Define the
map for all architectures, because for example one can build
and detect and run x86_64 intrinsics in code built with -m32.
This should not add runtime overhead, as mentioned previously
the map resolves at compile time with standard optimizations.
Tested with gcc 15 and clang 20.
Note clang didn't need the adjustment,
but it was applied for clang also, to be defensive.
* tests/test-memset_explicit.c (do_secret_stuff): Mark stack variable
as not to be initialized with either zero or pattern on each invocation.
tests/test-explicit_bzero.c (do_secret_stuff): Likewise.
Work even if the system <string.h> declares memeq and streq.
Current standards allow systems to do that,
and we hope future systems will do it.
* lib/string.in.h (memeq) [HAVE_DECL_MEMEQ]: Do not define.
(streq) [HAVE_DECL_STREQ]: Do not define.
* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Default HAVE_DECL_MEMEQ,
HAVE_DECL_STREQ.
* modules/string-h (string-h):
Substitute HAVE_DECL_MEMEQ, HAVE_DECL_STREQ.
* modules/stringeq (configure.ac):
Define HAVE_DECL_MEMEQ, HAVE_DECL_STREQ.
* MODULES.html.sh (func_all_modules): Add stringeq.
* lib/string.c, modules/stringeq: New files.
* lib/string.in.h: Use _GL_INLINE-related macros.
(memeq, streq): New functions, if stringeq module is in use.
* m4/string_h.m4 (gl_STRING_H_REQUIRE_DEFAULTS):
New var GNULIB_STRINGEQ.
* modules/string-h (string.h): Substitute GNULIB_STRINGEQ.
Reported by 松延 英樹 <maznobu@gmail.com> in
<https://github.com/mlocati/gettext-iconv-windows/issues/52>.
* lib/stdio.in.h (gl_consolesafe_fprintf, gl_consolesafe_printf,
gl_consolesafe_vfprintf, gl_consolesafe_vprintf): New declarations.
(fprintf): When msvcrt is in use, use gl_consolesafe_fprintf.
(printf): When msvcrt is in use, use gl_consolesafe_printf.
(vfprintf): When msvcrt is in use, use gl_consolesafe_vfprintf.
(vprintf): When msvcrt is in use, use gl_consolesafe_vprintf.
* lib/stdio-consolesafe.c: Include fseterr.h.
(gl_consolesafe_fprintf, gl_consolesafe_printf, gl_consolesafe_vfprintf,
gl_consolesafe_vprintf): New functions.
* lib/stdio-write.c (vfprintf): When msvcrt is in use, use
gl_consolesafe_vfprintf.
* modules/stdio-h (Depends-on): Add fseterr.
* doc/posix-functions/fprintf.texi: Document the mingw bug.
* doc/posix-functions/printf.texi: Likewise.
* doc/posix-functions/vfprintf.texi: Likewise.
* doc/posix-functions/vprintf.texi: Likewise.
Reported by 松延 英樹 <maznobu@gmail.com> in
<https://github.com/mlocati/gettext-iconv-windows/issues/52>.
* lib/stdio.in.h (gl_consolesafe_fwrite): New declaration.
(fwrite): When msvcrt is in use, use gl_consolesafe_fwrite.
* lib/stdio-consolesafe.c: New file.
* lib/stdio-write.c (fwrite): When msvcrt is in use, use
gl_consolesafe_fwrite.
* modules/stdio.h (Files): Add lib/stdio-consolesafe.c.
(Depends-on): Add stdckdint-h.
(configure.ac): Define condition GL_COND_OBJ_STDIO_CONSOLESAFE.
(Makefile.am): Arrange to compile stdio-consolesafe.c.
* doc/posix-functions/fwrite.texi: Document the workaround.
Reported by Michele Locati in
<https://lists.gnu.org/archive/html/bug-gettext/2024-09/msg00015.html>.
* tests/test-inttypes-h.c (l): On mingw without __USE_MINGW_ANSI_STDIO,
don't test for the presence of SCN*8, SCN*LEAST8, SCN*FAST8}.
* doc/posix-headers/inttypes.texi: Mention the mingw bug.
* doc/posix-functions/fputc.texi: Document a bug found in msvcrt.
* doc/posix-functions/putc.texi: Likewise.
* doc/posix-functions/fwrite.texi: Document another bug found in msvcrt.
This was noticed when building expr in coreutils
with -fsanitize=memory, which induced false failures
resulting in an infinite loop.
* tests/init.sh: Break from the loop if there's an issue with expr(1).
This functionality is useful to allow better test coverage at least,
and may be useful for users to tune their environment,
avoiding CPU throttling for example.
* lib/cpu-supports.h (cpu_supports): A new wrapper that
checks that the GLIBC_TUNABLES environment variable allows
the hardware feature, before checking with __builtin_cpu_supports().
(cpu_may_support): Only perform the GLIBC_TUNABLES check,
which is useful if using other interfaces like getauxval().
(gcc_feature_to_glibc_hwcap): An internal helper that will resolve
at compile time with standard optimizations enabled.
* lib/cpu-supports.c (hwcap_allowed): Query the GLIBC_TUNABLES
environment variable (read once per process), to see if the
passed GLIBC_HWCAP is allowed.
* modules/cpu-supports: New module definition.
* modules/cpu-supports-tests: New test module definition.
* tests/test-cpu-supports.c: New tests.
* m4/gettext_h.m4: New file, extracted from modules/gettext-h. Add back
the newline at the end of the AH_BOTTOM argument.
* modules/gettext-h (Files): Add it.
(configure.ac): Invoke gl_GETTEXT_H.
* tests/test-pagealign_alloc.c: New file.
* modules/pagealign_alloc-tests (Files): Add it.
(Depends-on): Add xalloc.
(configure.ac): Check for alarm().
(Makefile.am): Arrange to compile and run test-pagealign_alloc.
* lib/pagealign_alloc.c (pagealign_alloc, pagealign_free): Add missing
'break' statements. For PA_IMPL_VIRTUAL_ALLOC, don't use new_memnode and
get_memnode.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2025-09/msg00174.html
* lib/byteswap.in.h (_GL_BYTESWAP_INLINE):
Define before including stdint.h.
* lib/endian.in.h (bswap_16, bswap_32, bswap_64):
Declare as _GL_BYTESWAP_INLINE rather than as extern.
Conditionalize these decls with _GL_BYTESWAP_INLINE rather than
with _GL_BYTESWAP_H.