]> Savannah Git Hosting - gnulib.git/log
gnulib.git
5 months agowcsncat tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:39 +0000 (21:11 +0100)]
wcsncat tests: Verify N3322 functionality.

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

5 months agowcsncat: Guarantee N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:33 +0000 (21:11 +0100)]
wcsncat: Guarantee N3322 functionality.

* lib/wchar.in.h (wcsncat): Consider REPLACE_WCSNCAT.
* m4/wcsncat.m4 (gl_FUNC_WCSNCAT): Test whether the zero-length bug is
present.
* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCSNCAT.
* modules/wchar (Makefile.am): Substitute REPLACE_WCSNCAT.
* modules/wcsncat (Status, Notice): Remove.
(configure.ac): Consider REPLACE_WCSNCAT.
* doc/posix-functions/wcsncat.texi: Mention the zero-length bug.

5 months agowmemmove tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:29 +0000 (21:11 +0100)]
wmemmove tests: Verify N3322 functionality.

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

5 months agowmemcpy tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:25 +0000 (21:11 +0100)]
wmemcpy tests: Verify N3322 functionality.

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

5 months agowcsncpy tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:22 +0000 (21:11 +0100)]
wcsncpy tests: Verify N3322 functionality.

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

5 months agomemset_explicit tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:20 +0000 (21:11 +0100)]
memset_explicit tests: Verify N3322 functionality.

* tests/test-memset_explicit.c (main): Add a zero-size test.

5 months agomemset tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:17 +0000 (21:11 +0100)]
memset tests: Verify N3322 functionality.

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

5 months agomemchr tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:14 +0000 (21:11 +0100)]
memchr tests: Verify N3322 functionality.

* tests/test-memchr.c (main): Add a zero-size test.

5 months agostrncmp tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:12 +0000 (21:11 +0100)]
strncmp tests: Verify N3322 functionality.

* modules/strncmp: New file.
* doc/posix-functions/strncmp.texi: Mention the new module.
* tests/test-strncmp.c: New file.
* modules/strncmp-tests: New file.

5 months agomemcmp tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:10 +0000 (21:11 +0100)]
memcmp tests: Verify N3322 functionality.

* tests/test-memcmp.c (main): Add zero-size tests.

5 months agostrncat tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:11:02 +0000 (21:11 +0100)]
strncat tests: Verify N3322 functionality.

* tests/test-strncat.c (main): Add a zero-size test.

5 months agostrndup tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:23 +0000 (21:10 +0100)]
strndup tests: Verify N3322 functionality.

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

5 months agostrndup: Guarantee N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:20 +0000 (21:10 +0100)]
strndup: Guarantee N3322 functionality.

* m4/strndup.m4 (gl_FUNC_STRNDUP): Check against the AIX bug.
* doc/posix-functions/strndup.texi: Mention the AIX bug.

5 months agostrncpy tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:13 +0000 (21:10 +0100)]
strncpy tests: Verify N3322 functionality.

* modules/strncpy: New file.
* doc/posix-functions/strncpy.texi: Mention the new module.
* tests/test-strncpy.c: New file.
* modules/strncpy-tests: New file.

5 months agomemmove tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:11 +0000 (21:10 +0100)]
memmove tests: Verify N3322 functionality.

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

5 months agomemccpy tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:08 +0000 (21:10 +0100)]
memccpy tests: Verify N3322 functionality.

* modules/memccpy: New file.
* doc/posix-functions/memccpy.texi: Mention the new module.
* tests/test-memccpy.c: New file.
* modules/memccpy-tests: New file.

5 months agomemcpy tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:05 +0000 (21:10 +0100)]
memcpy tests: Verify N3322 functionality.

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

5 months agoqsort tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:10:02 +0000 (21:10 +0100)]
qsort tests: Verify N3322 functionality.

* modules/qsort: New file.
* doc/posix-functions/qsort.texi: Mention the new module.
* tests/test-qsort.c: New file.
* modules/qsort-tests: New file.

5 months agobsearch tests: Verify N3322 functionality.
Bruno Haible [Tue, 5 Nov 2024 20:09:07 +0000 (21:09 +0100)]
bsearch tests: Verify N3322 functionality.

* modules/bsearch: New file.
* doc/posix-functions/bsearch.texi: Mention the new module.
* tests/test-bsearch.c: New file.
* modules/bsearch-tests: New file.

5 months agorealloc-posix: Avoid use of AC_LIBOBJ.
Bruno Haible [Tue, 5 Nov 2024 21:18:35 +0000 (22:18 +0100)]
realloc-posix: Avoid use of AC_LIBOBJ.

* modules/realloc-posix (configure.ac): Define
GL_COND_OBJ_REALLOC_POSIX. Don't invoke AC_LIBOBJ.
(Makefile.am): Add realloc.c to lib_SOURCES instead.

5 months agorealloc-posix: Fix link error (regression yesterday).
Bruno Haible [Tue, 5 Nov 2024 21:16:12 +0000 (22:16 +0100)]
realloc-posix: Fix link error (regression yesterday).

