Bruno Haible [Thu, 30 May 2024 08:23:22 +0000 (10:23 +0200)]
windows-once: Free allocated resources when done.
Based on an observation regarding Cygwin's pthread_once implementation
by Takashi Yano <takashi.yano@nifty.ne.jp> at
<https://cygwin.com/pipermail/cygwin/2024-January/255182.html> and
<https://cygwin.com/pipermail/cygwin-patches/2024q1/012600.html>
* lib/windows-once.h (glwthread_once_t): Change type of inited to LONG.
Add field 'num_threads'.
(GLWTHREAD_ONCE_INIT): Initialize it to zero.
* lib/windows-once.c (glwthread_once): Use InterlockedCompareExchange
instead of InterlockedIncrement. Increment num_threads while the thread
uses the lock. Let the last thread that uses the lock destroy it.
Bruno Haible [Thu, 30 May 2024 08:55:40 +0000 (10:55 +0200)]
call_once: Work around Cygwin 3.5.3 bug.
* m4/call_once.m4 (gl_FUNC_CALL_ONCE): Require AC_CANONICAL_HOST.
On Cygwin, set REPLACE_CALL_ONCE to 1.
* lib/call_once.c (call_once): On Cygwin, use a cast, to avoid a
compiler warning.
* modules/call_once (Depends-on): Add pthread-once.
* doc/posix-functions/call_once.texi: Mention the Cygwin bug.
Bruno Haible [Tue, 28 May 2024 20:35:54 +0000 (22:35 +0200)]
pthread-once: Work around Cygwin 3.5.3 bug.
* m4/pthread-once.m4 (gl_PTHREAD_ONCE): On Cygwin, set
REPLACE_PTHREAD_ONCE to 1.
* lib/pthread-once.c (pthread_once): Add an implementation for Cygwin.
* doc/posix-functions/pthread_once.texi: Mention the Cygwin bug.
Bruno Haible [Wed, 29 May 2024 12:13:33 +0000 (14:13 +0200)]
mbfile tests: Avoid test failure on mingw.
* tests/test-mbfile.c: Include <string.h>, localcharset.h.
(main): Verify that setlocale() has installed an UTF-8 locale.
* modules/mbfile-tests (Depends-on): Add localcharset.
Bruno Haible [Mon, 27 May 2024 21:29:36 +0000 (23:29 +0200)]
nstrftime: Make %r work on macOS, FreeBSD, native Windows.
* doc/posix-functions/strftime.texi: Mention the %r problem.
* lib/nstrftime.c (__strftime_internal): On macOS, FreeBSD, and native
Windows, for %r, use the English AM/PM format.
Bruno Haible [Mon, 27 May 2024 21:01:50 +0000 (23:01 +0200)]
nstrftime: Make %c work on native Windows.
* doc/posix-functions/strftime.texi: Mention the %c problem.
* lib/nstrftime.c: Include <locale.h>. Include hard-locale.h.
(__strftime_internal): For %c, use a subformat that contains the weekday
name (or abbrev.) and the month name (or abbrev.).
* modules/nstrftime (Depends-on): Add hard-locale.
(Link): New section.
* modules/nstrftime-tests (Makefile.am): Link test-nstrftime with
$(HARD_LOCALE_LIB).
Bruno Haible [Mon, 27 May 2024 15:42:20 +0000 (17:42 +0200)]
parse-datetime tests: Avoid failure on native Windows.
* tests/test-parse-datetime.c (SOME_TIMEPOINT): New macro.
(main): Use it. On native Windows, use Windows time zone names.
Invoke tzset() after setting TZ.
* doc/posix-functions/gmtime.texi: Mention the native Windows problem.
* doc/posix-functions/localtime.texi: Likewise.
Collin Funk [Sat, 25 May 2024 02:23:25 +0000 (19:23 -0700)]
boot-time, readutmp: Add a Native Windows boot time fallback.
* lib/boot-time-aux.h (initialize, get_windows_boot_time_fallback): New
functions.
* lib/boot-time.c [_WIN32 && !__CYGWIN__]: Include Windows headers and
<sys/time.h>.
(get_boot_time_uncached): Use the fallback.
* lib/readutmp.c [_WIN32 && !__CYGWIN__]: Include Windows headers and
<sys/time.h>.
(read_utmp_from_file): Use the fallback.
* modules/boot-time (Depends-on): Add gettimeofday.
* modules/readutmp (Depends-on): Add gettimeofday.
Bruno Haible [Thu, 23 May 2024 21:46:52 +0000 (23:46 +0200)]
mbrtoc32: Work around bug in Cygwin 3.5.3.
* m4/mbrtoc32.m4 (gl_MBRTOC32_UTF8_LOCALE): New macro.
(gl_FUNC_MBRTOC32): Invoke it. If mbrtoc32 has this bug, define
MBRTOC32_MULTIBYTE_LOCALE_BUG and reset LOCALE_ZH_CN to 'none'.
* lib/mbrtoc32.c (mbrtoc32): Test MBRTOC32_MULTIBYTE_LOCALE_BUG.
* doc/posix-functions/mbrtoc32.texi: Mention the Cygwin bug.
Bruno Haible [Thu, 23 May 2024 13:15:40 +0000 (15:15 +0200)]
renameatu: Work around Cygwin 3.4.6 bug.
* m4/renameat.m4 (gl_FUNC_RENAMEAT): Test whether renameat2 works, and
define HAVE_WORKING_RENAMEAT2 if so.
* lib/renameatu.c (renameatu): Test HAVE_WORKING_RENAMEAT2 instead of
HAVE_RENAMEAT2.
Bruno Haible [Wed, 22 May 2024 23:10:18 +0000 (01:10 +0200)]
iconv: Reject the broken macOS 14.4 iconv implementation.
Reported by Daniel Collins <solemnwarning@solemnwarning.net> at
<https://savannah.gnu.org/bugs/?65686>.
* m4/iconv.m4 (AM_ICONV_LINK): In the test "for working iconv", test
against the macOS 14.4 iconv bug.
* doc/posix-functions/iconv.texi: Document the bug.
Bruno Haible [Mon, 20 May 2024 22:33:55 +0000 (00:33 +0200)]
vasnprintf: Don't abort for pseudo-denormal arguments on macOS 12.
Reported by Gaëtan Herfray <g.herfray@gahfy.io> via Erik Blake in
<https://lists.gnu.org/archive/html/bug-m4/2022-03/msg00002.html>
<https://lists.gnu.org/archive/html/bug-gnulib/2022-03/msg00066.html>.
* lib/vasnprintf.c (safe_frexpl): New function.
(decode_long_double, floorlog10l): Invoke it instead of frexpl.
Paul Eggert [Mon, 20 May 2024 21:55:11 +0000 (14:55 -0700)]
getopt-posix: port better to Alpine 3.20.0_rc1
Alpine’s <sys/cdefs.h> is a stub that issues a deprecation #warning.
* m4/getopt.m4 (gl_GETOPT_SUBSTITUTE_HEADER):
* m4/sched_h.m4 (gl_SCHED_H): Use the new macro
gl_CHECK_HEADER_SYS_CDEFS_H instead of checking independently.
* m4/sys_cdefs_h.m4: New file.
* modules/getopt-posix, modules/sched (Files): Add m4/sys_cdefs_h.m4.
Collin Funk [Mon, 20 May 2024 21:23:41 +0000 (14:23 -0700)]
utimensat, utimens: Work around NetBSD 10.0 bugs.
* lib/utimens.c (fdutimens): Work around a NetBSD 10.0 UTIME_OMIT bug in
the same way as Linux kernel 2.6.32 and Solaris 11.1.
(lutimens): Likewise.
* lib/utimensat.c (rpl_utimensat): Likewise. Workaround a NetBSD 10.0
bug where invalid tv_nsec values are not rejected in the same way as
Linux kernel 2.6.22.19 on hppa.
* doc/posix-functions/utimensat.texi: Document the invalid tv_nsec bug.
Bruno Haible [Thu, 9 May 2024 12:01:10 +0000 (14:01 +0200)]
explicit_bzero, memset_explicit tests: Avoid test failures with ASAN.
* tests/test-explicit_bzero.c (test_heap, test_stack): Define to empty
if ASAN is enabled.
* tests/test-memset_explicit.c (test_heap, test_stack): Likewise.
Bruno Haible [Thu, 9 May 2024 10:56:55 +0000 (12:56 +0200)]
dprintf-posix, fprintf-posix tests: Avoid test failures with ASAN.
* tests/test-dprintf-posix2.c (main): Skip the test if ASAN is enabled.
* tests/test-fprintf-posix3.c (main): Likewise.
* tests/test-dprintf-posix2.sh: Update.
* tests/test-fprintf-posix3.sh: Likewise.
Bruno Haible [Wed, 8 May 2024 23:41:52 +0000 (01:41 +0200)]
sigsegv, c-stack tests: Avoid test failures with ASAN.
* tests/test-sigsegv-catch-stackoverflow1.c
(HAVE_STACK_OVERFLOW_RECOVERY): Undefine if ASAN is enabled.
* tests/test-sigsegv-catch-stackoverflow2.c
(HAVE_STACK_OVERFLOW_RECOVERY): Likewise.
* tests/test-c-stack.c (main): Skip the test if ASAN is enabled.
Bruno Haible [Wed, 1 May 2024 22:10:21 +0000 (00:10 +0200)]
stddef: A better workaround against GCC bug 114870.
* lib/stddef.in.h: If STDDEF_NOT_IDEMPOTENT is 1, disable the special
invocation convention.
* m4/stddef_h.m4 (gl_STDDEF_H): Set STDDEF_NOT_IDEMPOTENT.
(gl_STDDEF_H_DEFAULTS): Initialize STDDEF_NOT_IDEMPOTENT.
* modules/stddef (Makefile.am): Substitute STDDEF_NOT_IDEMPOTENT.
Paul Eggert [Sat, 27 Apr 2024 16:09:38 +0000 (09:09 -0700)]
stddef: work around a GCC 14 stddef.h bug
* lib/stddef.in.h: (_GCC_NULLPTR_T): Define if needed to work around
GCC bug 114869.
* m4/stddef_h.m4 (gl_STDDEF_H, gl_STDDEF_H_DEFAULTS):
* modules/stddef (stddef.h):
Detect the two bugs 114869 and 114870.
Bruno Haible [Sat, 27 Apr 2024 00:22:05 +0000 (02:22 +0200)]
login_tty tests: Avoid gcc warnings.
* tests/test-login_tty.c: Include ignore-value.h.
(main): Ignore the results of the freopen calls.
* modules/login_tty-tests (Depends-on): Add ignore-value.
Paul Eggert [Wed, 24 Apr 2024 06:18:07 +0000 (23:18 -0700)]
manywarnings: update C warnings for GCC 14
Adjust for C programs compiled by GCC 14.
(A C++ expert still needs to look at manywarnings-c++.m4.)
* build-aux/gcc-warning.spec: Add warnings introduced in GCC 14.
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
Add -Wflex-array-member-not-at-end, -Wmissing-variable-declarations.
Bruno Haible [Fri, 19 Apr 2024 11:57:14 +0000 (13:57 +0200)]
signed-nan: Don't assume that '-' works as expected on NaN values.
* lib/signed-nan.h (minus_NaNf): New function.
(positive_NaNf, negative_NaNf): Use it.
(minus_NaNd): New function.
(positive_NaNd, negative_NaNd): Use it.
(minus_NaNl): New function.
(positive_NaNl, negative_NaNl): Use it.
Bruno Haible [Fri, 19 Apr 2024 00:14:37 +0000 (02:14 +0200)]
totalorder*: Support newer MIPS CPUs.
* lib/totalorder.c (totalorder): On MIPS CPUs with MIPS_NAN2008_DOUBLE,
don't invert the most significant bit of the mantissa field.
* lib/totalorderf.c (totalorderf): On MIPS CPUs with MIPS_NAN2008_FLOAT,
don't invert the most significant bit of the mantissa field.
* lib/totalorderl.c (totalorderl): On MIPS CPUs with
MIPS_NAN2008_LONG_DOUBLE, don't invert the most significant bit of the
mantissa field.
* m4/totalorder.m4 (gl_FUNC_TOTALORDERF, gl_FUNC_TOTALORDER,
gl_FUNC_TOTALORDERL): Invoke gl_NAN_MIPS.
* modules/totalorder (Files): Add m4/nan-mips.m4.
* modules/totalorderf (Files): Likewise.
* modules/totalorderl (Files): Likewise.
Bruno Haible [Tue, 9 Apr 2024 11:08:32 +0000 (13:08 +0200)]
totalorder, totalorderf: Fix handling of SNaN on i386 and x86_64 CPUs.
* lib/totalorder.c: Include <string.h>.
(totalorder): Use memcpy to copy the 'double' values into the union.
Drop 'volatile'.
* lib/totalorderf.c: Include <string.h>.
(totalorderf): Use memcpy to copy the 'float' values into the union.
Drop 'volatile'.
Bruno Haible [Fri, 5 Apr 2024 14:04:59 +0000 (16:04 +0200)]
roundl: Fix a link error on Linux/powerpc64le.
* m4/check-math-lib.m4 (gl_CHECK_MATH_LIB): Accept an additional TYPE
argument.
* m4/isfinite.m4 (gl_ISFINITE): Use the type 'double'.
* m4/isinf.m4 (gl_ISINF): Likewise.
* m4/round.m4 (gl_FUNC_ROUND): Likewise.
* m4/roundf.m4 (gl_FUNC_ROUNDF): Use the type 'float'.
* m4/roundl.m4 (gl_FUNC_ROUNDL): Use the type 'long double'.
quotearg: fix shell-escape quoting with single quotes
With shell-escape quoting, we misquoted strings
where the first and last characters required escaping,
while the string also contained single quotes.
* lib/quotearg.c (quotearg_buffer_restyled): Ensure that
pending_shell_escape_end is reset to the initial state
when reprocessing input due to single quotes.
Reported by Grisha Levit
* 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.