Paul Eggert [Mon, 21 Apr 2025 17:58:58 +0000 (10:58 -0700)]
getloadavg: port to Android 3.1-
Problem reported by Po Lu in:
https://lists.gnu.org/r/bug-gnulib/2025-04/msg00172.html
* lib/getloadavg.c (getloadavg): Do not try to use sysinfo on
Android 3.1 Honeycomb (API 12, 2011) and earlier.
* lib/stdio-impl.h (fp_) [__HAIKU__]: Define to FILE which is an
incomplete type on Haiku.
(_IO_EOF_SEEN) [__HAIKU__]: Define macro.
* lib/fseeko.c (fp_) [!__HAIKU__]: Define to fp.
(fseeko): Use fp_ instead of fp.
Bruno Haible [Fri, 21 Mar 2025 15:25:59 +0000 (16:25 +0100)]
getloadavg: Improve Linux and Android support.
* lib/getloadavg.c [__linux__, __ANDROID__]: Include <sys/param.h> and
<sys/sysinfo.h>.
(getloadavg) [__linux__, __ANDROID__]: Use sysinfo() instead of reading
/proc/loadavg.
(LINUX_LDAV_FILE): Remove macro.
Collin Funk [Wed, 19 Mar 2025 04:50:00 +0000 (21:50 -0700)]
futimens: Work around a GNU/Hurd bug.
* m4/futimens.m4 (gl_FUNC_FUTIMENS): Check if futimens validates the
tv_nsec values of the timespec argument. Set bits in a return value
instead of exiting early.
* doc/posix-functions/futimens.texi (futimens): Mention the GNU/Hurd
bug. Mention the same bug occurs on NetBSD 10.
Collin Funk [Tue, 18 Mar 2025 04:16:22 +0000 (21:16 -0700)]
utimensat: Work around a GNU/Hurd bug.
* lib/utimensat.c (rpl_utimensat) [__gnu_hurd__]: Check for out of range
tv_nsec values.
* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Likewise. Guess that utimensat
doesn't work on GNU/Hurd.
* doc/posix-functions/utimensat.texi: Mention the bug.
Collin Funk [Thu, 13 Mar 2025 01:55:26 +0000 (18:55 -0700)]
dup3: Fix behavior for equal file descriptors on Haiku.
* lib/dup3.c (dup3) [__HAIKU__]: Set errno to EINVAL and return -1 if
both file descriptors are equal.
* doc/posix-functions/dup3.texi: Document the Haiku bug.
Bruno Haible [Fri, 21 Feb 2025 10:38:35 +0000 (11:38 +0100)]
host-cpu-c-abi: Improve support for loongarch32.
Reported by <wuruilong@loongson.cn>
in <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1098478>
via Simon Josefsson.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Prepare template for
__loongarch32__ in config.h.
(gl_HOST_CPU_C_ABI_32BIT): Speed up the configure test on loongarch*.
Bruno Haible [Wed, 19 Feb 2025 22:46:37 +0000 (23:46 +0100)]
readutmp: Let callers distinguish LOGINs from USERs.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-02/msg00123.html>.
* lib/readutmp.h (LOGIN_PROCESS, UT_TYPE_LOGIN_PROCESS): New macros.
* lib/readutmp.c (read_utmp_from_systemd): Possibly use LOGIN_PROCESS
instead of USER_PROCESS, depending on the session's class.
Bruno Haible [Thu, 13 Feb 2025 01:18:05 +0000 (02:18 +0100)]
setlocale: Update info about Galician and Tamil.
* lib/setlocale.c (locales_with_principal_territory): Galician is
mostly spoken in Spain, not Portugal. Tamil is mostly spoken in India,
not Sri Lanka.
Bruno Haible [Mon, 3 Feb 2025 22:55:39 +0000 (23:55 +0100)]
gnulib-tool: Apply libgnu.{,l}a specific CFLAGS to all its object files.
* gnulib-tool.sh (func_emit_initmacro_end): Define
${macro_prefix}_${libname}_{LIBOBJS,LTLIBOBJS,LIBOBJDEPS} macros, that
include libname in the base name of the object files.
(func_emit_lib_Makefile_am): Use ${macro_prefix}_${libname}_*LIBOBJS
values instead of ${macro_prefix}_*LIBOBJS values.
* pygnulib/GLEmiter.py (GLEmiter.initmacro_end): Define
{macro_prefix_arg}_{libname}_{LIBOBJS,LTLIBOBJS,LIBOBJDEPS} macros, that
include libname in the base name of the object files.
(GLEmiter.lib_Makefile_am):Use {macro_prefix}_{libname}_*LIBOBJS
values instead of {macro_prefix}_*LIBOBJS values.
Collin Funk [Sat, 25 Jan 2025 05:36:11 +0000 (21:36 -0800)]
ptsname_r: Work around ptsname_r bug on Solaris 11 OmniOS.
* lib/ptsname_r.c (ptsname_r): Ensure the resulting buffer is not
clobbered if it is too small on Solaris 11 OmniOS.
* m4/ptsname_r.m4 (gl_FUNC_PTSNAME_R): On Solaris 11 OmniOS, arrange to
override ptsname_r.
Collin Funk [Sat, 25 Jan 2025 04:38:54 +0000 (20:38 -0800)]
strerrorname_np: Work around a bug on Solaris 11 OmniOS.
* m4/strerrorname_np.m4 (gl_CHECK_STRERRORNAME_NP): Test if
strerrorname_np returns NULL when given ERESTART or ESTRPIPE.
* doc/glibc-functions/strerrorname_np.texi: Document the bug.
Paul Eggert [Sun, 19 Jan 2025 07:02:09 +0000 (23:02 -0800)]
flexmember: port to IBM XL C 16.1
* lib/flexmember.h (FLEXALIGNOF): Use the conservative definition
if _Alignof is a macro, to avoid a C99 conformance issue exposed
by IBM XL C 16.1 which otherwise complains "An aggregate
containing a flexible array member cannot be used as a member of a
structure or as an array element."
Paul Eggert [Sun, 19 Jan 2025 06:06:55 +0000 (22:06 -0800)]
alignasof: port to IBM XL C 16.1
* doc/gnulib.texi (alignof):
Improve doc to match implementation better.
* m4/stdalign.m4 (alignas): Do not define to _Alignas
if __xlC__ claims to conform to C11, because _Alignas fails with
weird diagnostics "Unexpected text %1$s encountered."
* tests/test-alignasof.c (TEST_ALIGNMENT, alignas):
Follow doc advice.
Paul Eggert [Sat, 18 Jan 2025 06:11:54 +0000 (22:11 -0800)]
alignasof: port to IBM XL C V16.1
* m4/stdalign.m4 (gl_ALIGNASOF):
Work around similar bug in IBM XL C V16.1.0 cc (non-clang).
Since this is the last version of this obsolescent compiler,
assume the bug is in earlier versions.
Paul Eggert [Wed, 8 Jan 2025 08:32:23 +0000 (00:32 -0800)]
fcntl-h: port better to musl on GNU/Linux
* lib/fcntl.in.h (O_SEARCH): Redefine to O_RDONLY on musl,
which mistakenly defines it to be O_PATH on GNU/Linux.
Problem reported by Lasse Collin in:
https://bugs.gnu.org/75405
Bruno Haible [Mon, 6 Jan 2025 00:16:11 +0000 (01:16 +0100)]
sigsegv tests: Work around a longjmp bug on GNU/Hurd.
* tests/test-sigsegv-catch-stackoverflow1.c (_FORTIFY_SOURCE,
__USE_FORTIFY_LEVEL): Undefine, as a workaround to the Hurd longjmp bug.
* tests/test-sigsegv-catch-stackoverflow2.c (_FORTIFY_SOURCE,
__USE_FORTIFY_LEVEL): Likewise.
* doc/posix-functions/longjmp.texi: Document the Hurd bug.
Bruno Haible [Tue, 31 Dec 2024 18:38:42 +0000 (19:38 +0100)]
getcwd: Return "/bin" instead of "//bin" on Adélie Linux.
Reported by Zach van Rijn <me@zv.io> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-04/msg00072.html>
and <https://git.adelielinux.org/adelie/packages/-/issues/987>.
* lib/getcwd.c (__getcwd_generic): Remove a trailing slash from the
result of readlink().
Bruno Haible [Sat, 28 Dec 2024 15:47:16 +0000 (16:47 +0100)]
endian: Fix compilation error on NetBSD 7.1.
* m4/endian_h.m4 (gl_ENDIAN_H): Test for <sys/endian.h>. Set
HAVE_SYS_ENDIAN_H.
* lib/endian.in.h: Test HAVE_SYS_ENDIAN_H as an alternative to
HAVE_ENDIAN_H.
* modules/endian (Makefile.am): Substitute HAVE_SYS_ENDIAN_H.
Bruno Haible [Wed, 25 Dec 2024 00:34:23 +0000 (01:34 +0100)]
access, euidaccess tests: Avoid test failure in Cygwin 3.5.5.
* tests/test-access.h [__CYGWIN__]: Include <grp.h>, <string.h>,
<unistd.h>.
(is_administrator): New function.
(is_root): New macro.
(test_access): Reenable F_OK test for non-administrators on Cygwin.
Disable X_OK test for administrators on Cygwin.
Bruno Haible [Tue, 24 Dec 2024 10:22:40 +0000 (11:22 +0100)]
threads-h: Support several gnulib-tool invocations better.
* lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): Rename to a macro
that depends on GUARD_PREFIX.
(struct thrd_with_exitcode): Avoid duplicate definition.
Bruno Haible [Tue, 24 Dec 2024 10:21:51 +0000 (11:21 +0100)]
sys_socket: Support several gnulib-tool invocations better.
* lib/sys_socket.in.h (_GL_ALREADY_INCLUDING_SYS_SOCKET_H): Rename to a
macro that depends on GUARD_PREFIX.
(struct msghdr): Avoid duplicate definition.
Bruno Haible [Tue, 24 Dec 2024 10:19:49 +0000 (11:19 +0100)]
stdio: Support several gnulib-tool invocations better.
* lib/stdio.in.h: Test _GL_SKIP_GNULIB_STDIO_H.
(_GL_ALREADY_INCLUDING_STDIO_H): Rename to a macro that depends on
GUARD_PREFIX.
* lib/fopen.c: Set _GL_SKIP_GNULIB_STDIO_H instead of
_GL_ALREADY_INCLUDING_STDIO_H.
* lib/freopen.c: Likewise.
Paul Eggert [Mon, 23 Dec 2024 20:57:12 +0000 (12:57 -0800)]
stdlib: fix MB_CUR_MAX on older Android
Android NDK r16 MB_CUR_MAX doesn’t link when compiling C.
Problem found in GNU Emacs, which worked around it this way:
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=39a7e6b79fdeafc539a36f6831d922a2622cb679
... but this ran afoul of the recent Gnulib change that
added lib/stdlib.c.
* lib/stdlib.in.h (gl_MB_CUR_MAX): If @REPLACE_MB_CUR_MAX@
is positive, use its value directly.
* m4/stdlib_h.m4 (gl_STDLIB_H): Set REPLACE_MB_CUR_MAX to (-1)
if the Solaris bug, and to 4 if the Android bug.
* tests/test-stdlib.c (main): Check that MB_CUR_MAX compiles
and is nonzero.
Bruno Haible [Mon, 23 Dec 2024 15:57:15 +0000 (16:57 +0100)]
setlocale: Support the UTF-8 environment on native Windows.
* lib/setlocale.c: Include <windows.h>.
(setlocale_unixlike): In the UTF-8 environment, append a suffix ".65001"
to the locale names passed to the native setlocale().
Bruno Haible [Sun, 22 Dec 2024 11:03:22 +0000 (12:03 +0100)]
test-framework-sh: Avoid test suite failures on MSYS2.
* tests/init.sh (compare_) [MSys]: Use a temporary file on MSYS2.
* tests/test-update-copyright.sh: Use the test framework.
(compare): Remove function.
* modules/update-copyright-tests (Depends-on): Add test-framework-sh.
Bruno Haible [Sun, 22 Dec 2024 03:38:48 +0000 (04:38 +0100)]
execl, execle, execlp: Fix compilation error with gcc 14.
* lib/execl.c (execl): Cast second argument of execv.
* lib/execle.c (execle): Cast second argument of execve.
* lib/execlp.c (execlp): Cast second argument of execvp.