* lib/stdlib.in.h (realloc): Don't inline rpl_realloc if IN_GNULIB_TESTS
is defined.
* modules/realloc-posix (Depends-on, configure.ac): Compile realloc.c
also if REPLACE_REALLOC_FOR_REALLOC_POSIX is 2.

5 months agostdlib: Add a copyright header.
Bruno Haible [Tue, 5 Nov 2024 15:23:41 +0000 (16:23 +0100)]
stdlib: Add a copyright header.

* lib/stdlib.c: Add a copyright header.

5 months agocalloc, malloc: Fix a comment.
Bruno Haible [Tue, 5 Nov 2024 14:53:47 +0000 (15:53 +0100)]
calloc, malloc: Fix a comment.

* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Mention that it sets
HAVE_MALLOC_PTRDIFF.
(gl_FUNC_MALLOC_PTRDIFF): Likewise.
(gl_CHECK_MALLOC_PTRDIFF): Do not mention HAVE_MALLOC_PTRDIFF here.

5 months agocalloc: Fix configure test (regression yesterday).
Bruno Haible [Tue, 5 Nov 2024 14:30:49 +0000 (15:30 +0100)]
calloc: Fix configure test (regression yesterday).

* m4/calloc.m4 (gl_FUNC_CALLOC_IF): Fix wrong cache variable name.
Rename cache variable. Restore earlier comment.

5 months agosafe-alloc: simplify, given new reallocarray behavior
Paul Eggert [Tue, 5 Nov 2024 06:24:29 +0000 (22:24 -0800)]
safe-alloc: simplify, given new reallocarray behavior

* lib/safe-alloc.h [__CHERI_PURE_CAPABILITY__]:
Remove special cases for this, as reallocarray
now does it for us.
(safe_alloc_realloc_n): Remove.  All uses replaced by reallocarray.

5 months agoargz: defend against realloc (0, 0)
Paul Eggert [Tue, 5 Nov 2024 05:38:55 +0000 (21:38 -0800)]
argz: defend against realloc (0, 0)

* modules/argz (Depends-on): Add realloc-posix so that
argz_append doesn’t wrongly fail with ENOMEM on AIX.

5 months agorealloc-posix: update doc
Paul Eggert [Tue, 5 Nov 2024 03:09:08 +0000 (19:09 -0800)]
realloc-posix: update doc

* doc/posix-functions/realloc.texi: Update to match recent Gnulib
changes and OS discoveries, and to clarify and simplify by
coalescing behaviors (4) and (5).

5 months agodoc: mention Solaris malloc ENOMEM issues
Paul Eggert [Tue, 5 Nov 2024 02:24:07 +0000 (18:24 -0800)]
doc: mention Solaris malloc ENOMEM issues

5 months agorealloc-posix: tune for glibc-like
Paul Eggert [Tue, 5 Nov 2024 02:16:50 +0000 (18:16 -0800)]
realloc-posix: tune for glibc-like

For glibc, implementing realloc (p, s) as realloc (p, s?s:1) suffices,
and it’s probably better to do it inline to aid static checking.
* lib/realloc.c (rpl_realloc) [_GL_INLINE_RPL_REALLOC]:
Remove, replacing with inline function in stdlib.h.
* lib/stdlib.in.h (_GL_INLINE_RPL_REALLOC): New macro.
(rpl_realloc): Define as inline if _GL_INLINE_RPL_REALLOC.
* m4/realloc.m4 (gl_FUNC_REALLOC_0_NONNULL):
Set REPLACE_REALLOC_FOR_REALLOC_POSIX=2 instead of 1,
if it’s close enough to glibc that the inline optimization is valid.

5 months agorealloc-posix: use _GL_USE_STDLIB_ALLOC
Paul Eggert [Mon, 4 Nov 2024 23:31:15 +0000 (15:31 -0800)]
realloc-posix: use _GL_USE_STDLIB_ALLOC

* lib/realloc.c (_GL_USE_STDLIB_ALLOC):
New macro, which we can use now that we don’t use malloc.
(realloc): Do not undef; no longer needed.

5 months agostdlib: make MB_CUR_MAX usable from extern inline
Paul Eggert [Mon, 4 Nov 2024 19:12:21 +0000 (11:12 -0800)]
stdlib: make MB_CUR_MAX usable from extern inline

* lib/stdlib.c: New file.
* modules/stdlib (Files, lib_SOURCES): Add it.
(Depends-on): Add extern-inline.
* lib/stdlib.in.h: Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
(_GL_STDLIB_INLINE): New macro.
(gl_MB_CUR_MAX): Make it _GL_STDLIB_INLINE not static inline,
so that it can be called from extern inline functions.
Redo implementation to help GCC better optimize common expressions
like (MB_CUR_MAX == 1).

5 months agorealloc-posix: set CHERI bounds
Paul Eggert [Mon, 4 Nov 2024 07:27:52 +0000 (23:27 -0800)]
realloc-posix: set CHERI bounds

* lib/ialloc.h, lib/xmalloc.c [__CHERI_PURE_CAPABILITY__]:
Do nothing special, as realloc and reallocarray
should do this for us now.
* lib/realloc.c [__CHERI_PURE_CAPABILITY__]:
Include cheri.h, and arrange for rpl_realloc to set bounds.

