]> Savannah Git Hosting - gnulib.git/log
gnulib.git
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.

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

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

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

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

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

18 months agofenv-exceptions-state-c99: Fix compilation error on FreeBSD.
Bruno Haible [Sat, 4 Nov 2023 15:37:02 +0000 (16:37 +0100)]
fenv-exceptions-state-c99: Fix compilation error on FreeBSD.

* lib/fenv.in.h (fegetexceptflag, fesetexceptflag): On FreeBSD, use an
rpl_ prefix, to avoid a conflict with an inline definition in FreeBSD's
<fenv.h>.

18 months agodoc: Update info about Cygwin feraiseexcept bug.
Bruno Haible [Sat, 4 Nov 2023 15:27:09 +0000 (16:27 +0100)]
doc: Update info about Cygwin feraiseexcept bug.

* doc/posix-functions/feraiseexcept.texi: Update info regarding Cygwin.

18 months agofenv-exceptions-tracking-c99 tests: Avoid test failure on NetBSD/sparc.
Bruno Haible [Sat, 4 Nov 2023 15:23:16 +0000 (16:23 +0100)]
fenv-exceptions-tracking-c99 tests: Avoid test failure on NetBSD/sparc.

* tests/test-fenv-except-tracking-2.c (main): On NetBSD/sparc, skip the
'long double' test.

18 months agofenv-exceptions-tracking-c99: Fix fetestexcept() override for AIX.
Bruno Haible [Sat, 4 Nov 2023 14:29:46 +0000 (15:29 +0100)]
fenv-exceptions-tracking-c99: Fix fetestexcept() override for AIX.

* lib/fenv-except-tracking-test.c (fetestexcept): On AIX, use
fp_read_flag() rather than the fpscr register.

18 months agofenv-exceptions-tracking-c99: Work around a NetBSD/x86_64 bug.
Bruno Haible [Sat, 4 Nov 2023 13:31:37 +0000 (14:31 +0100)]
fenv-exceptions-tracking-c99: Work around a NetBSD/x86_64 bug.

* m4/fenv-exceptions-tracking.m4 (gl_FENV_EXCEPTIONS_TRACKING): On
NetBSD/x86_64, set REPLACE_FETESTEXCEPT to 1.
* doc/posix-functions/fetestexcept.texi: Document the NetBSD bug.

18 months agofenv-rounding: Avoid a test failure on NetBSD/sparc64.
Bruno Haible [Sat, 4 Nov 2023 13:18:28 +0000 (14:18 +0100)]
fenv-rounding: Avoid a test failure on NetBSD/sparc64.

* tests/test-fenv-round.c (test_towardzero, test_upward, test_downward):
Skip the 'long double' tests on NetBSD/sparc64.
* doc/posix-functions/fesetround.texi: Mention the problem with
'long double' operations on some platforms.

18 months agofenv-rounding: Improve code for MSVC.
Bruno Haible [Sat, 4 Nov 2023 13:07:22 +0000 (14:07 +0100)]
fenv-rounding: Improve code for MSVC.

* lib/fenv-round.c (fegetround) [MSVC]: Use the rounding direction from
the SSE unit. Don't assume stable values for FE_UPWARD and FE_DOWNWARD.
(fesetround) [MSVC]: Set the rounding direction only in the SSE unit.
Don't assume stable values for FE_UPWARD and FE_DOWNWARD.

18 months agofenv-rounding et al.: Require AC_CANONICAL_HOST before accessing $host.
Bruno Haible [Sat, 4 Nov 2023 12:54:56 +0000 (13:54 +0100)]
fenv-rounding et al.: Require AC_CANONICAL_HOST before accessing $host.

* m4/fenv-rounding.m4 (gl_FENV_ROUNDING): Require AC_CANONICAL_HOST.
* m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Likewise.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise.
* m4/iswdigit.m4 (gl_FUNC_ISWDIGIT): Likewise.
* m4/iswpunct.m4 (gl_FUNC_ISWPUNCT): Likewise.
* m4/iswxdigit.m4 (gl_FUNC_ISWXDIGIT): Likewise.
* m4/strerrorname_np.m4 (gl_FUNC_STRERRORNAME_NP): Likewise.
* m4/strfmon_l.m4 (gl_FUNC_STRFMON_L): Likewise.
* m4/unlink-busy.m4 (gl_FUNC_UNLINK_BUSY_TEXT): Likewise.
* m4/vasnprintf.m4 (gl_PREREQ_VASNWPRINTF): Likewise.
* m4/wcscmp.m4 (gl_FUNC_WCSCMP): Likewise.
* m4/wcsncmp.m4 (gl_FUNC_WCSNCMP): Likewise.

