* lib/renameatu.c(): Fall back to renameat() when
renameatx_np(RENAME_EXCL) returns "Function not implemented".
This issue was seen with macFUSE.
Reported at https://github.com/coreutils/coreutils/issues/79
Paul Eggert [Fri, 29 Mar 2024 22:56:45 +0000 (15:56 -0700)]
intprops: pacify GCC < 10 -Wsign-compare
Problem reported by Martin Dorey in:
https://savannah.gnu.org/bugs/index.php?65537
* lib/intprops-internal.h (_GL_INT_MULTIPLY_WRAPV):
When working around GCC bug 91450, pacify -Wsign-compare by
casting 0 to the result type.
Bruno Haible [Tue, 5 Mar 2024 16:10:38 +0000 (17:10 +0100)]
c-strtod, c-strtold: Make multithread-safe.
* lib/c-strtod.c: Include <langinfo.h>, c-ctype.h.
(decimal_point_char): New function, copied from lib/vasnprintf.c.
(C_STRTOD): On platforms that don't have STRTOD_L nor a working
uselocale(), pre-parse the number and call STRTOD after having replaced
the '.' with the locale-dependent decimal point character.
* m4/c-strtod.m4 (gl_C_STRTOD, gl_C_STRTOLD): Test for nl_langinfo().
* modules/c-strtod (Depends-on): Add c-ctype. Remove strdup-posix.
* modules/c-strtold (Depends-on): Likewise.
Bruno Haible [Wed, 14 Feb 2024 22:16:15 +0000 (23:16 +0100)]
Improve support of Citrus/FreeBSD iconv.
* lib/striconveh.c (iconveh_open): Use //TRANSLIT with all iconv
implementations that support it.
* lib/striconveha.c (mem_iconveha, str_iconveha): Likewise.
* lib/propername.c (proper_name_utf8): Likewise.
* m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK): Pass
a pointer of the correct type to pthread_mutex_timedlock.
* m4/pthread-spin.m4 (gl_PTHREAD_SPIN): Pass a pointer of the correct
type to pthread_spin_init.
Bruno Haible [Tue, 6 Feb 2024 20:59:01 +0000 (21:59 +0100)]
nl_langinfo: Fix fallback list of month names (regression 2014-07-07).
* lib/nl_langinfo.c (nl_langinfo): In the implementation for native
Windows, fix the results for MON_8..MON_12, ALTMON_8..ALTMON_12,
ABMON_8..ABMON_12.
Paul Eggert [Sat, 3 Feb 2024 20:05:17 +0000 (12:05 -0800)]
ctime: fix false positive
Problem reported by Bjarni Ingi Gislason in:
https://lists.gnu.org/r/bug-gnulib/2024-02/msg00006.html
* lib/time.in.h (ctime): Do not warn about ctime portability,
as there is a more serious warning about it crashing,
and the two warning directives can cause false alarms.
Bruno Haible [Mon, 29 Jan 2024 17:26:41 +0000 (18:26 +0100)]
Port FALLTHROUGH to Mac OS X 10.9.
Report and fix by Ryan Carsten Schmidt <gnulib@ryandesign.com>
at <https://savannah.gnu.org/bugs/?63866>.
* m4/gnulib-common.m4 (gl_COMMON_BODY): For _GL_HAS_ATTRIBUTE, don't use
__has_attribute for Apple clang versions < 7000000.
* lib/cdefs.h (__glibc_has_attribute): Don't use __has_attribute for
Apple clang versions < 7000000.
Bruno Haible [Sun, 28 Jan 2024 19:23:10 +0000 (20:23 +0100)]
host-cpu-c-abi: Let gl_HOST_CPU_C_ABI_32BIT never return 'unknown'.
Reported by Mohammad-Reza Nabipoor <mnabipoor@gnu.org>.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI_32BIT): Use the list of
always-32-bit CPUs and the list of always-64-bit CPUs also when
gl_HOST_CPU_C_ABI has already been run. As a fallback, use a test of
'sizeof (void *)' to always return 'yes' or 'no', never 'unknown'.
Bruno Haible [Fri, 26 Jan 2024 00:12:08 +0000 (01:12 +0100)]
execute tests: Avoid test failure on macOS 14.
Reported by Guangyu Li <gl343@cornell.edu> in
<https://lists.gnu.org/archive/html/bug-gettext/2024-01/msg00006.html>.
* tests/test-execute-main.c (main): In the tests 17, 18, 19, 20, use the
file descriptors 15, 16 instead of 10, 11, respectively.
* tests/test-execute-child.c (main): Likewise.
Bruno Haible [Thu, 25 Jan 2024 23:55:45 +0000 (00:55 +0100)]
Resolve conflicts for functions introduced in Android API level 35.
* lib/time.in.h (timespec_getres): Consider REPLACE_TIMESPEC_GETRES.
* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GETRES.
* modules/time-h (Makefile.am): Substitute REPLACE_TIMESPEC_GETRES.
* m4/timespec_getres.m4 (gl_FUNC_TIMESPEC_GETRES): Test for
timespec_getres using gl_CHECK_FUNCS_ANDROID instead of
AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_TIMESPEC_GETRES.
* modules/timespec_getres (Depends-on, configure.ac): Consider
REPLACE_TIMESPEC_GETRES.
* m4/gettime.m4 (gl_GETTIME_RES): Test for timespec_getres using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* doc/posix-functions/timespec_getres.texi: Mention the Android API
levels.
Bruno Haible [Thu, 25 Jan 2024 23:18:55 +0000 (00:18 +0100)]
Resolve conflicts for functions introduced in Android API level 34.
* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE): On platforms without
glibc, test for copy_file_range using gl_CHECK_FUNCS_ANDROID instead of
AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_COPY_FILE_RANGE.
* doc/glibc-functions/copy_file_range.texi: Mention the Android API
levels.
Bruno Haible [Thu, 25 Jan 2024 23:18:52 +0000 (00:18 +0100)]
Resolve conflicts for functions introduced in Android API level 34.
* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test for
posix_spawn_file_actions_addchdir_np and
posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
* m4/posix_spawn_faction_addchdir.m4
(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR): Test for
posix_spawn_file_actions_addchdir_np using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
* m4/posix_spawn_faction_addfchdir.m4
(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR): Test for
posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
* doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi: Mention
the Android API levels.
* doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi:
Likewise.
Bruno Haible [Thu, 25 Jan 2024 23:18:45 +0000 (00:18 +0100)]
Resolve conflicts for functions introduced in Android API level 34.
* m4/freadahead.m4 (gl_FUNC_FREADAHEAD): Test for __freadahead using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* lib/freadahead.h: Update comment.
Bruno Haible [Fri, 19 Jan 2024 21:58:43 +0000 (22:58 +0100)]
fenv-environment: Fix for NetBSD/powerpc.
* m4/fenv-environment.m4 (gl_FENV_ENVIRONMENT): For feupdateenv, use
the same configure test on NetBSD/powerpc as on glibc/hppa.
* doc/posix-functions/feupdateenv.texi: Mention the NetBSD/powerpc bug.
Bruno Haible [Fri, 19 Jan 2024 21:34:27 +0000 (22:34 +0100)]
fenv-exceptions-state-c99: Fix for FreeBSD/powerpc64 and NetBSD/powerpc.
* m4/fenv-exceptions-state.m4 (gl_FENV_EXCEPTIONS_STATE): On
FreeBSD/powerpc64 and NetBSD/powerpc, set REPLACE_FESETEXCEPTFLAG.
* doc/posix-functions/fesetexceptflag.texi: Mention the FreeBSD and
NetBSD bug.
Bruno Haible [Fri, 19 Jan 2024 09:55:13 +0000 (10:55 +0100)]
fenv-*: Avoid test failures on OpenBSD/sparc64.
* tests/test-fenv-except-tracking-2.c (main): On OpenBSD/sparc64, skip
the 'long double' test.
* tests/test-fenv-except-trapping-2.c (main): Skip the 'long double'
tests also on OpenBSD/sparc64.
Paul Eggert [Wed, 17 Jan 2024 01:21:08 +0000 (17:21 -0800)]
posixtm: pacify clang 18
Problem reported by Khem Raj in:
https://lists.gnu.org/r/bug-gnulib/2024-01/msg00045.html
* lib/posixtm.c (posixtime): Pacify clang 18 by converting bool to int.
Arguably this is a bug in draft C2x, since the non-pointer args to
ckd_add should promote just like any other expressions do;
but that’s not clang’s fault.
Bruno Haible [Wed, 10 Jan 2024 14:26:53 +0000 (15:26 +0100)]
jit/cache: Fix for arm CPUs with GCC target arm-linux-gnueabihf.
* tests/jit/test-cache.c (CODE): Define differently on arm.
(SET_CODE, IS, SET_IS): New macros.
(main): New variables is_of_return1, is_of_return2. Use the SET_CODE and
SET_IS macros.
Bruno Haible [Tue, 9 Jan 2024 20:10:19 +0000 (21:10 +0100)]
jit/cache tests: Avoid test failure on OpenBSD.
* tests/jit/test-cache.c (return1_code, return2_code): New constants.
(main): On OpenBSD, use return1_code and return2_code instead of
CODE (return1) and CODE (return2), since the latter may not be in a
readable memory area.
Bruno Haible [Tue, 9 Jan 2024 15:56:08 +0000 (16:56 +0100)]
jit/cache tests: Avoid test failure on hppa CPUs.
* tests/jit/test-cache.c (FUNCPTR_BIAS): New macro.
(structptr_to_funcptr, funcptr_to_structptr): New functions/macros.
(xcopy_structptr): Renamed from xcopy_funcptr. Mark as inline.
(COPY_FUNCPTR, CODE): Use structptr_to_funcptr, funcptr_to_structptr.
* modules/jit/cache-tests (configure.ac): Require AC_C_INLINE.
Bruno Haible [Mon, 8 Jan 2024 21:48:46 +0000 (22:48 +0100)]
jit/cache tests: Fix for powerpc*, ia64, hppa* CPUs.
* modules/jit/cache-tests (Depends-on): Add xalloc.
* tests/jit/test-cache.c: Include xalloc.h.
(FUNCPTR_POINTS_TO_CODE, COPY_FUNCPTR): New macros.
(xcopy_funcptr): New function.
(main): Create a copy of the function pointer return1, so as not to
destructively modify return1. Fix memcpy argument.
Bruno Haible [Mon, 8 Jan 2024 17:10:28 +0000 (18:10 +0100)]
jit/cache tests: Avoid test failure on OpenBSD.
* modules/jit/cache-tests (Files): Add m4/warnings.m4.
(configure.ac): Set and substitute DISABLE_OPENBSD_RETGUARD.
(Makefile.am): Set test_cache_CFLAGS.
* tests/jit/test-cache.c (main): If the compiler defines _RET_PROTECTOR,
skip the test.
Bruno Haible [Tue, 2 Jan 2024 10:37:05 +0000 (11:37 +0100)]
strverscmp: Work around bug in musl libc 1.2.3 and in Cygwin.
Reported by Dmitry Bogatov <KAction@gnu.org> via Simon Josefsson in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-01/msg00002.html>.
* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STRVERSCMP.
* m4/strverscmp.m4 (gl_FUNC_STRVERSCMP): Test whether strverscmp works
and set REPLACE_STRVERSCMP if not.
* lib/string.in.h (strverscmp): Consider REPLACE_STRVERSCMP.
* modules/strverscmp (Depends-on, configure.ac): Likewise.
* modules/string (Makefile.am): Substitute REPLACE_STRVERSCMP.
* tests/test-strverscmp.c (main): Add test cases suggested by Dmitry
Bogatov and by Simon Josefsson.
* doc/glibc-functions/strverscmp.texi: Mention the musl and Cygwin bug.
Update version info regarding FreeBSD.
Paul Eggert [Tue, 2 Jan 2024 00:51:51 +0000 (16:51 -0800)]
update-copyright-tests: immunize against self
Problem reported by Bernhard Voelker in:
https://lists.gnu.org/r/bug-gnulib/2024-01/msg00003.html
* tests/test-update-copyright.sh (ight): New var.
Use it in tests, to prevent update-copyright from
messing with the test data.
* m4/gnulib-common.m4 (gl_CC_GNULIB_WARNINGS): Pass
-Wno-tautological-constant-out-of-range-compare to clang, as it’s
the warning is enabled by default and in portable code where type
ranges are platform dependent it is generally more trouble than
it’s worth.
Without this change, Ubuntu clang version 16.0.6 (15) issues
warnings like this: “In file included from xalloc-die.c:25:
./error.h:28:3: warning: #include_next in file found relative to
primary source file or found by absolute path; will search from
start of include path [-Winclude-next-absolute-path]”.
And sure enough, each file includes itself rather than the
next include file and it’s only the subsidiary include that
gets around to including the next include file.
* lib/argmatch.c, lib/chdir-long.c, lib/clean-temp-simple.c:
* lib/clean-temp.c, lib/closein.c, lib/closeout.c, lib/copy-acl.c:
* lib/copy-file.c, lib/creat.c, lib/csharpcomp.c:
* lib/csharpexec.c, lib/error.c, lib/exclude.c, lib/execute.c:
* lib/faccessat.c, lib/fopen.c, lib/freopen.c, lib/getopt.c:
* lib/getopt1.c, lib/git-merge-changelog.c, lib/javacomp.c:
* lib/javaexec.c, lib/javaversion.c, lib/mkdir-p.c, lib/open.c:
* lib/openat-die.c, lib/openat.c, lib/os2-spawn.c:
* lib/pagealign_alloc.c, lib/pipe-filter-gi.c:
* lib/pipe-filter-ii.c, lib/same.c, lib/set-acl.c:
* lib/sigpipe-die.c, lib/spawn-pipe.c, lib/sys_socket.c, lib/truncate.c:
* lib/unistd.c, lib/verror.c, lib/wait-process.c, lib/wctype-h.c:
* lib/xalloc-die.c, lib/xfreopen.c, lib/xmemcoll.c, lib/xprintf.c:
* lib/xsetenv.c, lib/xstdopen.c, lib/xstrtol-error.c:
Use ‘#include <foo.h>’ instead of ‘#include "foo.h"’ if foo.h
possibly uses #include_next. (However, don’t do this on OSF/1
which has its own problems.)
Paul Eggert [Thu, 28 Dec 2023 19:15:56 +0000 (11:15 -0800)]
stat-time: fix macOS bug with negative file times
macOS has a bug similar (but not identical) to Solaris when
file timestamps are negative: tv_nsec might go negative.
Problem reported on Darwin 8.11.0 for GNU Tar by Gordon Steemson in:
https://lists.gnu.org/r/bug-tar/2023-12/msg00001.html
This was evidently Mac OS X 10.4.11; I reproduced it on
Darwin 21.6.0 (macOS 12.5).
* lib/stat-time.h (STAT_TIMESPEC_OFFSETOF): New macro.
(stat_time_normalize): Also normalize timestamps on macOS.
* m4/fstat.m4 (gl_FUNC_FSTAT):
* m4/fstatat.m4 (gl_FUNC_FSTATAT):
* m4/lstat.m4 (gl_FUNC_LSTAT):
* m4/stat.m4 (gl_FUNC_STAT):
Also replace on macOS.
* tests/jit/test-cache.c (CODE): New macro.
(struct func): New type.
(main): Initialize f more carefully.
* modules/jit/cache-tests (Depends-on): Add host-cpu-c-abi.
selinux-h: add stubs and wrappers for raw counterparts
Add stubs and wrappers of already covered libselinux interfaces for
their `raw` counterparts. These counterparts perform the same
operation expect for context translation. Context translation is used
to convert SELinux MCS/MLS labels into human readable form, see
mcstransd(8).
* lib/se-selinux.in.h: Add declarations for raw variants.
* lib/se-label.in.h: Likewise.
* lib/getfilecon.c: Add wrappers for problematic raw variants.
* m4/selinux-selinux-h.m4: Use wrappers for problematic raw variants.
Paul Eggert [Tue, 12 Dec 2023 01:47:38 +0000 (17:47 -0800)]
savedir: scale better when sorting by name
* lib/savedir.c: Include attribute.h.
(direntry_t): The ‘name’ member is now idx_t, not char *,
so that it survives name_space relocation.
(direntry_cmp_name, direntry_cmp_inode, comparison_function):
Adjust to qsort_r API, and to direntry_t layout change.
(streamsavedir): Redo to avoid need for xstrdup on each directory
entry. Instead, copy the string data into name_space; this
typically scales better the memory allocator is called O(log N)
rather than O(N) times. Use qsort_r so that name_space can be
passed to the comparison functions. Simplify calls to ‘free’ so
that lack of leakage is more obvious.
* modules/savedir (Depends-on): Add attribute, qsort_r.
Paul Eggert [Mon, 11 Dec 2023 18:57:06 +0000 (10:57 -0800)]
getopt: pacify gcc -Wanalyzer-null-dereference
* lib/getopt.c (process_long_option): Simplify logic slightly.
This pacifies gcc -flto -Wanalyzer-null-dereference when compiling
GNU tar on x86-64 with gcc 13.2.1 20231205 (Red Hat 13.2.1-6).
Pádraig Brady [Sun, 10 Dec 2023 14:46:58 +0000 (14:46 +0000)]
bootstrap: fix option propagation with --bootstrap-sync
* top/bootstrap: Ensure options are propagated through
upgrade_bootstrap().
* top/bootstrap-funclib.sh: Likewise.
* build-aux/bootstrap: Auto generated with `make build-aux/bootstrap`.
Fixes https://bugs.gnu.org/67731
Paul Eggert [Sat, 2 Dec 2023 06:19:22 +0000 (22:19 -0800)]
frexp: pacify clang re address-of-volatile
Problem reported by Sam James in:
https://lists.gnu.org/r/bug-gnulib/2023-12/msg00013.html
* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Don’t try to convert
‘double volatile *’ to ‘void const *’ as the C standard
doesn’t allow accessing volatile variables through
pointer-to-nonvolatile.
* m4/frexpf.m4 (gl_FUNC_FREXPF_WORKS): Likewise.
Paul Eggert [Fri, 1 Dec 2023 20:17:32 +0000 (12:17 -0800)]
Update portability doc for CHERI, C23
* doc/gnulib-readme.texi:
Prefer “null pointer” to “@code{NULL}” since C23 has nullptr.
(Portability guidelines): Mention C99 instead of C89 for what
Gnulib assumes of headers.
(C99 features avoided): Mention CHERI issue with intptr_t etc.
(Other portability assumptions): Say that C23 requires two’s
complement. Mention CHERI’s holes.