5 months agorealloc-posix: realloc (..., 0) now returns nonnull
Paul Eggert [Mon, 4 Nov 2024 06:41:41 +0000 (22:41 -0800)]
realloc-posix: realloc (..., 0) now returns nonnull

* lib/realloc.c (rpl_realloc): Simplify and tune by using
HAVE_REALLOC_0_NONNULL and HAVE_MALLOC_PTRDIFF, and
by having just one call to realloc instead of two.
* lib/reallocarray.c (reallocarray): Simplify and tune
by delegating the zero case to the revised realloc.
* m4/eealloc.m4 (_AC_FUNC_REALLOC_IF): Since only eealloc uses
this macro now, move its definition here ...
* m4/realloc.m4: ... from here.
(gl_FUNC_REALLOC_0_NONNULL): Also check that realloc (p, 0)
returns nonnull.  Require gl_FUNC_REALLOC_POSIX.
Define HAVE_REALLOC_0_NONNULL.
* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY):
Also replace reallocarray if it returns a null pointer for size zero.
* modules/eealloc (Files): Remove m4/realloc.m4.
* modules/realloc-posix (Depends-on): Add extensions-aix.
* modules/reallocarray (Files): Add m4/realloc.m4.

5 months agostdlib: simplify preprocessor conditionals
Paul Eggert [Mon, 4 Nov 2024 06:02:28 +0000 (22:02 -0800)]
stdlib: simplify preprocessor conditionals

* lib/stdlib.in.h: Omit some redundant tests in conditionals.

5 months agorealloc: don’t require success for nongrowth
Paul Eggert [Mon, 4 Nov 2024 05:44:15 +0000 (21:44 -0800)]
realloc: don’t require success for nongrowth

* lib/realloc.c (rpl_realloc): Do not require realloc (p, 0) to
succeed, as apparently glibc realloc (p, n) can sometimes fail
even when the region would not grow.

5 months agocalloc, malloc: tune a bit
Paul Eggert [Mon, 4 Nov 2024 02:18:58 +0000 (18:18 -0800)]
calloc, malloc: tune a bit

This applies mostly to non-glibc platforms, or to 32-bit
glibc before glibc 2.30 (2019).
* lib/calloc.c (rpl_calloc):
* lib/malloc.c (rpl_malloc):
Optimize away some of the code if !HAVE_MALLOC_0_NONNULL or if
!HAVE_MALLOC_PTRDIFF.
* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Define HAVE_MALLOC_0_NONNULL.
(gl_FUNC_MALLOC_PTRDIFF): Define HAVE_MALLOC_PTRDIFF.

5 months agocalloc: configure more like malloc
Paul Eggert [Sun, 3 Nov 2024 20:24:03 +0000 (12:24 -0800)]
calloc: configure more like malloc

* m4/calloc.m4 (gl_FUNC_CALLOC_IF): Rename from _AC_FUNC_CALLOC_IF
since this is not derived from Autoconf.  All uses changed.
Redo implementation so that it is more like _AC_FUNC_MALLOC_IF;
this fixes some problems with "volatile" and modernizes the known
platforms.

5 months agomalloc-gnu: depend on stdckdint not xalloc-oversized
Paul Eggert [Sun, 3 Nov 2024 20:19:33 +0000 (12:19 -0800)]
malloc-gnu: depend on stdckdint not xalloc-oversized

* lib/malloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_malloc): Use ckd_mul instead of xalloc_oversized.
* modules/malloc-gnu, modules/malloc-posix:
(Depends-on): Depend on stdckdint, not xalloc-oversized.

5 months agocalloc: depend on stdckdint not xalloc-oversized
Paul Eggert [Sun, 3 Nov 2024 19:11:03 +0000 (11:11 -0800)]
calloc: depend on stdckdint not xalloc-oversized

* lib/calloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_calloc): Use ckd_mul instead of xalloc_oversized.
* modules/calloc-gnu, modules/calloc-posix:
(Depends-on): Depend on stdckdint, not xalloc-oversized.

5 months agomalloc etc. tests: use volatile more consistently
Paul Eggert [Mon, 4 Nov 2024 17:38:03 +0000 (09:38 -0800)]
malloc etc. tests: use volatile more consistently

Typically it’s ineffective to use ‘void *volatile p’
when testing malloc and similar functions, as the compiler
can optimize the call to malloc before assigning the result
to the volatile pointer variable.  Instead, be more systematic
about calling malloc through a volatile function pointer
so that the compiler cannot infer that it is a malloc call.
This fix can’t be done for alloca-like functions which may not
have a function address, so continue to trust to luck there.
* tests/test-aligned-malloc.c (aligned4_malloc, aligned4_free)
(aligned8_malloc, aligned8_free, aligned16_malloc)
(aligned16_free, aligned32_malloc, aligned32_free):
* tests/test-aligned_alloc.c (aligned_alloc):
* tests/test-calloc-gnu.c (calloc):
* tests/test-free.c (free):
* tests/test-malloc-gnu.c (malloc):
* tests/test-reallocarray.c (reallocarray):
Test indirectly, by calling through a volatile pointer.
* tests/test-aligned-malloc.c, tests/test-aligned_alloc.c:
* tests/test-calloc-gnu.c, tests/test-calloc-posix.c:
* tests/test-free.c, tests/test-malloc-gnu.c:
* tests/test-malloc-posix.c, tests/test-realloc-posix.c:
* tests/test-reallocarray.c:
(main) Don’t bother making data pointers olatile, as it’s ineffective.
* tests/test-calloc-gnu.c (identity):
* tests/test-free.c (get_errno, get_errno_func):
Remove; all uses removed.