18 months agofenv: Document an ABI break on MSVC.
Bruno Haible [Sat, 4 Nov 2023 12:22:08 +0000 (13:22 +0100)]
fenv: Document an ABI break on MSVC.

* doc/posix-headers/fenv.texi: Document why fegetround and fesetround
are seemingly broken on MSVC.

18 months agofenv-exceptions-trapping: Add tests.
Bruno Haible [Tue, 31 Oct 2023 20:54:49 +0000 (21:54 +0100)]
fenv-exceptions-trapping: Add tests.

* tests/test-fenv-except-trapping-1.c: New file.
* tests/test-fenv-except-trapping-2.sh: New file.
* tests/test-fenv-except-trapping-2.c: New file.
* modules/fenv-exceptions-trapping-tests: New file.

18 months agofenv-exceptions-trapping: New module.
Bruno Haible [Tue, 31 Oct 2023 20:46:13 +0000 (21:46 +0100)]
fenv-exceptions-trapping: New module.

* lib/fenv.in.h (feenableexcept, fedisableexcept, fegetexcept): New
declarations.
* lib/fenv-except-trapping.c: New file, based on glibc.
* m4/fenv_h.m4 (gl_FENV_H): Test also whether fegetexcept is declared.
* m4/fenv-exceptions-trapping.m4: New file.
* modules/fenv-exceptions-trapping: New file.
* doc/glibc-functions/fegetexcept.texi: Mention the new module.
* doc/glibc-functions/fedisableexcept.texi: Likewise.
* doc/glibc-functions/feenableexcept.texi: Likewise. Mention the glibc,
macOS, FreeBSD bugs.

18 months agofenv-exceptions-state-c99: Fix the x86_64 and i386 case.
Bruno Haible [Mon, 30 Oct 2023 15:26:46 +0000 (16:26 +0100)]
fenv-exceptions-state-c99: Fix the x86_64 and i386 case.

* lib/fenv-except-state-set.c (fesetexceptflag): Make sure to restore
the exception trap bits in all cases.

18 months agofenv-exceptions-state-c23: Add tests.
Bruno Haible [Mon, 30 Oct 2023 15:52:20 +0000 (16:52 +0100)]
fenv-exceptions-state-c23: Add tests.

* tests/test-fenv-except-state-3.c: New file.
* modules/fenv-exceptions-state-c23-tests: New file.

18 months agofenv-exceptions-state-c23: New module.
Bruno Haible [Mon, 30 Oct 2023 15:49:25 +0000 (16:49 +0100)]
fenv-exceptions-state-c23: New module.

* lib/fenv.in.h (fetestexceptflag): New declaration.
* lib/fenv-except-state-test.c: New file, based on glibc.
* m4/fenv-exceptions-state-c23.m4: New file.
* modules/fenv-exceptions-state-c23: New file.
* doc/posix-functions/fetestexceptflag.texi: Mention the new module.

18 months agofenv-exceptions-state-c99: Add tests.
Bruno Haible [Mon, 30 Oct 2023 15:44:26 +0000 (16:44 +0100)]
fenv-exceptions-state-c99: Add tests.

* tests/test-fenv-except-state-1.c: New file.
* tests/test-fenv-except-state-2.c: New file.
* modules/fenv-exceptions-state-c99-tests: New file.

18 months agofenv-exceptions-state-c99: New module.
Bruno Haible [Mon, 30 Oct 2023 15:39:19 +0000 (16:39 +0100)]
fenv-exceptions-state-c99: New module.

* lib/fenv.in.h (fegetexceptflag, fesetexceptflag): New declarations.
* lib/fenv-except-state-get.c: New file, baed on glibc.
* lib/fenv-except-state-set.c: New file, baed on glibc.
* m4/mathfunc.m4 (gl_MATHFUNC): Handle also the 'fexcept_t *' type.
* m4/fenv-exceptions-state.m4: New file.
* modules/fenv-exceptions-state-c99: New file.
* doc/posix-functions/fegetexceptflag.texi: Mention the new module.
* doc/posix-functions/fesetexceptflag.texi: Mention the new module and
the glibc, musl libc, macOS, AIX, mingw bugs.

