Paul Eggert wrote:
> > If we let realloc-gnu and realloc-0safe exist both in Gnulib, we need to add
> > a conflict-detection mechanism in gnulib-tool.
> 
> Ah, in that case you're right, let's just remove realloc-gnu.

I notified the inetutils and liblouis people:
https://lists.gnu.org/archive/html/bug-inetutils/2024-10/msg00005.html
https://github.com/liblouis/liblouis/issues/1649

Both packages can just use 'realloc-posix' instead.

Therefore we can remove or alias 'realloc-gnu'. In order to avoid possible
complaints, I'm making it a module alias for 'realloc-posix'.

The new tests that I'm adding with '#ifdef NOT_YET' can be enabled when
your transversal module is ready.


2024-10-27  Bruno Haible  <br...@clisp.org>

        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.

>From 6659e016165ccc95e2dedd8f3805d33efa783e41 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 28 Oct 2024 00:18:35 +0100
Subject: [PATCH] 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.
---
 ChangeLog                                     | 22 +++++++++++++++++++
 MODULES.html.sh                               |  2 +-
 doc/posix-functions/realloc.texi              | 17 --------------
 lib/stdlib.in.h                               |  3 +--
 m4/malloc.m4                                  |  4 ++--
 m4/realloc.m4                                 | 21 +-----------------
 m4/stdlib_h.m4                                |  4 +---
 modules/realloc-gnu                           | 18 ++++++---------
 modules/realloc-gnu-tests                     | 12 ----------
 modules/realloc-posix-tests                   | 12 ++++++++++
 modules/stdlib                                |  2 --
 ...est-realloc-gnu.c => test-realloc-posix.c} | 18 ++++++++++++++-
 12 files changed, 64 insertions(+), 71 deletions(-)
 delete mode 100644 modules/realloc-gnu-tests
 create mode 100644 modules/realloc-posix-tests
 rename tests/{test-realloc-gnu.c => test-realloc-posix.c} (79%)

diff --git a/ChangeLog b/ChangeLog
index 7fb8300bbd..c0d8f3dedd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-10-27  Bruno Haible  <br...@clisp.org>
+
+	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.
+
 2024-10-27  Bruno Haible  <br...@clisp.org>
 
 	doc: Add a module index.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index 775841bff0..8e0e696404 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -1738,7 +1738,7 @@ func_all_modules ()
   func_module free-posix
   func_module malloc-gnu
   func_module memalign
-  func_module realloc-gnu
+  func_module realloc-posix
   func_module reallocarray
   func_module pagealign_alloc
   func_end_table
diff --git a/doc/posix-functions/realloc.texi b/doc/posix-functions/realloc.texi
index 28ad26acef..4be63c767a 100644
--- a/doc/posix-functions/realloc.texi
+++ b/doc/posix-functions/realloc.texi
@@ -99,20 +99,3 @@
 glibc 2.1.1--2.40, most likely glibc 2.41+ at least by default,
 Android, mingw, MSVC.
 @end itemize
-
-@mindex realloc-gnu
-Extension: Gnulib provides a module @samp{realloc-gnu} that substitutes a
-@code{realloc} implementation that behaves more like the current
-glibc implementation.
-It fixes these portability problems:
-
-@itemize
-@item
-@code{realloc (NULL, 0)} returns @code{NULL} on success on some platforms:
-AIX 7.3.
-
-@item
-On some platforms, @code{realloc (p, 0)} with non-null @code{p}
-might not free @code{p}, or might clobber @code{errno},
-or might not return @code{NULL}.
-@end itemize
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 6667f426ad..9d82f35b00 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1454,8 +1454,7 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
 
 
 #if @GNULIB_REALLOC_POSIX@
-# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
-     || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
+# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@)
 #  if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
         || _GL_USE_STDLIB_ALLOC)
 #   undef realloc
diff --git a/m4/malloc.m4 b/m4/malloc.m4
index 6f9aeecb6d..ff10e727ad 100644
--- a/m4/malloc.m4
+++ b/m4/malloc.m4
@@ -1,5 +1,5 @@
 # malloc.m4
-# serial 34
+# serial 35
 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -134,7 +134,7 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX]
       dnl some systems go to their knees when you do that. So assume that
       dnl all Unix implementations of the function set errno on failure,
       dnl except on those platforms where we have seen 'test-malloc-gnu',
-      dnl 'test-realloc-gnu', 'test-calloc-gnu' fail.
+      dnl 'test-realloc-posix', 'test-calloc-gnu' fail.
       case "$host_os" in
         mingw* | windows*)
           gl_cv_func_malloc_posix=no ;;
diff --git a/m4/realloc.m4 b/m4/realloc.m4
index f4d78f9622..8fd220e883 100644
--- a/m4/realloc.m4
+++ b/m4/realloc.m4
@@ -1,5 +1,5 @@
 # realloc.m4
-# serial 33
+# serial 34
 dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -51,25 +51,6 @@ AC_DEFUN([_AC_FUNC_REALLOC_IF]
   AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
 ])# AC_FUNC_REALLOC
 