5 months agoaligned_alloc: Fix test failures on macOS, Solaris (regr. 2024-10-30).
Bruno Haible [Mon, 4 Nov 2024 16:50:09 +0000 (17:50 +0100)]
aligned_alloc: Fix test failures on macOS, Solaris (regr. 2024-10-30).

* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Check for the Solaris
bug. Let the test program return a bit mask. Update cross-compilation
guesses.
* lib/aligned_alloc.c: Include <errno.h>.
(aligned_alloc): Fail if the alignment is not a power of 2. Work around
the Solaris bug.
* modules/aligned_alloc (Depends-on): Add malloc-posix.
* doc/posix-functions/aligned_alloc.texi: Mention the Solaris bug.

6 months agotests: Add comments.
Bruno Haible [Mon, 4 Nov 2024 12:49:22 +0000 (13:49 +0100)]
tests: Add comments.

* tests/test-aligned_alloc.c (main): Clarify that we test a zero size.
* tests/test-posix_memalign.c (main): Likewise.

6 months agomalloc, calloc, realloc tests: Work around clang optimization bug.
Bruno Haible [Mon, 4 Nov 2024 10:47:23 +0000 (11:47 +0100)]
malloc, calloc, realloc tests: Work around clang optimization bug.

* tests/test-malloc-posix.c (my_malloc): New variable.
* tests/test-calloc-posix.c (my_calloc): New variable.
* tests/test-realloc-posix.c (my_realloc): New variable.

6 months agocrc: Fix build rules with Automake's option 'subdir-objects'.
Bruno Haible [Sun, 3 Nov 2024 20:18:29 +0000 (21:18 +0100)]
crc: Fix build rules with Automake's option 'subdir-objects'.

Reported by Pádraig Brady in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-11/msg00011.html>.

* build-aux/prefix-gnulib-mk: Add comments.
(usage): Mark this usage as deprecated.
* modules/crc (Makefile.am): Use %reldir%. Write $(srcdir)/. instead of
$(srcdir).

6 months agoselect: Document a Haiku bug.
Bruno Haible [Fri, 1 Nov 2024 22:04:06 +0000 (23:04 +0100)]
select: Document a Haiku bug.

* doc/posix-functions/select.texi: Mention a Haiku bug.

6 months agoeealloc: Revert last change.
Bruno Haible [Fri, 1 Nov 2024 12:44:12 +0000 (13:44 +0100)]
eealloc: Revert last change.

* m4/eealloc.m4 (gl_EEMALLOC): Invoke _AC_FUNC_MALLOC_IF, not
gl_CHECK_MALLOC_POSIX.

6 months agorealloc-posix: Fix test failure on AIX (regression 2024-10-27).
Bruno Haible [Fri, 1 Nov 2024 12:26:40 +0000 (13:26 +0100)]
realloc-posix: Fix test failure on AIX (regression 2024-10-27).

* m4/realloc.m4 (gl_FUNC_REALLOC_0_NONNULL): New macro.
* modules/realloc-posix (configure.ac): Invoke it.

6 months agoeealloc: Use the same cross-compilation guess as malloc-posix.
Bruno Haible [Fri, 1 Nov 2024 11:28:05 +0000 (12:28 +0100)]
eealloc: Use the same cross-compilation guess as malloc-posix.

* m4/eealloc.m4 (gl_EEMALLOC): Invoke gl_CHECK_MALLOC_POSIX, not
_AC_FUNC_MALLOC_IF.
* modules/malloca (Files): Add m4/malloc.m4.
* modules/regex (Files): Likewise.

6 months agoImprove log output of an Autoconf test.
Bruno Haible [Fri, 1 Nov 2024 11:25:22 +0000 (12:25 +0100)]
Improve log output of an Autoconf test.

* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): On native Windows, report
"guessing yes/no".
(gl_FUNC_MALLOC_POSIX): Update.
* m4/strdup.m4 (gl_FUNC_STRDUP_POSIX): Likewise.

6 months agomalloc, realloc: fix $3 bug
Paul Eggert [Fri, 1 Nov 2024 02:22:22 +0000 (19:22 -0700)]
malloc, realloc: fix $3 bug

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2024-10/msg00284.html
* m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
* m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
Sync from bleeding-edge Autoconf again.

6 months agocrc: Support generating the tables also when cross-compiling.
Bruno Haible [Thu, 31 Oct 2024 23:17:20 +0000 (00:17 +0100)]
crc: Support generating the tables also when cross-compiling.