18 months agofenv-exceptions-tracking-{c99,c23}: Fix the x86_64 and i386 case.
Bruno Haible [Mon, 30 Oct 2023 15:32:30 +0000 (16:32 +0100)]
fenv-exceptions-tracking-{c99,c23}: Fix the x86_64 and i386 case.

* lib/fenv-except-tracking-clear.c (feclearexcept): Make sure to restore
the exception trap bits in all cases.
* lib/fenv-except-tracking-raise.c (feraiseexcept): Likewise.
* lib/fenv-except-tracking-set.c (fesetexcept): Likewise.

18 months agofenv-exceptions-tracking-c23: Add tests.
Bruno Haible [Sun, 29 Oct 2023 21:27:38 +0000 (22:27 +0100)]
fenv-exceptions-tracking-c23: Add tests.

* tests/test-fenv-except-tracking-4.c: New file.
* tests/test-fenv-except-tracking-5.c: New file.
* modules/fenv-exceptions-tracking-c23-tests: New file.

18 months agofenv-exceptions-tracking-c23: New module.
Bruno Haible [Sun, 29 Oct 2023 21:20:02 +0000 (22:20 +0100)]
fenv-exceptions-tracking-c23: New module.

* lib/fenv.in.h (fesetexcept): New declaration.
* lib/fenv-except-tracking-set.c: New file, based on glibc.
* lib/fenv-private.h (_GETMSR, _SETMSR, MSR_FP_EXC_MASK, PR_SET_FPEXC,
PR_FP_EXC_DISABLED, PR_FP_EXC_NONRECOV, PR_FP_EXC_ASYNC,
PR_FP_EXC_PRECISE, prctl) [NetBSD/powerpc]: New macros.
* m4/fenv-exceptions-tracking-c23.m4: New file.
* modules/fenv-exceptions-tracking-c23: New file.
* doc/posix-functions/fesetexcept.texi: Mention the new module and the
glibc bugs.

18 months agofenv-exceptions-tracking-c99: Fix feraiseexcept (FE_OVERFLOW) on MSVC.
Bruno Haible [Sat, 28 Oct 2023 22:29:46 +0000 (00:29 +0200)]
fenv-exceptions-tracking-c99: Fix feraiseexcept (FE_OVERFLOW) on MSVC.

* lib/fenv-except-tracking-raise.c (feraiseexcept): Use the generic
approach for all exceptions.

18 months agofpe-trapping: Always clear the FE_INVALID exception flag first.
Bruno Haible [Sat, 28 Oct 2023 16:42:47 +0000 (18:42 +0200)]
fpe-trapping: Always clear the FE_INVALID exception flag first.

* lib/fpe-trapping.h: Include <fenv.h> on all platforms.
(sigfpe_on_invalid) [AIX, HP-UX, IRIX, Solaris] : Clear the FE_INVALID
exception flag first.
* modules/fpe-trapping (Depends-on): Add fenv-exceptions-tracking-c99.

18 months agofenv-exceptions-tracking-c99: Add tests.
Bruno Haible [Sat, 28 Oct 2023 16:39:32 +0000 (18:39 +0200)]
fenv-exceptions-tracking-c99: Add tests.

* tests/test-fenv-except-tracking-1.c: New file.
* tests/test-fenv-except-tracking-2.sh: New file.
* tests/test-fenv-except-tracking-2.c: New file.
* tests/test-fenv-except-tracking-3.sh: New file.
* tests/test-fenv-except-tracking-3.c: New file.
* modules/fenv-exceptions-tracking-c99-tests: New file.

18 months agofenv-exceptions-tracking-c99: New module.
Bruno Haible [Sat, 28 Oct 2023 16:31:22 +0000 (18:31 +0200)]
fenv-exceptions-tracking-c99: New module.

* lib/fenv.in.h (feclearexcept, feraiseexcept, fetestexcept): New
declarations.
* lib/fenv-except-tracking-clear.c: New file, based on glibc.
* lib/fenv-except-tracking-raise.c: New file, based on glibc.
* lib/fenv-except-tracking-test.c: New file, based on glibc.
* m4/fenv-exceptions-tracking.m4: New file.
* m4/fenv-exceptions.m4: New file.
* modules/fenv-exceptions-tracking-c99: New file.
* doc/posix-functions/feclearexcept.texi: Mention the new module.
* doc/posix-functions/fetestexcept.texi: Likewise.
* doc/posix-functions/feraiseexcept.texi: Likewise. Mention the glibc
and Cygwin bugs.

