1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-09-21 08:21:59 +03:00

27121 Commits

Author SHA1 Message Date
Bruno Haible
d941c98dbf pthread-once: Reduce link dependencies.
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.
2025-09-21 02:11:03 +02:00
Bruno Haible
8ebd5a9aa7 nl_langinfo: Work around nl_langinfo multithread-safety bug on macOS 26.
* 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.
2025-09-20 15:49:50 +02:00
Paul Eggert
ad4d97cbad fchownat: fix unlikely EOVERFLOW 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.
2025-09-20 00:41:51 -07:00
Paul Eggert
c48ee317b7 fchownat: fix missing HAVE_FCHOWNAT
* 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.
2025-09-20 00:41:51 -07:00
Paul Eggert
92e7a7b130 fchownat: depend on fstatat
* modules/fchownat (Depends-on): Add fstatat.
This fixes a dependency bug I introduced on 2022-03-09
when I made the statat module obsolute.
2025-09-20 00:41:50 -07:00
Bruno Haible
dc1dc5630e stringeq: Fix use in C++ mode.
* lib/string.in.h (memeq, streq): Define with "C" linkage.
2025-09-20 00:03:51 +02:00
Bruno Haible
ba34a934c4 map-c++-tests: Fix compilation error (regression 2025-09-17).
* tests/test-map-c++.cc (streq): Remove function.
* modules/map-c++-tests (Depends-on): Add stringeq.
2025-09-19 16:26:52 +02:00
Bruno Haible
153cf1abe6 stack-trace: Add support for Oracle DeveloperStudio cc.
* m4/stack-trace.m4 (gl_STACK_TRACE_EARLY): Use option
'-Wl,-export-dynamic' instead of '-rdynamic'.
2025-09-18 20:57:26 +02:00
Pádraig Brady
9d7a6e0113 localcharset: fix macOS build
* lib/localcharset.c: s/ostreq/streq/ typo.
2025-09-18 14:36:16 +01:00
Bruno Haible
8c4f03e94f threadlib: Improve support for HP-UX.
* m4/threadlib.m4 (gl_ANYTHREADLIB_EARLY): Define _REENTRANT also on
HP-UX.
2025-09-17 22:11:16 +02:00
Bruno Haible
b9f485800d stringeq: Make use of Autoconf more reliable.
* 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.
2025-09-17 22:05:22 +02:00
Pádraig Brady
395bd7a734 cpu-supports: support checks on any architecture
* 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.
2025-09-17 20:37:24 +01:00
Pádraig Brady
df414ade24 tests: support -ftrivial-auto-var-init
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.
2025-09-17 20:36:33 +01:00
Paul Eggert
6b7a999681 stringeq: port to platforms declaring memeq, streq
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.
2025-09-17 10:12:33 -07:00
Bruno Haible
055d5f02b8 gen-uni-tables: Fix module description (left-over from 2025-05-11).
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-09/msg00223.html>.