* m4/build-cc.m4: New file.
* modules/crc (Files): Add it.
(configure.ac): Invoke gl_BUILD_CC. Don't set GL_CROSS_COMPILING.
(Makefile.am): Use $(BUILD_CC) etc. instead of $(CC) etc.

6 months agomalloc-posix, realloc-posix: Fix incorrect expansion of AC_FUNC_MALLOC.
Bruno Haible [Thu, 31 Oct 2024 21:11:22 +0000 (22:11 +0100)]
malloc-posix, realloc-posix: Fix incorrect expansion of AC_FUNC_MALLOC.

* m4/malloc.m4 (_AC_FUNC_MALLOC_IF): Handle the case of a missing third
argument.
* m4/realloc.m4 (_AC_FUNC_REALLOC_IF): Likewise.

6 months agomalloc-gnu, eealloc: Make code more future-proof.
Bruno Haible [Thu, 31 Oct 2024 21:04:42 +0000 (22:04 +0100)]
malloc-gnu, eealloc: Make code more future-proof.

* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Protect evaluation of
$gl_cross_guess_normal.
* m4/eealloc.m4 (gl_EEMALLOC, gl_EEREALLOC): Likewise.

6 months agomalloc-posix, calloc-posix, realloc-posix: Optimize on MSVC.
Bruno Haible [Thu, 31 Oct 2024 19:54:52 +0000 (20:54 +0100)]
malloc-posix, calloc-posix, realloc-posix: Optimize on MSVC.

* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): Assume that malloc sets errno
upon failure if UCRT is in use.

6 months agorealloc-posix tests: Enhance tests.
Bruno Haible [Thu, 31 Oct 2024 19:54:45 +0000 (20:54 +0100)]
realloc-posix tests: Enhance tests.

* tests/test-realloc-posix.c (main): Check errno also after normal
failing realloc calls.

6 months agorealloc-posix tests: Fix memory leak.
Bruno Haible [Thu, 31 Oct 2024 19:54:41 +0000 (20:54 +0100)]
realloc-posix tests: Fix memory leak.

* tests/test-realloc-posix.c (main): Don't clobber variable 'p' in
failing call.

6 months agocalloc-posix: Add tests.
Bruno Haible [Thu, 31 Oct 2024 19:54:36 +0000 (20:54 +0100)]
calloc-posix: Add tests.

* tests/test-calloc-posix.c: New file.
* modules/calloc-posix-tests: New file.

6 months agomalloc-posix: Add tests.
Bruno Haible [Thu, 31 Oct 2024 19:54:15 +0000 (20:54 +0100)]
malloc-posix: Add tests.

* tests/test-malloc-posix.c: New file.
* modules/malloc-posix-tests: New file.

6 months agorealloc-posix: Set errno when failing (regression 2029-10-29).
Bruno Haible [Thu, 31 Oct 2024 19:53:17 +0000 (20:53 +0100)]
realloc-posix: Set errno when failing (regression 2029-10-29).

* lib/realloc.c (rpl_realloc): When failing, with HAVE_MALLOC_POSIX not
defined, set errno.

6 months agocrc: Avoid potential conflict with other configure.ac files.
Bruno Haible [Thu, 31 Oct 2024 19:51:10 +0000 (20:51 +0100)]
crc: Avoid potential conflict with other configure.ac files.

Suggested by Simon Josefsson.

* modules/crc (configure.ac, Makefile.am): Rename CROSS_COMPILING to
GL_CROSS_COMPILING.

6 months agocrc: Fix compile warnings
Sam Russell [Thu, 31 Oct 2024 13:59:37 +0000 (14:59 +0100)]
crc: Fix compile warnings

* lib/crc-generate-table.c: Mark non-exported functions as static
* lib/crc.c: Mark non-exported functions as static

Signed-off-by: Simon Josefsson <simon@josefsson.org>
6 months agocrc: Don't attempt to run a compiled C program when cross-compiling.
Bruno Haible [Thu, 31 Oct 2024 13:48:35 +0000 (14:48 +0100)]
crc: Don't attempt to run a compiled C program when cross-compiling.

* lib/crc-generate-table.c: Don't include config.h.
* modules/crc (configure.ac): Define CROSS_COMPILING variable. Invoke
AC_PROG_MKDIR_P.
(Makefile.am): When cross-compiling, don't regenerate crc-sliceby8.h.
Don't use Gnulib modules while compiling the generator.

6 months agocrc: Tweak generator.
Bruno Haible [Thu, 31 Oct 2024 13:23:09 +0000 (14:23 +0100)]
crc: Tweak generator.

* lib/crc-generate-table.c (print_header): Don't emit a blank line at
the end.
(print_copyright_notice): Prepend a "DO NOT EDIT" line.
(main): Fail if disk is full after we wrote part of the file.

6 months agocrc: make it a maintainer setting rather than a user setting.
Simon Josefsson [Thu, 31 Oct 2024 12:10:34 +0000 (13:10 +0100)]
crc: make it a maintainer setting rather than a user setting.

* m4/crc.m4 (gl_CRC_SLICE_BY_8): Drop AC_ARG_ENABLE.