-# gl_FUNC_REALLOC_GNU
-# -------------------
-# Replace realloc if it is not compatible with GNU libc.
-AC_DEFUN([gl_FUNC_REALLOC_GNU],
-[
-  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
-  AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
-
-  dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT
-  dnl gets defined already before this macro gets invoked.  This helps
-  dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
-
-  AC_REQUIRE([gl_FUNC_REALLOC_SANITIZED])
-  if test "$gl_cv_func_realloc_sanitize" = no \
-     && test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
-    _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
-  fi
-])# gl_FUNC_REALLOC_GNU
-
 # gl_FUNC_REALLOC_POSIX
 # ---------------------
 # Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 68d98427b5..87b63ff54e 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,5 +1,5 @@
 # stdlib_h.m4
-# serial 81
+# serial 82
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -141,7 +141,6 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS]
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
-    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
@@ -248,7 +247,6 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS]
   REPLACE_RAND=0;            AC_SUBST([REPLACE_RAND])
   REPLACE_RANDOM=0;          AC_SUBST([REPLACE_RANDOM])
   REPLACE_RANDOM_R=0;        AC_SUBST([REPLACE_RANDOM_R])
-  REPLACE_REALLOC_FOR_REALLOC_GNU=0;    AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
   REPLACE_REALLOC_FOR_REALLOC_POSIX=0;  AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
   REPLACE_REALLOCARRAY=0;    AC_SUBST([REPLACE_REALLOCARRAY])
   REPLACE_REALPATH=0;        AC_SUBST([REPLACE_REALPATH])
diff --git a/modules/realloc-gnu b/modules/realloc-gnu
index ff0f838b99..4ad46a94eb 100644
--- a/modules/realloc-gnu
+++ b/modules/realloc-gnu
@@ -1,22 +1,18 @@
 Description:
 realloc() function that is glibc compatible.
 
+Status:
+deprecated
+
+Notice:
+This module is deprecated. Use the module 'filename' instead.
+
 Files:
-lib/realloc.c
 
 Depends-on:
 realloc-posix
-extensions-aix
-free-posix           [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1]
-malloc-gnu           [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1]
-xalloc-oversized     [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1]
 
 configure.ac:
-gl_FUNC_REALLOC_GNU
-if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
-  AC_LIBOBJ([realloc])
-fi
-gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
 
 Makefile.am:
 
@@ -27,4 +23,4 @@ License:
 LGPLv2+
 
 Maintainer:
-Jim Meyering
+all
diff --git a/modules/realloc-gnu-tests b/modules/realloc-gnu-tests
deleted file mode 100644
index c1dbe17b18..0000000000
--- a/modules/realloc-gnu-tests
+++ /dev/null
@@ -1,12 +0,0 @@
-Files:
-tests/test-realloc-gnu.c
-tests/macros.h
-
-Depends-on:
-stdint
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-realloc-gnu
-check_PROGRAMS += test-realloc-gnu
diff --git a/modules/realloc-posix-tests b/modules/realloc-posix-tests
new file mode 100644
index 0000000000..0361cdcd46
--- /dev/null
+++ b/modules/realloc-posix-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-realloc-posix.c
+tests/macros.h
+
+Depends-on:
+stdint
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-realloc-posix
+check_PROGRAMS += test-realloc-posix
diff --git a/modules/stdlib b/modules/stdlib
index 9646c3b336..3dffbf56bb 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -66,7 +66,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's/@''GNULIB_RAND''@/$(GNULIB_RAND)/g' \
 	      -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
 	      -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
-	      -e 's/@''GNULIB_REALLOC_GNU''@/$(GNULIB_REALLOC_GNU)/g' \
 	      -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
 	      -e 's/@''GNULIB_REALLOCARRAY''@/$(GNULIB_REALLOCARRAY)/g' \
 	      -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
@@ -168,7 +167,6 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \
 	      -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
 	      -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-	      -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
 	      -e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
 	      -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
diff --git a/tests/test-realloc-gnu.c b/tests/test-realloc-posix.c
similarity index 79%
rename from tests/test-realloc-gnu.c
rename to tests/test-realloc-posix.c
index f36866ce0d..79d430b95a 100644
--- a/tests/test-realloc-gnu.c
+++ b/tests/test-realloc-posix.c
@@ -27,9 +27,25 @@
 int
 main (int argc, _GL_UNUSED char **argv)
 {
+  void *volatile p;
+
   /* Check that realloc (NULL, 0) is not a NULL pointer.  */
-  void *volatile p = realloc (NULL, 0);
+  p = realloc (NULL, 0);
+  ASSERT (p != NULL);
+#ifdef NOT_YET
+  free (p);
+
+  /* Check that realloc (p, 0) for non-NULL p is not a NULL pointer.  */
+  p = malloc (200);
+  p = realloc (p, 0);
+  ASSERT (p != NULL);
+  free (p);
+
+  /* Check that realloc (p, 0) for non-NULL p is not a NULL pointer.  */
+  p = malloc (2 * 1024 * 1024);
+  p = realloc (p, 0);
   ASSERT (p != NULL);
+#endif
 
   /* Check that realloc (p, n) fails when p is non-null and n exceeds
      PTRDIFF_MAX.  */
-- 
2.34.1

Reply via email to