* modules/gen-uni-tables (Depends-on): Remove str_startswith,
str_endswith.
2025-09-17 18:33:18 +02:00
Bruno Haible
9bc29cb1ec Add copyright notices.
* lib/string.c: Add copyright notice. Use <string.h>, not "string.h".
2025-09-17 18:28:35 +02:00
Paul Eggert
b95da5f7a7 stringeq: diagnose for streq instead of STREQ
* top/maint.mk (sc_prohibit_strcmp): In diagnostic, suggest streq
instead of STREQ/STRNEQ.
2025-09-17 08:20:25 -07:00
Paul Eggert
26fd35455d stringeq: prefer streq to strcmp in other modules
* lib/acl-internal.c, lib/argmatch.c, lib/argp-help.c:
* lib/argp-parse.c, lib/bcp47.c, lib/c32_get_mapping.c:
* lib/c32_get_type_test.c, lib/concat-filename.c:
* lib/cpu-supports.h, lib/dfa.c, lib/duplocale.c, lib/exclude.c:
* lib/findprog-in.c, lib/findprog.c, lib/fopen.c, lib/freopen.c:
* lib/fts.c, lib/gen-uni-tables.c, lib/getfilecon.c:
* lib/getlogin.c, lib/getugroups.c, lib/hard-locale.c:
* lib/hashcode-named-file.c, lib/hashkey-string.c:
* lib/iconv_open.c, lib/idcache.c, lib/lc-charset-unicode.c:
* lib/localcharset.c, lib/localename-environ.c:
* lib/localename-unsafe.c, lib/mbs_endswith.c, lib/mountlist.c:
* lib/newlocale.c, lib/nl_langinfo.c, lib/nproc.c, lib/open.c:
* lib/os2-spawn.c, lib/parse-datetime.y, lib/popen.c:
* lib/progreloc.c, lib/propername.c, lib/pt_chown.c, lib/putenv.c:
* lib/qcopy-acl.c, lib/readutmp.c, lib/rpmatch.c:
* lib/setlocale-fixes.c, lib/setlocale.c, lib/sig2str.c:
* lib/spawni.c, lib/stat.c, lib/str_endswith.c, lib/streq.h:
* lib/striconveha.c, lib/struniq.h, lib/supersede.c:
* lib/time_rz.c, lib/unicodeio.c, lib/vasnprintf.c:
* lib/vc-mtime.c, lib/wctrans-impl.h, lib/wctype-impl.h:
Prefer streq to strcmp when either will do.
Do not make this change to files shared with glibc.
Do not make the change to test files, at least not for now.
* lib/gen-uni-tables.c (streq): New static function, in same style.
* modules/acl-permissions, modules/argp, modules/c32_get_mapping:
* modules/c32_get_type_test, modules/concat-filename:
* modules/cpu-supports, modules/dfa, modules/duplocale:
* modules/exclude, modules/findprog, modules/findprog-in:
* modules/fopen, modules/fopen-gnu, modules/freopen, modules/fts:
* modules/getlocalename_l-simple, modules/getlocalename_l-unsafe:
* modules/getlogin, modules/getugroups, modules/hard-locale:
* modules/hashcode-named-file, modules/hashkey-string:
* modules/iconv_open, modules/idcache, modules/localcharset:
* modules/localename, modules/localename-unsafe:
* modules/mbs_endswith, modules/mountlist, modules/newlocale:
* modules/nl_langinfo, modules/nproc, modules/open:
* modules/parse-datetime, modules/popen:
* modules/posix_spawn-internal, modules/propername:
* modules/pt_chown, modules/putenv-gnu, modules/qcopy-acl:
* modules/rpmatch, modules/selinux-h, modules/setenv:
* modules/setlocale, modules/setlocale-fixes, modules/sig2str:
* modules/spawn-pipe, modules/stat, modules/str_endswith:
* modules/streq, modules/striconveha, modules/supersede:
* modules/time_rz, modules/uchar-h, modules/unicodeio:
* modules/uniconv/base, modules/wctrans, modules/wctype:
(Depends-on): Add stringeq.
2025-09-17 08:20:25 -07:00
Paul Eggert
6ca831b019 stringeq: prefer memeq to memcmp in other modules
* lib/argmatch.c, lib/argmatch.h, lib/backupfile.c, lib/bcp47.c:
* lib/boot-time.c, lib/csharpcomp.c, lib/csharpexec.c:
* lib/file-has-acl.c, lib/gen-uni-tables.c, lib/get_ppid_of.c:
* lib/get_progname_of.c, lib/getlogin_r.c, lib/getprogname.c:
* lib/getumask.c, lib/isnan.c, lib/mbchar.h, lib/mem-hash-map.c:
* lib/memcoll.c, lib/progname.c, lib/progreloc.c:
* lib/pthread_sigmask.c, lib/quotearg.c, lib/readutmp.c:
* lib/same.c, lib/signbitd.c, lib/signbitf.c, lib/signbitl.c:
* lib/string-desc.c, lib/string.c, lib/string.in.h:
* lib/unictype/3level.h, lib/unictype/3levelbit.h:
* lib/uniname/uniname.c, lib/vc-mtime.c:
Prefer memeq to memcmp when either will do.
Do not make this change to files shared with glibc.
Do not make the change to test files, at least not for now.
* lib/gen-uni-tables.c (memeq): New static function, in same style.
* modules/argmatch, modules/backupfile, modules/bcp47:
* modules/boot-time, modules/csharpcomp, modules/csharpexec:
* modules/file-has-acl:
* modules/get_ppid_of, modules/get_progname_of:
* modules/getlogin_r, modules/getprogname, modules/getumask:
* modules/isnan, modules/mbchar, modules/mem-hash-map:
* modules/memcoll, modules/progname, modules/pthread_sigmask:
* modules/quotearg, modules/readutmp, modules/relocatable-prog:
* modules/relocatable-prog-wrapper, modules/same, modules/signbit:
* modules/string-desc, modules/stringeq, modules/uniname/uniname:
* modules/vc-mtime:
(Depends-on): Add stringeq.
2025-09-17 08:20:24 -07:00
Paul Eggert
60b0949c93 stringeq: new module
* 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.
2025-09-17 08:20:23 -07:00
Pádraig Brady
093de60973 doc: MODULES.html.sh: add missing cpu-supports entry
* MODULES.html.sh: Add "cpu-supports" to Misc section.
2025-09-17 15:58:33 +01:00
Bruno Haible
84d76cdd16 stdio-h: Work around [v][f]printf bugs in mingw with msvcrt.
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.
2025-09-17 11:31:34 +02:00
Bruno Haible
dc8590b1ff stdio-h: Work around fwrite bug in msvcrt.
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.
2025-09-17 11:30:19 +02:00
Bruno Haible
c172e838f9 strerror_r-posix: Fix truncation code (regression today).
* lib/strerror_r.c (strerror_r): Fix use of snprintf again.
2025-09-16 22:04:46 +02:00
Bruno Haible
a9a1a8cd09 inttypes-h tests: Avoid compilation error on mingw.
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.
2025-09-16 21:35:12 +02:00
Pádraig Brady
c0184d73eb cpu-supports: remove assert dependency
Avoid LGPL incompatibility issues by removing assert.