6 months agocrc: New optimised slice-by-8 implementation
Sam Russell [Sun, 27 Oct 2024 12:19:17 +0000 (13:19 +0100)]
crc: New optimised slice-by-8 implementation

* lib/crc.c: Implementation of slice-by-8 algorithm
* lib/crc-generate-table.c: Generation code for CRC32 lookup tables
* m4/crc.m4: Autoconf enable slice-by-8, flag to disable
* modules/crc (Depends-on): Add endian.
(Makefile.am): Build slice-by-8 tables from crc-generate-table.c.

Signed-off-by: Simon Josefsson <simon@josefsson.org>
6 months agoposix_memalign: Fix configure test (regression yesterday).
Bruno Haible [Thu, 31 Oct 2024 11:13:17 +0000 (12:13 +0100)]
posix_memalign: Fix configure test (regression yesterday).

* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Fix typo in comment.
Fix variable name.

6 months agoaligned_alloc: Fix comment.
Bruno Haible [Thu, 31 Oct 2024 11:09:46 +0000 (12:09 +0100)]
aligned_alloc: Fix comment.

* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Fix typo in comment.

6 months agoassert-h: Allow mixed use of gcc/g++ also on Haiku 2022.
Bruno Haible [Thu, 31 Oct 2024 03:34:29 +0000 (04:34 +0100)]
assert-h: Allow mixed use of gcc/g++ also on Haiku 2022.

* m4/assert_h.m4 (gl_ASSERT_H): Don't assume that in C mode, <assert.h>
defines static_assert.

6 months agofutimes, utimensat, utimes, utime: Document Haiku malfunction.
Bruno Haible [Wed, 30 Oct 2024 22:21:04 +0000 (23:21 +0100)]
futimes, utimensat, utimes, utime: Document Haiku malfunction.

* doc/posix-functions/futimens.texi: Mention Haiku's brokenness.
* doc/posix-functions/utimensat.texi: Likewise.
* doc/posix-functions/utimes.texi: Likewise.
* doc/pastposix-functions/utime.texi: Likewise.

6 months agoposix_memalign: check for GNU behavior with size 0
Paul Eggert [Wed, 30 Oct 2024 19:47:02 +0000 (12:47 -0700)]
posix_memalign: check for GNU behavior with size 0

* lib/posix_memalign.c: Include stdckdint.h.
(posix_memalign): Test for overflow more straightforwardly,
and more portably to unlikely platforms where SIZE_MAX <= INT_MAX.
Treat a zero size as if it were alignment.
* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN):
* tests/test-posix_memalign.c (main):
Test zero size too.  Use volatile to avoid compiler optimizations.
* modules/posix_memalign (Depends-on): Add stdckdint.

6 months agoaligned_alloc: check for GNU behavior with size 0
Paul Eggert [Wed, 30 Oct 2024 18:54:57 +0000 (11:54 -0700)]
aligned_alloc: check for GNU behavior with size 0

If someone ever needs to distinguish between GNU and merely POSIX
behavior we can split this into two modules, but for now just
make this module act like GNU.
* lib/aligned_alloc.c (aligned_alloc): Treat zero size like GNU.
* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC):
* tests/test-aligned_alloc.c (main):
Test zero size too.

6 months agoassert-h, stdbool: Fix compilation error with MSVC 14 (regr. yesterday).
Bruno Haible [Wed, 30 Oct 2024 14:56:41 +0000 (15:56 +0100)]
assert-h, stdbool: Fix compilation error with MSVC 14 (regr. yesterday).

* m4/assert_h.m4 (gl_ASSERT_H): Add parentheses to the preprocessor
expression.
* m4/c-bool.m4 (gl_C_BOOL): Likewise.

6 months agomalloc, realloc: sync from Autoconf master
Paul Eggert [Wed, 30 Oct 2024 05:01:44 +0000 (22:01 -0700)]
malloc, realloc: sync from Autoconf master

* m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
* m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
Sync from bleeding-edge Autoconf.  All uses changed.

6 months agomalloc: fix recent doc bug for AIX 7.3
Paul Eggert [Wed, 30 Oct 2024 05:01:43 +0000 (22:01 -0700)]
malloc: fix recent doc bug for AIX 7.3

* doc/posix-functions/malloc.texi: Undo previous change,
as _LINUX_SOURCE_COMPAT no longer affects malloc on AIX 7.3.
It did affect it in AIX 7.1 but 7.1 is no longer supported.

6 months agorealloc-posix: realloc (p, 0) yields nonnull
Paul Eggert [Wed, 30 Oct 2024 05:01:42 +0000 (22:01 -0700)]
realloc-posix: realloc (p, 0) yields nonnull

* lib/realloc.c: Include <stdckdint.h>, not "xalloc-oversized.h".
Use of xalloc_oversized replaced by ckd_add.
(rpl_realloc) [!NEED_SANITIZED_REALLOC]:
Treat realloc (p, 0) as if it were a realloc (p, 1) that never fails.
That’s easier, reduces module dependencies,
and better supports the future alloc-0-nonnull module.
* modules/realloc-posix (Depends-on): Remove free-posix,
malloc-posix, xalloc-oversized.  Add stdckdint.

