Paul Eggert [Fri, 9 Aug 2024 21:33:31 +0000 (14:33 -0700)]
full-read, etc.: prefer signed types
* lib/full-read.h, lib/full-write.h, lib/safe-read.h, lib/safe-write.h:
Include idx.h.
* lib/full-write.c (full_read, full_write):
Now accept and returns idx_t.
* lib/safe-read.c (bufptr): New type, since apps are not
supposed to #define keywords like ‘const’.
(safe_read, safe_write): Now accept idx_t and return ptrdiff_t.
* lib/safe-read.h (SAFE_READ_ERROR):
* lib/safe-write.h (SAFE_WRITE_ERROR):
Now ptrdiff_t, not size_t.
* modules/full-read, modules/full-write, modules/safe-read:
* modules/safe-write (Depends-on): Add idx.
Bruno Haible [Fri, 9 Aug 2024 00:09:03 +0000 (02:09 +0200)]
doc: Update for other functions added in POSIX:2024.
* doc/posix-functions/be16toh.texi: New file.
* doc/posix-functions/be32toh.texi: New file.
* doc/posix-functions/be64toh.texi: New file.
* doc/posix-functions/dcgettext_l.texi: New file.
* doc/posix-functions/dcngettext_l.texi: New file.
* doc/posix-functions/dgettext_l.texi: New file.
* doc/posix-functions/dngettext_l.texi: New file.
* doc/posix-functions/getlocalename_l.texi: New file.
* doc/posix-functions/gettext_l.texi: New file.
* doc/posix-functions/htobe16.texi: New file.
* doc/posix-functions/htobe32.texi: New file.
* doc/posix-functions/htobe64.texi: New file.
* doc/posix-functions/htole16.texi: New file.
* doc/posix-functions/htole32.texi: New file.
* doc/posix-functions/htole64.texi: New file.
* doc/posix-functions/le16toh.texi: New file.
* doc/posix-functions/le32toh.texi: New file.
* doc/posix-functions/le64toh.texi: New file.
* doc/posix-functions/ngettext_l.texi: New file.
* doc/posix-functions/posix_close.texi: New file.
* doc/posix-functions/posix_devctl.texi: New file.
* doc/posix-functions/posix_getdents.texi: New file.
* doc/posix-functions/posix_spawn_file_actions_addchdir.texi: New file.
* doc/posix-functions/posix_spawn_file_actions_addfchdir.texi: New file.
* doc/posix-functions/sig2str.texi: New file.
* doc/posix-functions/str2sig.texi: New file.
* doc/posix-functions/tcgetwinsize.texi: New file.
* doc/posix-functions/tcsetwinsize.texi: New file.
* doc/posix-functions/wcslcat.texi: New file.
* doc/posix-functions/wcslcpy.texi: New file.
* doc/gnulib.texi (Functions in <devctl.h>, Functions in <endian.h>):
New sections.
(Functions in <dirent.h>, Functions in <libintl.h>,
Functions in <locale.h>, Functions in <signal.h>,
Functions in <spawn.h>, Functions in <termios.h>,
Functions in <unistd.h>, Functions in <wchar.h>): Include the other new
files.
* doc/posix-functions/strlcat.texi: Update.
* doc/posix-functions/strlcpy.texi: Update.
Bruno Haible [Thu, 8 Aug 2024 22:15:16 +0000 (00:15 +0200)]
doc: Update for ISO C functions added in POSIX:2024.
* doc/posix-headers/CMPLX*.texi: New files.
* doc/posix-headers/at_quick_exit.texi: New file.
* doc/posix-headers/atomic_*.texi: New files.
* doc/posix-headers/kill_dependency.texi: New file.
* doc/posix-headers/*.texi: Update.
* doc/gnulib.texi (Functions in <stdatomic.h>): New section.
(Functions in <complex.h>, Functions in <stdlib.h>): Include the other
new files.
Bruno Haible [Wed, 7 Aug 2024 22:54:03 +0000 (00:54 +0200)]
Avoid compiler warnings in some configure tests.
* m4/pthread-rwlock.m4 (gl_PTHREAD_RWLOCK): Allocate more room for local
array 'name'.
* m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK): Don't
pass a NULL pointer to pthread_mutex_timedlock.
Bruno Haible [Wed, 7 Aug 2024 17:53:41 +0000 (19:53 +0200)]
pthread-rwlock tests: Strengthen tests.
* tests/test-pthread-rwlock-waitqueue.c: New file.
* modules/pthread-rwlock-tests (Files): Add it.
(Depends-on): Add extensions, nanosleep, stdbool.
(Makefile.am): Arrange to test test-pthread-rwlock-waitqueue.
Bruno Haible [Wed, 7 Aug 2024 17:53:37 +0000 (19:53 +0200)]
pthread-rwlock: Fix default wait queue behaviour on glibc/Linux.
* lib/pthread.in.h: If REPLACE_PTHREAD_RWLOCK_INIT is 1 but
REPLACE_PTHREAD_RWLOCK_DESTROY is 0, override
PTHREAD_RWLOCK_INITIALIZER.
* lib/pthread-rwlock.c
(pthread_rwlockattr_init) [PTHREAD_RWLOCK_BAD_WAITQUEUE]: New function.
(pthread_rwlock_init) [PTHREAD_RWLOCK_BAD_WAITQUEUE]: New function.
* m4/pthread-rwlock.m4 (gl_PTHREAD_RWLOCK): Check for reasonable
pthread_rwlock wait queue handling. Set REPLACE_PTHREAD_RWLOCK_INIT and
REPLACE_PTHREAD_RWLOCKATTR_INIT and define PTHREAD_RWLOCK_BAD_WAITQUEUE
if not.
* modules/pthread-rwlock (configure.ac): Update
GL_COND_OBJ_PTHREAD_RWLOCK condition.
* doc/posix-functions/pthread_rwlock_rdlock.texi: Mark the glibc problem
as fixed.
* doc/posix-functions/pthread_rwlock_tryrdlock.texi: Likewise.
* doc/posix-functions/pthread_rwlock_timedrdlock.texi: Likewise.
Paul Eggert [Wed, 7 Aug 2024 14:23:51 +0000 (07:23 -0700)]
errno-tests: port to GNU/Hurd
Test for errno distinctness dynamically rather than statically,
since the static test blows up the compiler on Hurd.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-08/msg00039.html
Also, test that errno values can all be used in #if,
and improve diagnostics.
* tests/test-errno.c: Include stdio.h, stdlib.h, string.h.
(USABLE_IN_IF): New macro. Use it to check errno values in #if.
(ERRTAB): New macro.
(struct nameval): New type.
(errtab): New global variable.
(errtab_cmp): New function.
(main): Test for errno distinctness dynamically not statically.
Diagnose lack of distinctness better.
Bruno Haible [Tue, 6 Aug 2024 13:43:16 +0000 (15:43 +0200)]
pthread-mutex tests: Strengthen tests.
* tests/test-pthread-mutex-type.c: New file.
* modules/pthread-mutex-tests (Files): Add it.
(Makefile.am): Arrange to test test-pthread-mutex-type.
* doc/posix-functions/pthread_mutex_lock.texi: Mention FreeBSD and
NetBSD problem.
* doc/posix-functions/pthread_mutex_trylock.texi: Likewise.
* lib/windows-mutex.h (glwthread_mutex_t): Add 'owner' field.
* lib/windows-mutex.c: Include <stdlib.h>.
(glwthread_mutex_lock): Set the 'owner' field after entering the
critical section.
(glwthread_mutex_trylock): Detect whether the lock was previously locked
by this thread. Set the 'owner' field after entering the critical
section.
(glwthread_mutex_unlock): Clear the 'owner' field before leaving the
critical section.
* lib/windows-timedmutex.h (glwthread_timedmutex_t): Add 'owner' field.
* lib/windows-timedmutex.c: (glwthread_timedmutex_lock): Set the 'owner'
field after entering the critical section.
(glwthread_timedmutex_trylock): Detect whether the lock was previously
locked by this thread. Set the 'owner' field after entering the critical
section.
(glwthread_timedmutex_unlock): Clear the 'owner' field before leaving
the critical section.
Bruno Haible [Mon, 5 Aug 2024 19:31:28 +0000 (21:31 +0200)]
xstrtol, xstrtoll tests: Fix test failures.
* tests/test-xstrtol.c (is_GNULIB_strtol): New macro.
(main): Use it in the expected test results.
* tests/test-xstrtoll.c (is_GNULIB_strtol): New macro.
In the shell test framework, an error is either flagged by setting
the shell variable fail=1, or by invoking the fail_ function with an
error diagnostic.
* tests/init.sh (returns_): Change example code in the comment to
use '|| fail=1' properly.
Bruno Haible [Sat, 3 Aug 2024 15:04:55 +0000 (17:04 +0200)]
gnulib-tool.py: Small refactoring.
Suggested by Collin Funk.
* pygnulib/GLModuleSystem.py (GLModule.getDependenciesRecursively):
Return a set of GLModule.
* pygnulib/main.py (main): Convert the result to a string here.
Bruno Haible [Thu, 1 Aug 2024 14:41:23 +0000 (16:41 +0200)]
math: Fix INFINITY and NAN on FreeBSD and AIX.
* doc/posix-headers/math.texi: Mention some FreeBSD and AIX bugs.
* lib/math.in.h (INFINITY): New macro.
(NAN): Replace also on FreeBSD < 8 and AIX. Use __builtin_nanf where
available.
(HUGE_VALF): Replace also on FreeBSD < 6. Use __builtin_inff where
available.
(HUGE_VAL): Replace also on FreeBSD < 6. Use __builtin_inf where
available.
(HUGE_VALL): Replace also on FreeBSD < 6. Use __builtin_infl where
available.
* tests/test-math.c: Check that INFINITY, NAN, HUGE_VALF, HUGE_VAL,
HUGE_VALL are constant expressions.
(main): Check the type of INFINITY and NAN.
Bruno Haible [Thu, 1 Aug 2024 11:24:10 +0000 (13:24 +0200)]
strerror_r: Fix for AIX (regression yesterday).
* lib/strerror_r.c: Ignore the value of STRERROR_R_CHAR_P on AIX.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Don't define
_LINUX_SOURCE_COMPAT, since it provides no advantage for strerror_r.
Paul Eggert [Thu, 1 Aug 2024 00:10:56 +0000 (17:10 -0700)]
errno: make EEXIST != ENOTEMPTY on AIX
Also, improve errno tests.
* m4/calloc.m4 (gl_FUNC_CALLOC_GNU):
* m4/malloc.m4 (gl_FUNC_MALLOC_GNU):
* m4/realloc.m4 (gl_FUNC_REALLOC_GNU):
* m4/scandir.m4 (gl_FUNC_SCANDIR):
Define _LINUX_SOURCE_COMPAT, as this can sometimes help on AIX.
* m4/errno_h.m4 (gl_HEADER_ERRNO_H):
Define _LINUX_SOURCE_COMPAT, to make EEXIST != ENOTEMPTY.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R):
Define _LINUX_SOURCE_COMPAT, in case someone else does.
* modules/errno-tests (Depends-on): Add assert-h, c99.
* tests/test-errno.c (e1, ..., e131): Remove, replacing with ...
(CHECK_POSIX_ERRNOS, POSITIVE_INTEGER_CONSTANT_EXPRESSION)
(INDEXED_BY_ERRNO, ERRNO_COUNT): These new macros.
Check that all errno values are positive integer constant expressions.
Check that they are all distinct, except perhaps for
EWOULDBLOCK == EAGAIN and ENOTSUP == EOPNOTSUPP.
Also check ESOCKTNOSUPPORT, added in POSIX.1-2024.
Also, check that errno values are distinct except when POSIX says
they needn’t be distinct, since POSIX.1-2024 gives license to
GNU/Linux’s non-distinct values.
Bruno Haible [Tue, 30 Jul 2024 00:02:43 +0000 (02:02 +0200)]
Avoid g++ "warning: attributes are not permitted in this position".
* m4/gnulib-common.m4 (gl_COMMON_BODY): Add more comments. Define
_GL_BRACKET_USABLE. Use it for _GL_ATTRIBUTE_DEPRECATED,
_GL_ATTRIBUTE_MAYBE_UNUSED, _GL_ATTRIBUTE_NODISCARD,
_GL_ATTRIBUTE_REPRODUCIBLE, _GL_ATTRIBUTE_UNSEQUENCED.
* lib/stdio.in.h (aszprintf, vaszprintf, asprintf, vasprintf): Move
_GL_ATTRIBUTE_NODISCARD to the same position as the other attributes.
* lib/c-vasprintf.h (c_aszprintf, c_vaszprintf, c_asprintf,
c_vasprintf): Likewise.
Bruno Haible [Sun, 28 Jul 2024 21:52:04 +0000 (23:52 +0200)]
gnulib-tool.py: Avoid adding specific modules to a testdir.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00292.html>.
* pygnulib/GLInfo.py (GLInfo.usage): Document
--extract-usability-in-testdir option.
* pygnulib/GLModuleSystem.py (GLModule.section_label_pattern): Recognize
Usable-in-testdir section.
(GLModule.getUsabilityInTestdir): New function.
* pygnulib/GLTestDir.py (GLTestDir.execute): Invoke it to filter out
modules to avoid. Warn if such a module was specified.
* pygnulib/main.py (main): Add support for
--extract-usability-in-testdir. Provide an error message for error 24.
* pygnulib/GLError.py: Likewise.
* modules/config-h (Usable-in-testdir): New section.
* modules/lib-ignore (Usable-in-testdir): New section.
* modules/mountlist (Usable-in-testdir): New section.
* modules/non-recursive-gnulib-prefix-hack (Usable-in-testdir): New
section.
* modules/timevar (Usable-in-testdir): New section.
(Files): Remove lib/timevar.def.
Bruno Haible [Sun, 28 Jul 2024 21:38:45 +0000 (23:38 +0200)]
gnulib-tool.py: Fix an exception message.
* pygnulib/GLModuleSystem.py (GLModuleSystem.find): Raise error 23,
not 3.
* pygnulib/GLError.py: Provide an error message for error 23.
* pygnulib/main.py: Likewise.
Paul Eggert [Sun, 28 Jul 2024 19:37:13 +0000 (12:37 -0700)]
maint: remove ‘coding: utf-8’ on ASCII
These days, ‘coding: utf-8’ tags aren’t needed in general,
as Emacs typically defaults to UTF-8, and Emacs itself now
has many untagged source files in UTF-8. However, for now let’s
just remove the tags when they are on ASCII files.
* lib/md5-stream.c, lib/sha1-stream.c, lib/sha256-stream.c:
* lib/sm3-stream.c: Remove unnecessary coding: lines.
Paul Eggert [Sun, 28 Jul 2024 19:11:30 +0000 (12:11 -0700)]
std-gnu23: new module
The plan is to update the c99 module to depend on std-gnu23
instead of on std-gnu11, and to make std-gnu11 obsolete.
A benefit of this will be that c99 will no longer affect C++.
For now, though, std-gnu23 is simply a new, optional module.
* MODULES.html.sh (func_all_modules): Add it.
* modules/std-gnu11: Change description.
* modules/std-gnu23, m4/std-gnu23.m4: New files.
* m4/std-gnu11.m4: Do nothing if _AC_C_C23_OPTIONS is defined.
(AC_PROG_CC): Use AC_DEFUN, not AC_DEFUN_ONCE, so that
we can be superseded.
Paul Eggert [Sun, 28 Jul 2024 17:07:36 +0000 (10:07 -0700)]
strftime: improve doc
* lib/strftime.h: In comment, use active voice, reword errno
description for clarity, and omit reference to draft POSIX 202x to
simplify future maintenance.
Bruno Haible [Fri, 26 Jul 2024 11:04:09 +0000 (13:04 +0200)]
sys_un: Avoid compilation error in C++ <string.h> on glibc systems.
* m4/sys_un_h.m4 (gl_SYS_UN_H): Require AC_CANONICAL_HOST. Set
GL_GENERATE_SYS_UN_H to true on glibc systems. Invoke
gl_CHECK_NEXT_HEADERS. Initialize HAVE_SYS_UN_H.
* lib/sys_un.in.h: Use include_next and a split double-inclusion guard.
In C++ mode, include <stddef.h> and <string.h> first.
* modules/sys_un (Depends-on): Add include_next.
(Makefile.am): Substitute INCLUDE_NEXT, PRAGMA_SYSTEM_HEADER,
PRAGMA_COLUMNS, NEXT_SYS_UN_H, HAVE_SYS_UN_H. Arrange to remove 'sys'
directory at "make mostlyclean".
Paul Eggert [Fri, 26 Jul 2024 00:24:20 +0000 (17:24 -0700)]
xstrtol: remove the base-checking changes
* lib/xstrtol.c (__xstrtol): Stop worrying about hypothetical
implementations that are causing more confusion than the code is
worth. Instead, go back more to old way of doing things.
None of this matters for practical applications.
* lib/xstrtol.h: Document that behavior is undefined
if the base is negative, 1, or greater than 36.
* modules/xstrtol (Depends-on): Remove nullptr; no longer needed.
Bruno Haible [Thu, 25 Jul 2024 20:05:18 +0000 (22:05 +0200)]
xstrtol, xstrtoll tests: Test behaviour for an invalid base.
Reported by Alejandro Colomar <alx@kernel.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00249.html>.
* modules/xstrtol-tests (Files): Add tests/macros.h.
* modules/xstrtoll-tests (Files): Likewise.
* tests/test-xstrtol.c: Include macros.h.
(main): If no arguments are given on the command line, perform
miscellaneous tests.
* tests/test-xstrtol.sh: Also invoke test-xstrtol without arguments.
* tests/test-xstrtoll.sh: Also invoke test-xstrtoll without arguments.
* modules/select (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/sys_select.in.h (select): Don't define to
select_used_without_requesting_gnulib_module_select if the gnulib module
'select' is in use under the same configure.ac.
* modules/shutdown (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/sys_socket.in.h (shutdown): Don't define to
shutdown_used_without_requesting_gnulib_module_shutdown if the gnulib
module 'shutdown' is in use under the same configure.ac.