* lib/cpu-supports.c (hwcaps_allowed): Replace assert()s
with defensive returns allowing the passed hwcap.
* modules/cpu-supports: Remove the dependency.
2025-09-16 17:50:25 +01:00
Paul Eggert
9b5342110a mcel: document that errno is unspecified 2025-09-16 09:14:38 -07:00
Bruno Haible
901563ae36 Document msvcrt (native Windows) bugs regarding console output.
* 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.
2025-09-16 17:08:44 +02:00
Bruno Haible
bbd69592e3 strerror_r: Ensure a trailing NUL when truncating.
* lib/strerror_r.c (strerror_r): Fix use of snprintf.
2025-09-16 16:51:55 +02:00
Bruno Haible
51aa7ef138 strtof: Work around mingw bug with overflow.
* lib/strtod.c (STRTOD): Recognize overflow.
* modules/strtof (Depends-on): Add isinf.
* modules/strtod (Depends-on): Likewise.
* modules/strtold (Depends-on): Likewise.
* doc/posix-functions/strtof.texi: Update mingw version.
2025-09-16 16:30:38 +02:00
Bruno Haible
c663bd173e pagealign_alloc tests: Fix link error.
* modules/pagealign_alloc-tests (Makefile.am): Link
bench-pagealign_alloc with $(LIBINTL).
2025-09-16 15:07:55 +02:00
Pádraig Brady
b26ea307aa tests: avoid infinite loop in init.sh
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).
2025-09-15 20:43:48 +01:00
Pádraig Brady
2bad49a5f9 cpu-supports: relicense under LGPL
* modules/cpu-supports: Relicense under LGPL
to match the crc-x86_64 module.
2025-09-15 20:43:48 +01:00
Bruno Haible
8d868202fc threadlib: Omit unsupported configure option.
Reported by Michael Osipov <michael.osipov@innomotics.com> in
<https://lists.gnu.org/archive/html/bug-gettext/2025-09/msg00009.html>.