6 months agobackupfile: Remove non-existent module dependency.
Collin Funk [Wed, 30 Oct 2024 03:12:25 +0000 (20:12 -0700)]
backupfile: Remove non-existent module dependency.

* modules/backupfile (Depends-on): Remove irealloc dependency since the
function is a part of the ialloc module.

6 months agoFix indentation in config.h (regression 2024-09-25).
Bruno Haible [Tue, 29 Oct 2024 15:21:06 +0000 (16:21 +0100)]
Fix indentation in config.h (regression 2024-09-25).

* m4/gnulib-common.m4 (gl_COMMON_BODY): Fix a '#else' indentation.

6 months agoassert-h, stdbool: Allow mixed use of gcc/g++ and clang/clang++ again.
Bruno Haible [Tue, 29 Oct 2024 12:48:36 +0000 (13:48 +0100)]
assert-h, stdbool: Allow mixed use of gcc/g++ and clang/clang++ again.

* m4/assert_h.m4 (gl_ASSERT_H): Improve indentation. With GCC and clang,
don't use the value of HAVE_C_STATIC_ASSERT.
* m4/c-bool.m4 (gl_C_BOOL): With GCC and clang, don't use the value of
HAVE_C_BOOL.

6 months agodoc: Don't mention Java dependency.
Bruno Haible [Tue, 29 Oct 2024 04:02:20 +0000 (05:02 +0100)]
doc: Don't mention Java dependency.

* doc/build-automation.texi (Building gnulib): Remove Java from the
needed tools.

6 months agodoc: Mention Python dependency.
Collin Funk [Tue, 29 Oct 2024 02:59:35 +0000 (19:59 -0700)]
doc: Mention Python dependency.

* doc/build-automation.texi (Building gnulib): Document that Python is
needed for gnulib-tool.

6 months agodoc: Improve usability of generated PDF.
Bruno Haible [Mon, 28 Oct 2024 12:24:34 +0000 (13:24 +0100)]
doc: Improve usability of generated PDF.

* doc/gnulib.texi: Use a brown colour for interactive links.

6 months agorealloc-gnu: Fix typo in deprecation notice.
Collin Funk [Sun, 27 Oct 2024 23:58:59 +0000 (16:58 -0700)]
realloc-gnu: Fix typo in deprecation notice.

* modules/realloc-gnu (Notice): Recommend 'realloc-posix' in the
deprecation notice.

6 months agorealloc-gnu: Replace module with an alias to realloc-posix.
Bruno Haible [Sun, 27 Oct 2024 23:18:35 +0000 (00:18 +0100)]
realloc-gnu: Replace module with an alias to realloc-posix.

* tests/test-realloc-posix.c: Renamed from tests/test-realloc-gnu.c. Add
more tests, not yet activated.
* modules/realloc-posix-tests: Renamed from modules/realloc-gnu-tests.
Test test-realloc-posix instead of test-realloc-gnu.
* modules/realloc-gnu: Mark as a deprecated alias of 'realloc-posix'.
* lib/stdlib.in.h (realloc): Ignore GNULIB_REALLOC_GNU.
* modules/stdlib (Makefile.am): Don't substitute GNULIB_REALLOC_GNU,
REPLACE_REALLOC_FOR_REALLOC_GNU.
* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Don't initialize
GNULIB_REALLOC_GNU.
(gl_STDLIB_H_DEFAULTS): Don't initialize
REPLACE_REALLOC_FOR_REALLOC_GNU.
* m4/realloc.m4 (gl_FUNC_REALLOC_GNU): Remove macro.
* m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): Update comment.
* doc/posix-functions/realloc.texi: Remove description of module
'realloc-gnu'.
* MODULES.html.sh (Memory management functions <stdlib.h>): Remove
realloc-gnu. Add realloc-posix.

6 months agodoc: Add a module index.
Bruno Haible [Sun, 27 Oct 2024 16:01:29 +0000 (17:01 +0100)]
doc: Add a module index.

* doc/Makefile (undocumented-modules.texi): New rule.
(%.info, %.html, %.dvi, %.pdf): Depend on undocumented-modules.texi.
(mostlyclean): Remove also *.m and *.tmp.
(force): New rule.
* doc/*.texi: Add module index entries.
* doc/*/*.texi: Likewise.

6 months agoposix_memalign: port better to OpenBSD 6.2+ cross
Paul Eggert [Sat, 26 Oct 2024 21:34:10 +0000 (14:34 -0700)]
posix_memalign: port better to OpenBSD 6.2+ cross

* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN):
Don’t assume sizeof (void *) <= 32 (!).
The bug is fixed in OpenBSD 6.2+.

6 months agoposix_memalign-tests: fix message typo
Paul Eggert [Sat, 26 Oct 2024 17:07:53 +0000 (10:07 -0700)]
posix_memalign-tests: fix message typo

* tests/test-posix_memalign.c (main): Fix diagnostic typo.

6 months agoaligned_alloc: document glibc bug 32301
Paul Eggert [Sat, 26 Oct 2024 17:06:55 +0000 (10:06 -0700)]
aligned_alloc: document glibc bug 32301