18 months agofenv-rounding: Add tests.
Bruno Haible [Fri, 27 Oct 2023 18:26:56 +0000 (20:26 +0200)]
fenv-rounding: Add tests.

* tests/test-fenv-round.c: New file.
* modules/fenv-rounding-tests: New file.

18 months agofenv-rounding: New module.
Bruno Haible [Fri, 27 Oct 2023 18:16:50 +0000 (20:16 +0200)]
fenv-rounding: New module.

* lib/fenv.in.h (fegetround, fesetround): New declarations.
* lib/fenv-private.h: New file, based on glibc.
* lib/fenv-round.c: New file, based on glibc.
* m4/mathfunc.m4 (gl_MATHFUNC): Handle also the type fp_rnd.
* m4/fenv-rounding.m4: New file.
* modules/fenv (Depends-on): Add snippet/c++defs.
(Makefile.am): Substitute $(CXXDEFS_H) into fenv.h.
* modules/fenv-rounding: New file.
* doc/posix-functions/fegetround.texi: Mention the new module.
* doc/posix-functions/fesetround.texi: Likewise.

18 months agotests: Use C99 initializer syntax for memory_long_double.
Bruno Haible [Fri, 27 Oct 2023 18:02:27 +0000 (20:02 +0200)]
tests: Use C99 initializer syntax for memory_long_double.

* tests/test-isfinite.c (test_isfinitel): Use '.word = ...' syntax when
initializing memory_long_double variables.
* tests/test-isinf.c (test_isinfl): Likewise.
* tests/test-isnan.c (test_long_double): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasnprintf-posix.c (test_function): Likewise.
* tests/test-vasnwprintf-posix.c (test_function): Likewise.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* modules/isfinite-tests (Depends-on): Add c99.
* modules/isinf-tests (Depends-on): Likewise.
* modules/isnan-tests (Depends-on): Likewise.
* modules/isnanl-nolibm-tests (Depends-on): Likewise.
* modules/isnanl-tests (Depends-on): Likewise.
* modules/pipe-filter-gi-tests (Depends-on): Likewise.
* modules/pipe-filter-ii-tests (Depends-on): Likewise.
* modules/snprintf-posix-tests (Depends-on): Likewise.
* modules/sprintf-posix-tests (Depends-on): Likewise.
* modules/vasnprintf-posix-tests (Depends-on): Likewise.
* modules/vasnwprintf-posix-tests (Depends-on): Likewise.
* modules/vasprintf-posix-tests (Depends-on): Likewise.
* modules/vsnprintf-posix-tests (Depends-on): Likewise.
* modules/vsprintf-posix-tests (Depends-on): Likewise.

18 months agobase32, base64: disallow non-canonical encodings
Pádraig Brady [Thu, 26 Oct 2023 15:25:03 +0000 (16:25 +0100)]
base32, base64: disallow non-canonical encodings

Unconditionally disallow encodings that don't have
appropriate zero bits before padding characters.
This handles one class of encoding variations discussed at:
https://eprint.iacr.org/2022/361.pdf
Note the other variations discussed there, due to optional
padding characters are already disallowed.

* lib/base32.c: Check that discarded bits in the encoding are zero.
* lib/base64.c: Likewise.
* tests/test-base32.c: Add test cases.
* tests/test-base64.c: Likewise.

18 months agofenv: Add tests.
Bruno Haible [Fri, 27 Oct 2023 01:46:25 +0000 (03:46 +0200)]
fenv: Add tests.

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

18 months agofenv: New module.
Bruno Haible [Fri, 27 Oct 2023 01:43:15 +0000 (03:43 +0200)]
fenv: New module.

* lib/fenv.in.h: New file, based on glibc.
* m4/fenv_h.m4: New file.
* modules/fenv: New file.
* doc/posix-headers/fenv.texi: Mention the new module.

18 months agobase32: fix typo in previous commit
Paul Eggert [Wed, 25 Oct 2023 21:38:10 +0000 (14:38 -0700)]
base32: fix typo in previous commit