* m4/threadlib.m4 (gl_THREADLIB_EARLY_BODY): If libtool is in use, don't
display the --disable-threads option.
2025-09-15 18:09:33 +02:00
Karl Berry
e3777b8b52 autoupdate 2025-09-15 08:34:43 -07:00
Bruno Haible
06f481dafc pagealign_alloc tests: Fix link error.
* modules/pagealign_alloc-tests (Makefile.am): Link test-pagealign_alloc
with $(LIBINTL).
2025-09-15 08:32:29 +02:00
Bruno Haible
d3bcecb9d8 gettext-h: Avoid warning with gcc < 4.2.
Reported by Orgad Shaneh <orgads@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-09/msg00183.html>.

* lib/gettext.h (gettext, dgettext, dcgettext): Don't use attribute
__gnu_inline__ with gcc < 4.2.
2025-09-15 08:31:04 +02:00
Karl Berry
cfd950f473 autoupdate 2025-09-14 08:06:52 -07:00
Pádraig Brady
4aa11814c9 crc-x86_64: honor GLIBC_TUNABLES to disable acceleration
* modules/crc-x86_64: Depend on cpu-supports.
* lib/crc.c: Call the cpu_supports() wrapper that honors glibc hwcaps.
2025-09-14 13:17:22 +01:00
Pádraig Brady
16deb62f09 cpu-supports: a module to honor GLIBC_TUNABLES=glibc.cpu.hwcaps
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.
2025-09-14 13:16:29 +01:00
Bruno Haible
0f6c305537 gettext-h: Avoid -Wtrailing-whitespace in a better way.
* 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.
2025-09-14 03:12:08 +02:00
Collin Funk
f9e44d5d91 gettext-h: Avoid -Wtrailing-whitespace in config.h.
* modules/gettext-h (configure.ac): Move the closing bracket and
parentheses of AH_BOTTOM to the preceding line.
2025-09-13 17:34:21 -07:00
Bruno Haible
93a0da5d13 pagealign_alloc: Don't waste large amounts of memory (regr. 2025-09-10).
* tests/bench-pagealign_alloc.c: Update results.
2025-09-14 01:17:38 +02:00
Bruno Haible
bcc735c1eb pagealign_alloc: Don't waste large amounts of memory (regr. 2025-09-10).
* lib/pagealign_alloc.c (get_default_impl): Choose a default that does
not waste large amounts of memory.
2025-09-14 01:13:24 +02:00
Bruno Haible
7f4d4edc36 pagealign_alloc: Add unit test for scalability.
* 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.
2025-09-14 01:13:19 +02:00
Bruno Haible
9437102692 pagealign_alloc: Fix scalability problem.
Reported by Harry Sintonen <sintonen@iki.fi> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-09/msg00108.html>.

* lib/pagealign_alloc.c: Include gl_xmap.h, gl_hash_map.h. Don't include
xalloc.h.
(info_t, memnode_t, struct memnode_s): Remove types.
(memnode_table): Remove variable.
(new_memnode, get_memnode): Remove functions.
(page_info_map): New variable.
(pagealign_alloc): Use gl_map_put instead of new_memnode.
(pagealign_free): Use gl_map_getremove instead of get_memnode.
* modules/pagealign_alloc (Depends-on): Add xmap, hash-map. Remove
xalloc.
2025-09-14 00:24:21 +02:00
Bruno Haible
8bca9f3cc8 pagealign_alloc: Fix crashes (regression 2025-09-11).
* 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.
2025-09-14 00:18:04 +02:00
Paul Eggert
226b0092dc endian: port to Solaris 11.4 and macOS 15
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.
2025-09-13 13:01:00 -07:00
Karl Berry
b4855f4ae3 autoupdate 2025-09-13 09:02:51 -07:00
Bruno Haible
cea7fc1b0d gettext-h: Move fallback definition of GNULIB_TEXT_DOMAIN.
* lib/gettext.h (GNULIB_TEXT_DOMAIN): Remove macro.
* modules/gettext-h (configure.ac): Define it here instead.
2025-09-13 17:34:13 +02:00