* doc/posix-functions/aligned_alloc.texi:
* doc/posix-functions/posix_memalign.texi: Mention glibc bug
32301, which it is not worth our time to work around.

6 months agoeealloc: update commentary
Paul Eggert [Sat, 26 Oct 2024 00:02:02 +0000 (17:02 -0700)]
eealloc: update commentary

Even if we remove eealloc we might as well add commentary
explaining some of its confusion, before we remove it.
* lib/eealloc.h: Update comment.
* modules/eealloc (Description):
Update, since eealloc is not glibc compatible.

6 months agoregex: Avoid dialog while running configure test on Haiku/x86_64.
Bruno Haible [Sat, 26 Oct 2024 19:10:30 +0000 (21:10 +0200)]
regex: Avoid dialog while running configure test on Haiku/x86_64.

Reported by Alexandru Popa <alpopa@gmail.com> in
<https://sourceforge.net/p/clisp/mailman/message/58831511/>.

* m4/regex.m4 (gl_REGEX): Disable dialog upon abort on Haiku.

6 months agoregex: Make configure test more maintainable.
Bruno Haible [Sat, 26 Oct 2024 18:58:05 +0000 (20:58 +0200)]
regex: Make configure test more maintainable.

* m4/regex.m4 (gl_REGEX): Include <malloc.h> before testing for
M_CHECK_ACTION.

6 months agoexecute, spawn-pipe: Fix compilation error on Cygwin (regr. 2024-10-22).
Bruno Haible [Sat, 26 Oct 2024 18:19:40 +0000 (20:19 +0200)]
execute, spawn-pipe: Fix compilation error on Cygwin (regr. 2024-10-22).

* lib/windows-path.h: Include <stdlib.h>.

6 months agopipe-filter-gi: Correct documentation.
Bruno Haible [Sat, 26 Oct 2024 17:42:10 +0000 (19:42 +0200)]
pipe-filter-gi: Correct documentation.

Reported by Miro Palmu <email@miropalmu.cc> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-10/msg00199.html>.

* lib/pipe-filter.h (pipe_filter_gi_create): Don't say that this
function may return NULL.

6 months agoeealloc: Relicense under LGPLv2+.
Bruno Haible [Fri, 25 Oct 2024 19:59:45 +0000 (21:59 +0200)]
eealloc: Relicense under LGPLv2+.

Jim Meyering's approval is in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-10/msg00192.html>.

* modules/eealloc (License): Change to LGPLv2+.
* lib/eealloc.h: Update license notice.
* lib/eealloc.c: Likewise.

6 months agoxalloc: Adjust dependencies after last change.
Bruno Haible [Fri, 25 Oct 2024 11:59:41 +0000 (13:59 +0200)]
xalloc: Adjust dependencies after last change.

* modules/xalloc (Depends-on): Remove realloc-gnu. Add realloc-posix.

6 months agoialloc: Fix dependencies.
Bruno Haible [Fri, 25 Oct 2024 11:55:08 +0000 (13:55 +0200)]
ialloc: Fix dependencies.

* modules/ialloc (Depends-on): Add realloc-posix.

6 months agorealloc: minor style coalescing
Paul Eggert [Fri, 25 Oct 2024 04:55:46 +0000 (21:55 -0700)]
realloc: minor style coalescing

* lib/alignalloc.h (alignalloc):
* lib/eealloc.h (eerealloc):
* lib/ialloc.h (irealloc, ireallocarray):
* lib/safe-alloc.h (safe_alloc_realloc_n):
Adjust commentary and code to better match what’s used elsewhere.
This doesn’t change behavior.

6 months agoxalloc: port to Cheri, strict C23, realloc null
Paul Eggert [Fri, 25 Oct 2024 04:52:19 +0000 (21:52 -0700)]
xalloc: port to Cheri, strict C23, realloc null

* lib/xmalloc.c [__CHERI_PURE_CAPABILITY__]: Include <cheri.h>.
(xrealloc, xreallocarray): Support Cheri.  Avoid undefined
behavior in strict C23.  Work better on platforms where
realloc (p, 0) returns a null pointer

6 months agoreallocarray: simplify
Paul Eggert [Fri, 25 Oct 2024 04:34:12 +0000 (21:34 -0700)]
reallocarray: simplify

* lib/reallocarray.c (reallocarray): Use simpler workaround
for realloc glitch, which does not involve malloc.
* modules/reallocarray (Depends-on): Remove malloc-posix.

6 months agoialloc: fix realloc-gnu dependency
Paul Eggert [Wed, 23 Oct 2024 21:33:43 +0000 (14:33 -0700)]
ialloc: fix realloc-gnu dependency

* modules/ialloc (Depends-on): Remove realloc-gnu,
as ialloc.c does not depend on GNU semantics for realloc.

6 months agobackupfile: fix irealloc dependency
Paul Eggert [Wed, 23 Oct 2024 21:30:35 +0000 (14:30 -0700)]
backupfile: fix irealloc dependency

* modules/backupfile (Depends-on): Depend on irealloc,
not realloc-gnu, as the code now uses irealloc not realloc
and does not depend on GNU semantics anyway.