]> Savannah Git Hosting - gnulib.git/log
gnulib.git
16 months agoautoupdate
Karl Berry [Sun, 31 Dec 2023 16:33:17 +0000 (08:33 -0800)]
autoupdate

16 months agotests: don’t skip if LONG_MAX < pid
Paul Eggert [Sat, 30 Dec 2023 03:20:19 +0000 (19:20 -0800)]
tests: don’t skip if LONG_MAX < pid

* modules/pthread_sigmask-tests, modules/sigprocmask-tests:
(Depends-on): Add inttypes.
* tests/test-pthread_sigmask1.c, tests/test-sigprocmask.c:
Include inttypes.h.
(main): Don’t skip test if pid exceeds LONG_MAX.

16 months agoOmit no-longer-needed pragmas
Paul Eggert [Fri, 29 Dec 2023 18:33:42 +0000 (10:33 -0800)]
Omit no-longer-needed pragmas

* lib/anytostr.c, lib/poll.c, lib/regex.c:
Omit pragmas that should no longer be needed.

16 months agognulib-common: suppress -Wtautological-constant-out-of-range-compare
Paul Eggert [Fri, 29 Dec 2023 18:33:03 +0000 (10:33 -0800)]
gnulib-common: suppress -Wtautological-constant-out-of-range-compare

* 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.

16 months agoannounce-gen: Improve links.
Simon Josefsson [Fri, 29 Dec 2023 18:28:17 +0000 (19:28 +0100)]
announce-gen: Improve links.

* build-aux/announce-gen: Use https:// URLs.

16 months agoerror: More clang -Winclude-next-absolute-path silencing.
Bruno Haible [Fri, 29 Dec 2023 09:39:52 +0000 (10:39 +0100)]
error: More clang -Winclude-next-absolute-path silencing.

* modules/error (Include): Suggest <error.h>, not "error.h".
* tests/test-error.c: Write #include <error.h>.
* tests/test-exclude.c: Likewise.
* tests/test-verror.c: Likewise.
* tests/test-xstrtol.c: Likewise.

16 months agoinclude_next: pacify clang -Winclude-next-absolute-path
Paul Eggert [Thu, 28 Dec 2023 20:25:16 +0000 (12:25 -0800)]
include_next: pacify clang -Winclude-next-absolute-path

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.)

16 months agostat-time: fix macOS bug with negative file times
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.

16 months agojit/cache: Fix compilation error on m68k, sparc, etc.
Bruno Haible [Tue, 19 Dec 2023 21:10:58 +0000 (22:10 +0100)]
jit/cache: Fix compilation error on m68k, sparc, etc.

* lib/jit/cache.h: Include <stdint.h>.
* modules/jit/cache (Depends-on): Add stdint.

16 months agojit/cache tests: Make more portable.
Marc Nieper-Wißkirchen [Tue, 19 Dec 2023 19:04:12 +0000 (20:04 +0100)]
jit/cache tests: Make more portable.

* 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.

16 months agoselinux-h: add stubs and wrappers for raw counterparts
Christian Göttsche [Tue, 19 Dec 2023 14:54:37 +0000 (15:54 +0100)]
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.

16 months agomcel-tests: fix thinko in test
Paul Eggert [Fri, 15 Dec 2023 01:15:27 +0000 (17:15 -0800)]
mcel-tests: fix thinko in test

* tests/test-mcel.c (main): Fix typo in mcel_scanz test.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2023-12/msg00034.html

16 months ago* ChangeLog: Fix typo.
Paul Eggert [Tue, 12 Dec 2023 02:31:23 +0000 (18:31 -0800)]
* ChangeLog: Fix typo.

16 months agosavedir: scale better when sorting by name
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.

16 months agogetopt: pacify gcc -Wanalyzer-null-dereference
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).

16 months agobootstrap: fix option propagation with --bootstrap-sync
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

17 months agofrexp: pacify clang re address-of-volatile
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.

17 months agoUpdate portability doc for CHERI, C23
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.

17 months agoobstack: Avoid undefined behaviour.
Bruno Haible [Fri, 1 Dec 2023 18:39:26 +0000 (19:39 +0100)]
obstack: Avoid undefined behaviour.

Reported by Alexey Palienko <Alexey.Palienko@cma.se> in
<https://lists.gnu.org/archive/html/bug-m4/2023-02/msg00000.html>.

* lib/obstack.in.h: Include <stdint.h>.
(__BPTR_ALIGN): Remove macro.
(__PTR_ALIGN): For the optimized case, compute the alignment through
uintptr_t, instead of computing NULL + something.

17 months agodoc: Update for FreeBSD 14.0.
Bruno Haible [Fri, 1 Dec 2023 12:21:44 +0000 (13:21 +0100)]
doc: Update for FreeBSD 14.0.