* lib/base32.c (BASE32_INLINE): Rename from BASE64_INLINE.

18 months agobase32: new function isubase32; also, tune.
Paul Eggert [Wed, 25 Oct 2023 21:14:15 +0000 (14:14 -0700)]
base32: new function isubase32; also, tune.

* lib/base32.c (BASE32_INLINE): Define.
(base32_to_int): Rename from b32 and make it extern.  All uses changed.
(uchar_in_range): Remove.  All uses removed.
(isbase32, base32_decode_ctx_init):
Move to lib/base32.h and make inline.
* lib/base32.h: Ignore -Wtype-limits, so that we needn’t
worry about uchar_in_range.
(BASE32_INLINE): Define, and use _GL_INLINE_HEADER_BEGIN.
(isubase32): New function, useful as it as a different signature.
(isbase32): Define in terms of isubase32.
* modules/base32 (Depends-on): Add extern-inline.

18 months agobase64: new function isubase64; also, tune.
Paul Eggert [Wed, 25 Oct 2023 21:00:40 +0000 (14:00 -0700)]
base64: new function isubase64; also, tune.

* lib/base64.c (BASE64_INLINE): Define.
(base64_to_int): Rename from b64 and make it extern.  All uses changed.
(uchar_in_range): Remove.  All uses removed.
(isbase64, base64_decode_ctx_init):
Move to lib/base64.h and make inline.
* lib/base64.h: Ignore -Wtype-limits, so that we needn’t
worry about uchar_in_range.
(BASE64_INLINE): Define, and use _GL_INLINE_HEADER_BEGIN.
(isubase64): New function, useful as it as a different signature.
(isbase64): Define in terms of isubase64.
* modules/base64 (Depends-on): Add extern-inline.

18 months agotests/unistr/u16-chr-tests: pacify -Wcast-align
Paul Eggert [Wed, 25 Oct 2023 01:40:07 +0000 (18:40 -0700)]
tests/unistr/u16-chr-tests: pacify -Wcast-align

* tests/unistr/test-chr.h (main): Redo types to pacify
gcc -Wcast-align.

18 months agoisnanl-tests, stdio-tests: pacify GCC -Wshadow
Paul Eggert [Wed, 25 Oct 2023 01:37:37 +0000 (18:37 -0700)]
isnanl-tests, stdio-tests: pacify GCC -Wshadow

* tests/test-isnanl.h (NWORDS): Remove.
(memory_long_double): Do not redefine in an inner scope.
All uses changed to use the snan.h memory_long_double.
* tests/test-stdio.c (NWORDS): Remove.
(memory_long_double): Do not redefine in an inner scope.
The snan.h memory_long_double is fine here.

18 months agoexplicit_bzero-tests: pacify GCC 13.2.1
Paul Eggert [Wed, 25 Oct 2023 01:33:44 +0000 (18:33 -0700)]
explicit_bzero-tests: pacify GCC 13.2.1

* tests/test-explicit_bzero.c:
* tests/test-memset_explicit.c:
Ignore -Wdangling pointer.

18 months agomemset_explicit, explicit_bzero tests: Fix test failures with new gcc.
Bruno Haible [Mon, 23 Oct 2023 00:04:03 +0000 (02:04 +0200)]
memset_explicit, explicit_bzero tests: Fix test failures with new gcc.

Reported by Sam James <sam@gentoo.org> in
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111904>.

Fix by Alexandre Oliva <aoliva@gcc.gnu.org>.

* tests/test-memset_explicit.c (do_secret_stuff): Declare with
attributes 'noclone' and 'noipa'.
* tests/test-explicit_bzero.c (do_secret_stuff): Likewise.

18 months agonet_if tests: Fix gcc warning.
Bruno Haible [Sun, 15 Oct 2023 21:15:55 +0000 (23:15 +0200)]
net_if tests: Fix gcc warning.

* tests/test-net_if.c: Include <string.h>.

18 months agombspbrk: Fix gcc warning (regression 2023-09-26).
Bruno Haible [Sun, 15 Oct 2023 21:12:44 +0000 (23:12 +0200)]
mbspbrk: Fix gcc warning (regression 2023-09-26).

* lib/mbspbrk.c (mbspbrk): Fix gcc warning in GNULIB_MCEL_PREFER mode.