* doc/posix-headers/*.texi: Update.
* doc/glibc-headers/*.texi: Likewise.
* doc/posix-functions/*.texi: Likewise.
* doc/pastposix-functions/*.texi: Likewise.
* doc/glibc-functions/*.texi: Likewise.
* m4/printf.m4: Update comments.

17 months agosethostname tests: Fix a compilation error on FreeBSD 14.0.
Bruno Haible [Fri, 1 Dec 2023 10:47:31 +0000 (11:47 +0100)]
sethostname tests: Fix a compilation error on FreeBSD 14.0.

* tests/test-sethostname1.c: Skip the SIGNATURE_CHECK on some platforms.
* doc/glibc-functions/sethostname.texi: Update platforms list.

17 months agostack: Fix documentation in header file.
Marc Nieper-Wißkirchen [Mon, 27 Nov 2023 16:46:58 +0000 (17:46 +0100)]
stack: Fix documentation in header file.

* lib/stack.h: Correct documentation on `stack_current_base'.

17 months agojit/cache-tests: Fix include guard.
Marc Nieper-Wißkirchen [Mon, 27 Nov 2023 16:36:42 +0000 (17:36 +0100)]
jit/cache-tests: Fix include guard.

* tests/jit/test-cache.c (main): Extend range of include guard.

17 months agojit/cache-tests: New module.
Marc Nieper-Wißkirchen [Sat, 25 Nov 2023 17:14:55 +0000 (18:14 +0100)]
jit/cache-tests: New module.

* tests/jit/test-cache.c: New file.
* modules/jit/cache-tests: New file.  Mark the test as unportable
for now.

17 months agojit/cache: Fix configure error.
Marc Nieper-Wißkirchen [Sat, 25 Nov 2023 19:58:31 +0000 (20:58 +0100)]
jit/cache: Fix configure error.

* m4/valgrind-helper.m4: Unconditionally set support_valgrind.

17 months agoautoupdate
Karl Berry [Sat, 25 Nov 2023 17:21:42 +0000 (09:21 -0800)]
autoupdate

17 months agofloorf, ceilf tests: Strengthen against compiler optimizations.
Bruno Haible [Fri, 24 Nov 2023 19:02:37 +0000 (20:02 +0100)]
floorf, ceilf tests: Strengthen against compiler optimizations.

Reported by René Rebe <rene@t2-project.org>.

* tests/test-floorf1.c (main): Mark my_floorf as 'volatile'.
* tests/test-floorf-ieee.c (main): Likewise.
* tests/test-ceilf1.c (main): Mark my_ceilf as 'volatile'.
* tests/test-ceilf-ieee.c (main): Likewise.

17 months agostrerrorname_np: Work around glibc bug on HPPA systems.
Bruno Haible [Tue, 21 Nov 2023 15:18:44 +0000 (16:18 +0100)]
strerrorname_np: Work around glibc bug on HPPA systems.

* m4/strerrorname_np.m4 (gl_FUNC_STRERRORNAME_NP): Test also
strerrorname_np (ENOSYM).
* lib/strerrorname_np.c (strerrorname_np): Update comments.
* tests/test-strerrorname_np.c (main): Likewise.
* doc/glibc-functions/strerrorname_np.texi: Mention that glibc 2.37
still needs a workaround.

17 months agorand: Use the usual patterns for overriding a function.
Bruno Haible [Tue, 21 Nov 2023 14:25:24 +0000 (15:25 +0100)]
rand: Use the usual patterns for overriding a function.

* lib/stdlib.in.h (RAND_MAX): Override also if module 'rand' is present.
(rand): New declaration.
* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize GNULIB_RAND.
(gl_STDLIB_H_DEFAULTS): Initialize REPLACE_RAND.
* modules/stdlib (Makefile.am): Substitute GNULIB_RAND and REPLACE_RAND.

17 months agonan, snan tests: Don't include these tests by default.
Bruno Haible [Sat, 18 Nov 2023 05:42:56 +0000 (06:42 +0100)]
nan, snan tests: Don't include these tests by default.

* modules/nan-tests (Status): Mark the test as unportable.
* modules/snan-tests (Status): Likewise.

17 months agorealloc-gnu: Fix wrong configure test result with optimizing ibm-clang.
Bruno Haible [Fri, 17 Nov 2023 23:18:37 +0000 (00:18 +0100)]
realloc-gnu: Fix wrong configure test result with optimizing ibm-clang.

* m4/realloc.m4 (_AC_FUNC_REALLOC_IF): Use 'volatile', to defeat an
ibm-clang optimization.
* m4/malloc.m4 (_AC_FUNC_MALLOC_IF): Likewise.

17 months agombrtowc, mbrtoc32, nl_langinfo, setlocale-null: Obey --disable-threads.
Bruno Haible [Fri, 17 Nov 2023 18:37:24 +0000 (19:37 +0100)]
mbrtowc, mbrtoc32, nl_langinfo, setlocale-null: Obey --disable-threads.

Reported by David Edelsohn <dje.gcc@gmail.com> in
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636830.html>,
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636843.html>.

* m4/threadlib.m4 (gl_THREADLIB_BODY): If --disable-threads was
specified, define AVOID_ANY_THREADS to 1.
* lib/mbtowc-lock.c: Omit all code if --disable-threads was specified.
* lib/nl_langinfo-lock.c: Likewise.
* lib/setlocale-lock.c: Likewise.
* lib/mbtowc-lock.h: Omit locking code if --disable-threads was
specified.
* lib/nl_langinfo.c: Likewise.
* lib/setlocale_null.c: Likewise.
* lib/mbrtowc.c: Don't include any multithreading headers if
--disable-threads was specified.
* lib/mbrtoc32.c: Likewise.

17 months agogettext: Recognize a statically built libintl on macOS and AIX.
Bruno Haible [Fri, 17 Nov 2023 11:49:40 +0000 (12:49 +0100)]
gettext: Recognize a statically built libintl on macOS and AIX.

Reported by David Edelsohn <dje.gcc@gmail.com> in
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636558.html>.

* m4/gettext.m4 (AM_GNU_GETTEXT): In the
"checking for GNU gettext in libintl..." test, add also the special
system library dependencies needed on macOS and AIX.

17 months agoboot-time: Make it work on Adélie Linux.
Bruno Haible [Thu, 16 Nov 2023 13:06:29 +0000 (14:06 +0100)]
boot-time: Make it work on Adélie Linux.

* lib/boot-time.c (get_boot_time_uncached): Invoke Linux fallbacks also
on Linux systems that have neither <utmp.h> nor <utmpx.h>.

17 months agoobstack: Modernize, fixing several problems.
Bruno Haible [Wed, 15 Nov 2023 23:09:40 +0000 (00:09 +0100)]
obstack: Modernize, fixing several problems.

* lib/obstack.in.h: Renamed from lib/obstack.h. Add reference to the
glibc documentation.
(_OBSTACK_INTERFACE_VERSION): Remove macro.
(_OBSTACK_SIZE_T, _CHUNK_SIZE_T, _OBSTACK_CAST): Mark old values with
_LIBC.
(_obstack_newchunk, _obstack_free, _obstack_begin, _obstack_begin_1,
_obstack_memory_used, _obstack_allocated_p): Override if REPLACE_OBSTACK
is 1.
* lib/obstack.c: Don't include <gnu-versions.h>.
(_OBSTACK_ELIDE_CODE): Remove macro.
* m4/obstack.m4 (gl_FUNC_OBSTACK): Test whether obstack.h exists. Don't
define HAVE_OBSTACK any more. Set HAVE_OBSTACK, REPLACE_OBSTACK,
GL_GENERATE_OBSTACK_H.
* modules/obstack (Files): Remove obstack.h. Add obstack.in.h.
(Depends-on): Add gen-header. Add conditions.
(configure.ac): Consider HAVE_OBSTACK, REPLACE_OBSTACK. Invoke
gl_CONDITIONAL_HEADER and AC_PROG_MKDIR_P.
(Makefile.am): Generate obstack.h. Augment BUILT_SOURCES and
MOSTLYCLEANFILES.

17 months agostriconveha: pacify gcc -Wcast-align
Paul Eggert [Wed, 15 Nov 2023 08:09:03 +0000 (00:09 -0800)]
striconveha: pacify gcc -Wcast-align

* lib/striconveha.c (uniconv_register_autodetect): Rewrite to
avoid the need to cast from char * to a pointer to a more strictly
aligned type.  Use decls after statements to avoid some repetition.

17 months agodoc: Mention a 'random' limitation on OpenBSD.
Bruno Haible [Tue, 14 Nov 2023 18:33:21 +0000 (19:33 +0100)]
doc: Mention a 'random' limitation on OpenBSD.

Reported by Corinna Vinschen <vinschen@redhat.com>.

* doc/posix-functions/random.texi: Mention the OpenBSD limitation.

17 months agorand: Mark as obsolete.
Bruno Haible [Tue, 14 Nov 2023 18:18:16 +0000 (19:18 +0100)]
rand: Mark as obsolete.

* modules/rand (Status, Notice): New sections.

17 months ago*printf-posix: Revert expectations of %lc of 0.
Bruno Haible [Tue, 14 Nov 2023 13:10:57 +0000 (14:10 +0100)]
*printf-posix: Revert expectations of %lc of 0.

* m4/printf.m4 (gl_PRINTF_DIRECTIVE_LC): Expect a NUL byte in the
output.
* lib/vasnprintf.c (VASNPRINTF): In the %lc implementation, don't
special-case the NUL wide character.
* tests/test-vasnprintf-posix.c (test_function): Change expected result
for %lc of L'\0'.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* doc/posix-functions/dprintf.texi: Update platform list regarding %lc
of 0 bug.
* doc/posix-functions/fprintf.texi: Likewise.
* doc/posix-functions/printf.texi: Likewise.
* doc/posix-functions/snprintf.texi: Likewise.
* doc/posix-functions/sprintf.texi: Likewise.
* doc/posix-functions/vdprintf.texi: Likewise.
* doc/posix-functions/vfprintf.texi: Likewise.
* doc/posix-functions/vprintf.texi: Likewise.
* doc/posix-functions/vsnprintf.texi: Likewise.
* doc/posix-functions/vsprintf.texi: Likewise.
* doc/glibc-functions/asprintf.texi: Likewise.
* doc/glibc-functions/vasprintf.texi: Likewise.
* doc/glibc-functions/obstack_printf.texi: Likewise.
* doc/glibc-functions/obstack_vprintf.texi: Likewise.

17 months agodoc: Add a note.
Bruno Haible [Tue, 14 Nov 2023 01:47:21 +0000 (02:47 +0100)]
doc: Add a note.

* doc/posix-headers/stdatomic.texi: Add a note about the memory model.

17 months agoDon't use CHERI facilities with CC="clang -march=morello".
Bruno Haible [Mon, 13 Nov 2023 13:55:01 +0000 (14:55 +0100)]
Don't use CHERI facilities with CC="clang -march=morello".

Suggested by Jessica Clarke <jrtc27@jrtc27.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-11/msg00116.html>.

* lib/alignalloc.h (alignalloc): Test __CHERI_PURE_CAPABILITY__, not
__CHERI__.
* lib/eealloc.h (eemalloc, eerealloc): Likewise.
* lib/ialloc.h (irealloc, ireallocarray): Likewise.
* lib/malloca.h (malloca): Likewise.
* lib/malloca.c (small_t, mmalloca, freea): Likewise.
* lib/rawmemchr.c (rawmemchr): Likewise.
* lib/safe-alloc.h (safe_alloc_realloc_n): Likewise.
* lib/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER): Likewise.
* lib/ssfmalloc.h (struct dissected_page_header, init_small_block_page,
init_medium_block_page, free_block_from_pool, allocate_block): Likewise.
* tests/test-stdint.c: Likewise.

17 months agojit/cache: Fix configure test.
Bruno Haible [Mon, 13 Nov 2023 13:32:37 +0000 (14:32 +0100)]
jit/cache: Fix configure test.

* m4/valgrind-helper.m4 (gl_VALGRIND_HELPER): Check already at configure
time whether <valgrind/valgrind.h> exists. Fix AC_DEFINE_UNQUOTED
invocation.

17 months agorawmemchr: speed up, particularly on CHERI
Paul Eggert [Mon, 13 Nov 2023 07:21:40 +0000 (23:21 -0800)]
rawmemchr: speed up, particularly on CHERI

* lib/rawmemchr.c (rawmemchr) [__CHERI__]: Use memchr instead of
one-byte reads.  This sped up a simple benchmark (rawmemchr on
100,000 bytes) by 6x on a Research Morello SoC r0p0 on CheriBSD 14.
[!__CHERI__]: Use sizeof, not alignof, as better alignment
should help performance a bit on some platforms.
* modules/rawmemchr (Depends-on): Remove alignasof.

17 months agojit/cache: New module.
Bruno Haible [Sun, 12 Nov 2023 17:22:50 +0000 (18:22 +0100)]
jit/cache: New module.

* lib/jit/cache.h: New file.
* m4/valgrind-helper.m4: New file.
* modules/jit/cache: New file.

17 months agossfmalloc: Take advantage of CHERI bounds-checking.
Bruno Haible [Sat, 11 Nov 2023 23:45:39 +0000 (00:45 +0100)]
ssfmalloc: Take advantage of CHERI bounds-checking.

* lib/ssfmalloc.h: Include <cheri.h>.
(struct dissected_page_header) [CHERI]: Add field 'whole_page'.
(init_small_block_page, init_medium_block_page) [CHERI]: Initialize it.
(free_block_from_pool) [CHERI]: Use this field to initialize
pool->freeable_page.
(allocate_block) [CHERI]: Return a pointer with a tight upper bound.

17 months agovasnprintf: Re-enable parsing of directive with I64 (regr. 2023-03-24).
Johannes Schindelin [Sat, 11 Nov 2023 21:53:33 +0000 (22:53 +0100)]
vasnprintf: Re-enable parsing of directive with I64 (regr. 2023-03-24).

In 480a59ba60 (*printf-posix: ISO C 23: Support size specifiers 'wN' and
'wfN'., 2023-03-24), a major refactoring hides a bug in the conversion
of the code handling Windows' "%I64*" family of printf() formats:
before the refactoring, the "64" part was skipped (as desired), but
afterwards that part is not skipped and therefore the '6' is mistaken
for a conversion character. Which is invalid, of course, causing the
code to error out.

Fix this by skipping the "64" part again.

This bug was uncovered by the Git for Windows project when gettext
v0.22.3 switched to the gnulib code as work horse of the
libintl_vsnprintf() function.

* lib/printf-parse.c (PRINTF_PARSE): When parsing a size specifier
"I64", increment cp by 3, not 1.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Copyright-paperwork-exempt: Yes

17 months agomalloca: Take advantage of CHERI bounds-checking.
Bruno Haible [Sat, 11 Nov 2023 19:04:02 +0000 (20:04 +0100)]
malloca: Take advantage of CHERI bounds-checking.

* lib/malloca.h: Include <cheri.h>.
(malloca) [CHERI]: In the stack-allocation case, return a pointer with
a tight lower bound and a tight upper bound.
* lib/malloca.c: Include <cheri.h>.
(small_t) [CHERI]: Define as uintptr_t.
(mmalloca) [CHERI]: Return a pointer with a tight upper bound.
(freea) [CHERI]: Update.

17 months agosafe-alloc: Take advantage of CHERI bounds-checking.
Bruno Haible [Sat, 11 Nov 2023 18:36:36 +0000 (19:36 +0100)]
safe-alloc: Take advantage of CHERI bounds-checking.

* lib/safe-alloc.h: Include <cheri.h>.
(safe_alloc_realloc_n): When count or size is 0, return a pointer whose
bounds are of size 0, not 1.

17 months agoialloc: Take advantage of CHERI bounds-checking.
Bruno Haible [Sat, 11 Nov 2023 18:34:26 +0000 (19:34 +0100)]
ialloc: Take advantage of CHERI bounds-checking.

* lib/ialloc.h: Include <cheri.h>.
(irealloc): When s is 0, return a pointer whose bounds are of size 0,
not 1.
(ireallocarray): When n or s is 0, return a pointer whose bounds are of
size 0, not 1.

17 months agoeealloc: Take advantage of CHERI bounds-checking.
Bruno Haible [Sat, 11 Nov 2023 18:31:56 +0000 (19:31 +0100)]
eealloc: Take advantage of CHERI bounds-checking.

* lib/eealloc.h: Include <cheri.h>.
(eemalloc): When n is 0, return a pointer whose bounds are of size 0,
not 1.
(eerealloc): Likewise.

17 months agoalignalloc: Take advantage of CHERI bounds-checking.
Bruno Haible [Sat, 11 Nov 2023 18:28:26 +0000 (19:28 +0100)]
alignalloc: Take advantage of CHERI bounds-checking.

* lib/alignalloc.h: Include <cheri.h>.
(alignalloc): When size is 0, return a pointer whose bounds are of
size 0, not 1.

17 months agorawmemchr tests: Add test case for last commit.
Bruno Haible [Sat, 11 Nov 2023 10:44:47 +0000 (11:44 +0100)]
rawmemchr tests: Add test case for last commit.

* tests/test-rawmemchr.c (main): Add test case for aligned oversized
read.

17 months agorawmemchr: port better to CHERI
Paul Eggert [Sat, 11 Nov 2023 08:09:55 +0000 (00:09 -0800)]
rawmemchr: port better to CHERI

* lib/rawmemchr.c (rawmemchr): Use unsigned char for longword,
since CHERI doesn’t allow the aligned-word trick to speed up
performance.

17 months agodi-set: port better to CHERI-64
Paul Eggert [Sat, 11 Nov 2023 07:04:35 +0000 (23:04 -0800)]
di-set: port better to CHERI-64

* lib/di-set.c: Include stdint.h.
(hashint): Make it uintptr_t, not size_t, since it’s for use
when converting to pointer and back again.  This suppresses
a false positive on CHERI-64.
* modules/di-set (Depends-on): Add stdint.

17 months agostdio: fix port to older macOS
Paul Eggert [Sat, 11 Nov 2023 06:33:49 +0000 (22:33 -0800)]
stdio: fix port to older macOS

* lib/stdio.in.h: It’s pre macOS 13, not pre macOS 10.13.
Problem reported by Sevan Janiyan in:
https://lists.gnu.org/r/bug-gnulib/2023-11/msg00066.html
et seq.

17 months agodoc: Mention rand and srand limitations, part 2.
Bruno Haible [Sat, 11 Nov 2023 00:13:22 +0000 (01:13 +0100)]
doc: Mention rand and srand limitations, part 2.

17 months agodoc: Mention rand and srand limitations.
Bruno Haible [Fri, 10 Nov 2023 18:57:30 +0000 (19:57 +0100)]
doc: Mention rand and srand limitations.

* doc/posix-functions/rand.texi: Mention multithread-safety problem.
* doc/posix-functions/srand.texi: Mention a Cygwin bug.

17 months agotests: In multithreaded tests, use random() instead of rand().
Bruno Haible [Fri, 10 Nov 2023 18:01:40 +0000 (19:01 +0100)]
tests: In multithreaded tests, use random() instead of rand().

* tests/test-asyncsafe-spin2.c (random_account, lock_mutator_thread):
Use random() instead of rand().
* tests/test-lock.c (random_account, lock_mutator_thread,
rwlock_mutator_thread, recshuffle): Likewise.
* tests/test-mtx.c (random_account, lock_mutator_thread, recshuffle):
Likewise.
* tests/test-pthread-mutex.c (random_account, lock_mutator_thread,
recshuffle): Likewise.
* tests/test-pthread-rwlock.c (random_account, rwlock_mutator_thread):
Likewise.
* tests/test-pthread-spin.c (random_account, lock_mutator_thread):
Likewise.
* tests/test-pthread-tss.c (perhaps_yield, worker_thread,
racecheck_thread): Likewise.
* tests/test-thread_local.c (perhaps_yield, worker_thread): Likewise.
* tests/test-tls.c (perhaps_yield, worker_thread, racecheck_thread):
Likewise.
* tests/test-tss.c (perhaps_yield, worker_thread, racecheck_thread):
Likewise.
* asyncsafe-spin-tests (Depends-on): Add random.
* lock-tests (Depends-on): Likewise.
* mtx-tests (Depends-on): Likewise.
* pthread-mutex-tests (Depends-on): Likewise.
* pthread-rwlock-tests (Depends-on): Likewise.
* pthread-spin-tests (Depends-on): Likewise.
* pthread-tss-tests (Depends-on): Likewise.
* threads-h-tests (Depends-on): Likewise.
* tls-tests (Depends-on): Likewise.
* tss-tests (Depends-on): Likewise.

17 months agodoc: Mention an srandom limitation on OpenBSD.
Bruno Haible [Fri, 10 Nov 2023 15:51:02 +0000 (16:51 +0100)]
doc: Mention an srandom limitation on OpenBSD.

* doc/posix-functions/srandom.texi: Mention the OpenBSD limitation.

17 months agorandom tests: Add multithread-safety test.
Bruno Haible [Fri, 10 Nov 2023 15:48:18 +0000 (16:48 +0100)]
random tests: Add multithread-safety test.

* tests/test-random-mt.c: New file.
* modules/random-tests (Files): Add it.
(Depends-on): Add xalloc, thread, yield.
(Makefile.am): Also build and test test-random-mt.

17 months agorandom: Fix multithread-safety bug in general.
Bruno Haible [Fri, 10 Nov 2023 15:46:17 +0000 (16:46 +0100)]
random: Fix multithread-safety bug in general.

* m4/random.m4 (gl_FUNC_RANDOM): Override also macOS, FreeBSD, Solaris,
Cygwin, Haiku.
* doc/posix-functions/random.texi: Mention the wider scope of the
multithread-safety bug.

17 months agosigsegv: Improve port to CHERI.
Bruno Haible [Fri, 10 Nov 2023 01:30:28 +0000 (02:30 +0100)]
sigsegv: Improve port to CHERI.

* lib/sigsegv.c (SIGSEGV_FAULT_STACKPOINTER): Define also on CheriBSD.

17 months agosigsegv: Port to CHERI.
Bruno Haible [Fri, 10 Nov 2023 00:16:55 +0000 (01:16 +0100)]
sigsegv: Port to CHERI.

* lib/sigsegv.c: Treat __aarch64__ like __arm64__.
(SIGSEGV_FOR_ALL_SIGNALS): Treat SIGPROT like SIGSEGV and SIGBUS.

17 months agostdio: port better to older macOS
Paul Eggert [Thu, 9 Nov 2023 18:50:30 +0000 (10:50 -0800)]
stdio: port better to older macOS

* lib/stdio.in.h: Do not define _POSIX_C_SOURCE on older macOS,
as it is not needed and defining it causes other problems.
Problem reported by Sevan Janiyan in:
https://mail.gnu.org/r/bug-gnulib/2023-11/msg00039.html

17 months agorand: Add tests.
Bruno Haible [Thu, 9 Nov 2023 15:01:46 +0000 (16:01 +0100)]
rand: Add tests.

* tests/test-rand.c: New file.
* modules/rand-tests: New file.

17 months agorand: New module.
Bruno Haible [Thu, 9 Nov 2023 15:00:28 +0000 (16:00 +0100)]
rand: New module.

* lib/rand.c: New file, based on glibc/stdlib/rand.c.
* m4/rand.m4: New file.
* modules/rand: New file.
* doc/posix-functions/rand.texi: Mention the new module.

17 months agorandom: Fix multithread-safety bug on CheriBSD.
Bruno Haible [Thu, 9 Nov 2023 14:56:32 +0000 (15:56 +0100)]
random: Fix multithread-safety bug on CheriBSD.

* m4/random.m4 (gl_FUNC_RANDOM): Override on CheriBSD.
* lib/random.c: Include glthread/lock.h.
(__libc_lock_define_initialized, __libc_lock_lock, __libc_lock_unlock):
Define to do real locking.
* modules/random (Depends-on): Add lock.
* doc/posix-functions/random.texi: Mention the multithread-safety
problem.

17 months agohost-cpu-c-abi: Port to CHERI.
Bruno Haible [Thu, 9 Nov 2023 11:37:00 +0000 (12:37 +0100)]
host-cpu-c-abi: Port to CHERI.

* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI_32BIT): Treat aarch64c like
aarch64.

17 months agopthread-rwlock: Port to Mac OS X 10.4.
Bruno Haible [Thu, 9 Nov 2023 02:32:20 +0000 (03:32 +0100)]
pthread-rwlock: Port to Mac OS X 10.4.

Reported by Sevan Janiyan <venture37@geeklan.co.uk>.

* m4/pthread-rwlock.m4 (gl_PTHREAD_RWLOCK): On macOS, test for the
presence of PTHREAD_RWLOCK_INITIALIZER. If it is not defined, don't
attempt to use pthread_rwlock_init.

17 months agofenv-environment tests: Add a test of the link dependencies.
Bruno Haible [Tue, 7 Nov 2023 21:08:02 +0000 (22:08 +0100)]
fenv-environment tests: Add a test of the link dependencies.

* tests/test-fenv-env-6.c: Renamed from tests/test-fenv-env-5.c.
* tests/test-fenv-env-5.c: Renamed from tests/test-fenv-env-4.c.
* tests/test-fenv-env-4.c: Renamed from tests/test-fenv-env-3.c.
* tests/test-fenv-env-3.c: Renamed from tests/test-fenv-env-2.c.
* tests/test-fenv-env-2.c: Renamed from tests/test-fenv-env-1.c.
* tests/test-fenv-env-1.c: New file.
* tests/test-fenv-env-6.sh: Renamed from tests/test-fenv-env-5.sh. Update.
* modules/fenv-environment-tests: Update. Add test-fenv-env-1 unit test.

17 months agofenv-exceptions-state-c99 tests: Add a test of the link dependencies.
Bruno Haible [Tue, 7 Nov 2023 20:56:34 +0000 (21:56 +0100)]
fenv-exceptions-state-c99 tests: Add a test of the link dependencies.

* tests/test-fenv-except-state-4.c: Renamed from
tests/test-fenv-except-state-3.c.
* tests/test-fenv-except-state-3.c: Renamed from
tests/test-fenv-except-state-2.c.
* tests/test-fenv-except-state-2.c: Renamed from
tests/test-fenv-except-state-1.c.
* tests/test-fenv-except-state-1.c: New file.
* modules/fenv-exceptions-state-c23-tests: Update.
* modules/fenv-exceptions-state-c99-tests: Update. Add
test-fenv-except-state-1 unit test.

17 months agofenv-exceptions-trapping tests: Comments.
Bruno Haible [Tue, 7 Nov 2023 20:32:50 +0000 (21:32 +0100)]
fenv-exceptions-trapping tests: Comments.

* tests/test-fenv-except-trapping-1.c (main): Add a comment.

17 months agomalloca: pacify -Wcheri-provenance
Paul Eggert [Tue, 7 Nov 2023 18:54:58 +0000 (10:54 -0800)]
malloca: pacify -Wcheri-provenance

This shouldn’t affect generated code when optimizing.
* lib/malloca.c (mmalloca): Pacify -Wcheri-provenance on CHERI-64 cc.
(freea): Assign to temporaries to simplify debugging and avoid casts.

17 months agorawmemchr: Port to CHERI.
Bruno Haible [Tue, 7 Nov 2023 14:30:32 +0000 (15:30 +0100)]
rawmemchr: Port to CHERI.

* lib/rawmemchr.c (rawmemchr): Use 'unsigned long' instead of uintptr_t.

17 months agostdint: port intptr_t to CHERI
Paul Eggert [Tue, 7 Nov 2023 07:53:21 +0000 (23:53 -0800)]
stdint: port intptr_t to CHERI

* lib/stdint.in.h: Do not redefine intptr_t/uintptr_t
if __INTPTR_WIDTH__ says otherwise.  This is needed on CHERI.

17 months agostdint-tests: port to CHERI etc
Paul Eggert [Tue, 7 Nov 2023 07:46:53 +0000 (23:46 -0800)]
stdint-tests: port to CHERI etc

* tests/test-stdint.c: Test intptr_t only if INTPTR_MAX is
defined, since the type is optional.  Similarly for uintptr_t.
If CHERI, don’t assume TYPE_MINIMUM and TYPE_MAXIMUM works on
intptr_t, and similarly for TYPE_MAXIMUM and uintptr_t.

17 months agoposix_memalign-tests: port to CHERI-64
Paul Eggert [Tue, 7 Nov 2023 07:43:03 +0000 (23:43 -0800)]
posix_memalign-tests: port to CHERI-64

* tests/test-posix_memalign.c (main):
Don’t assume sizeof (void *) <= 8.

17 months agomcel-tests: fix read overrun in test case
Paul Eggert [Tue, 7 Nov 2023 04:38:52 +0000 (20:38 -0800)]
mcel-tests: fix read overrun in test case

* tests/test-mcel.c (main): Don’t overrun test input buffer.
Problem reported by Bruno Haible; found on CHERI-64.

17 months agofenv-exceptions-tracking-c99 tests: Fix typo.
Bruno Haible [Tue, 7 Nov 2023 01:24:37 +0000 (02:24 +0100)]
fenv-exceptions-tracking-c99 tests: Fix typo.

Found by coverity.

* tests/test-fenv-except-tracking-1.c (main): Write & ~, not & !.

17 months agosnan: Avoid test failures on OpenBSD/mips64.
Bruno Haible [Tue, 7 Nov 2023 01:05:05 +0000 (02:05 +0100)]
snan: Avoid test failures on OpenBSD/mips64.

* tests/test-snan-1.c (main): Skip the 'long double' test on
OpenBSD/mips64.
* tests/test-snan-2.c (main): Likewise.

17 months agofenv-*: Avoid test failures on OpenBSD/mips64.
Bruno Haible [Tue, 7 Nov 2023 01:04:59 +0000 (02:04 +0100)]
fenv-*: Avoid test failures on OpenBSD/mips64.

* tests/test-fenv-round.c (test_towardzero, test_upward, test_downward):
Skip the 'long double' tests on OpenBSD/mips64.
* tests/test-fenv-except-tracking-2.c (main): On OpenBSD/mips64, skip
the 'long double' test.
* tests/test-fenv-except-trapping-2.c (main): Skip the '4' tests and the
'long double' tests also on OpenBSD/mips64.
* doc/posix-functions/fesetround.texi: Mention OpenBSD/mips64 here too.

17 months agofenv-exceptions-tracking-c99: Fix test failures on OpenBSD/mips64.
Bruno Haible [Tue, 7 Nov 2023 01:04:47 +0000 (02:04 +0100)]
fenv-exceptions-tracking-c99: Fix test failures on OpenBSD/mips64.

* m4/fenv-exceptions-tracking.m4 (gl_FENV_EXCEPTIONS_TRACKING): On
OpenBSD/mips, set REPLACE_FECLEAREXCEPT to 1.
* doc/posix-functions/feclearexcept.texi: Mention the OpenBSD/mips64
bug.
* m4/fenv-exceptions-state.m4 (gl_FENV_EXCEPTIONS_STATE): No need to set
gl_cv_func_fesetexceptflag_works1 to 'no' on OpenBSD/mips.

17 months agonan: Defeat clang's incorrect -O2 optimization on mips64.
Bruno Haible [Tue, 7 Nov 2023 01:03:54 +0000 (02:03 +0100)]
nan: Defeat clang's incorrect -O2 optimization on mips64.

* lib/nan.h (NaNf, NaNd, NaNl): Use 'volatile' to disable a clang
optimization.

17 months agonan: Work around clang's incorrect constant-folding on mips64.
Bruno Haible [Mon, 6 Nov 2023 23:59:02 +0000 (00:59 +0100)]
nan: Work around clang's incorrect constant-folding on mips64.

* lib/nan.h (NaNf, NaNd, NaNl): On mips platforms, avoid the compiler's
constant-folding for 0.0f/0.0f, 0.0/0.0, 0.0L/0.0L.

17 months agosnan: Add more info for mips-based platforms.
Bruno Haible [Mon, 6 Nov 2023 23:52:14 +0000 (00:52 +0100)]
snan: Add more info for mips-based platforms.

* m4/nan-mips.m4: New file.
* lib/snan.h: Add comments regarding mips.
* modules/snan (Files): Add m4/nan-mips.m4.
(configure.ac): Invoke gl_NAN_MIPS.
* m4/snan.m4: Update comment.

17 months agofenv-exceptions-state-c99: Update doc regarding Minix.
Bruno Haible [Mon, 6 Nov 2023 13:09:17 +0000 (14:09 +0100)]
fenv-exceptions-state-c99: Update doc regarding Minix.

* doc/posix-functions/fesetexceptflag.texi: Mention the Minix bug.

17 months agofenv-exceptions-trapping: Avoid test failure on Minix.
Bruno Haible [Sun, 5 Nov 2023 21:47:59 +0000 (22:47 +0100)]
fenv-exceptions-trapping: Avoid test failure on Minix.

* tests/test-fenv-except-trapping-2.c (main): Skip the '4' tests also on
Minix.

17 months agofenv-exceptions-tracking-c99: Fix test failures on Minix.
Bruno Haible [Sun, 5 Nov 2023 22:25:08 +0000 (23:25 +0100)]
fenv-exceptions-tracking-c99: Fix test failures on Minix.

* m4/fenv-exceptions-tracking.m4 (gl_FENV_EXCEPTIONS_TRACKING): On
Minix, set REPLACE_FECLEAREXCEPT and REPLACE_FETESTEXCEPT to 1.
* doc/posix-functions/feclearexcept.texi: Mention the Minix bug.
* doc/posix-functions/fetestexcept.texi: Likewise.

17 months agofenv-exceptions-trapping: Avoid test failure on Haiku/i386.
Bruno Haible [Sun, 5 Nov 2023 21:22:35 +0000 (22:22 +0100)]
fenv-exceptions-trapping: Avoid test failure on Haiku/i386.

* tests/test-fenv-except-trapping-2.c (main): Skip the '4' tests also on
Haiku/i386.

17 months agofenv-exceptions-state: Fix test failure on Haiku/i386 and Haiku/x86_64.
Bruno Haible [Sun, 5 Nov 2023 21:16:38 +0000 (22:16 +0100)]
fenv-exceptions-state: Fix test failure on Haiku/i386 and Haiku/x86_64.

* m4/fenv-exceptions-state.m4 (gl_FENV_EXCEPTIONS_STATE): Arrange to
override fesetexceptflag() on Haiku.
* doc/posix-functions/fesetexceptflag.texi: Mention the Haiku bug.

17 months agofenv: Add C++ tests.
Bruno Haible [Sun, 5 Nov 2023 15:03:46 +0000 (16:03 +0100)]
fenv: Add C++ tests.

* tests/test-fenv-c++.cc: New file.
* modules/fenv-c++-tests: New file.
* modules/fenv-tests (Depends-on): Add it.

18 months agofenv-environment: Add tests.
Bruno Haible [Sun, 5 Nov 2023 14:21:06 +0000 (15:21 +0100)]
fenv-environment: Add tests.

* tests/test-fenv-env-1.c: New file.
* tests/test-fenv-env-2.c: New file.
* tests/test-fenv-env-3.c: New file.
* tests/test-fenv-env-4.c: New file.
* tests/test-fenv-env-5.sh: New file.
* tests/test-fenv-env-5.c: New file.
* modules/fenv-environment-tests: New file.

18 months agofenv-environment: New module.
Bruno Haible [Sun, 5 Nov 2023 14:00:29 +0000 (15:00 +0100)]
fenv-environment: New module.

* lib/fenv.in.h (fenv_t) [hppa]: Remove the __exception field.
(FE_DFL_ENV): Override if <fenv.h> exists but HAVE_FE_DFL_ENV is not
defined.
(fegetenv, fesetenv, feupdateenv, feholdexcept): New declarations.
* lib/fenv-env.c: New file, based on glibc.
* lib/fenv-env-hold.c: New file.
* lib/fenv-env-update.c: New file.
* m4/fenv-environment.m4: New file.
* m4/mathfunc.m4 (gl_MATHFUNC): Handle also the 'fenv_t *' type.
* m4/fenv_h.m4 (gl_FENV_H_DEFAULTS): Initialize REPLACE_FEGETENV,
REPLACE_FEHOLDEXCEPT, REPLACE_FESETENV, REPLACE_FEUPDATEENV.
* modules/fenv (Makefile.am): Substitute REPLACE_FEGETENV,
REPLACE_FEHOLDEXCEPT, REPLACE_FESETENV, REPLACE_FEUPDATEENV.
* modules/fenv-environment: New file.
* doc/posix-functions/fegetenv.texi: Mention the new module and the bugs
on glibc, macOS, AIX.
* doc/posix-functions/feholdexcept.texi: Mention the new module and the
bugs on glibc, musl libc, FreeBSD, AIX, mingw, MSVC.
* doc/posix-functions/fesetenv.texi: Mention the new module and the bugs
on musl libc, FreeBSD, NetBSD, AIX, Solaris, Cygwin, mingw, MSVC.
* doc/posix-functions/feupdateenv.texi: Mention the new module and the
bugs on glibc, musl libc, macOS, FreeBSD, AIX, Solaris, mingw, MSVC.

18 months agofenv-exceptions-tracking-c99 tests: Enhance tests.
Bruno Haible [Sun, 5 Nov 2023 13:50:08 +0000 (14:50 +0100)]
fenv-exceptions-tracking-c99 tests: Enhance tests.

* tests/test-fenv-except-tracking-3.sh: Test not only FE_INVALID, but
also FE_DIVBYZERO, FE_OVERFLOW, FE_UNDERFLOW, FE_INEXACT.
* tests/test-fenv-except-tracking-3.c: Include <stdlib.h>, <string.h>.
Don't include fpe-trapping.h. Assume HAVE_FPE_TRAPPING is 1.
(main): Receive the exception to test as first argument.

18 months agofpe-trapping: Simplify.
Bruno Haible [Sun, 5 Nov 2023 13:34:39 +0000 (14:34 +0100)]
fpe-trapping: Simplify.

* lib/fpe-trapping.h (sigfpe_on_invalid): Remove all platform specific
code. Just rely on feclearexcept and feenableexcept.
* m4/fpe-trapping.m4: Renamed from m4/fpe.m4.
(gl_FPE_TRAPPING): Greatly simplify.
* modules/fpe-trapping (Files): Use m4/fpe-trapping.m4 instead of
m4/fpe.m4. Remove m4/mathfunc.m4, m4/musl.m4.
(Depends-on): Add fenv-exceptions-trapping.
* tests/test-fenv-except-state-2.c (main): Update skip message.
* tests/test-fenv-except-tracking-2.c (main): Likewise.
* tests/test-fenv-except-tracking-3.c (main): Likewise.
* tests/test-fenv-except-tracking-5.c (main): Likewise.
* tests/test-nan-2.c (main): Likewise.
* tests/test-snan-2.c (main): Likewise.

18 months agofpe-tracking: Remove module.
Bruno Haible [Sun, 5 Nov 2023 13:27:47 +0000 (14:27 +0100)]
fpe-tracking: Remove module.

* modules/fpe-tracking: Remove file.
* m4/fpe.m4 (gl_FPE_TRACKING): Remove macro.
(gl_FPE_TRAPPING): Require gl_FENV_EXCEPTIONS_TRACKING instead of
gl_FPE_TRACKING. Use FENV_EXCEPTIONS_TRACKING_LIBM instead of
FPE_TRACKING_LIBM.
* modules/nan-tests (Depends-on): Add fenv-exceptions-tracking-c99.
Remove fpe-tracking.
(Makefile.am): Use FENV_EXCEPTIONS_TRACKING_LIBM instead of
FPE_TRACKING_LIBM.
* modules/snan-tests (Depends-on): Add fenv-exceptions-tracking-c99.
Remove fpe-tracking.
(Makefile.am): Use FENV_EXCEPTIONS_TRACKING_LIBM instead of
FPE_TRACKING_LIBM.
* tests/test-nan-1.c: Assume HAVE_FE_INVALID is 1.
* tests/test-snan-1.c: Likewise.

18 months agofenv-exceptions-trapping: Avoid test failure on NetBSD/sparc.
Bruno Haible [Sun, 5 Nov 2023 12:01:32 +0000 (13:01 +0100)]
fenv-exceptions-trapping: Avoid test failure on NetBSD/sparc.

* tests/test-fenv-except-trapping-2.c (main): Skip the 'long double'
tests also on NetBSD/sparc.

18 months agofenv-exceptions-trapping: Update documentation.
Bruno Haible [Sun, 5 Nov 2023 11:56:24 +0000 (12:56 +0100)]
fenv-exceptions-trapping: Update documentation.

* doc/glibc-functions/feenableexcept.texi: Document the Linux/hppa
problem.

18 months agofenv-exceptions-trapping: Avoid test failure on older systems.
Bruno Haible [Sun, 5 Nov 2023 11:49:43 +0000 (12:49 +0100)]
fenv-exceptions-trapping: Avoid test failure on older systems.

* tests/test-fenv-except-trapping-2.c (main): Skip the test also on x86
systems with gcc < 8.

18 months agofenv-exceptions-trapping: Fix for powerpc* platforms.
Bruno Haible [Sat, 4 Nov 2023 15:54:43 +0000 (16:54 +0100)]
fenv-exceptions-trapping: Fix for powerpc* platforms.

* lib/fenv-except-trapping.c (feenableexcept, fedisableexcept)
[powerpc]: Use the correct bit mask for the trap bits.
* tests/test-fenv-except-trapping-2.c (main): Reenable the '9' tests on
powerpc platforms.