]> Savannah Git Hosting - gnulib.git/commitdiff
realloc-gnu: Replace module with an alias to realloc-posix.
authorBruno Haible <bruno@clisp.org>
Sun, 27 Oct 2024 23:18:35 +0000 (00:18 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 27 Oct 2024 23:18:35 +0000 (00:18 +0100)
* 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.

13 files changed:
ChangeLog
MODULES.html.sh
doc/posix-functions/realloc.texi
lib/stdlib.in.h
m4/malloc.m4
m4/realloc.m4
m4/stdlib_h.m4
modules/realloc-gnu
modules/realloc-gnu-tests [deleted file]
modules/realloc-posix-tests [new file with mode: 0644]
modules/stdlib
tests/test-realloc-gnu.c [deleted file]
tests/test-realloc-posix.c [new file with mode: 0644]

index 7fb8300bbd7b578efed27299ac9fd1be3a02fde9..c0d8f3dedd4d168e5a6486ee8475d2364f4fb1c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-10-27  Bruno Haible  <bruno@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  <bruno@clisp.org>
 
        doc: Add a module index.
index 775841bff0b09a63b67e7340daf9330051105110..8e0e6964047d83f500db8ad18a85c8c81c04cf71 100755 (executable)
@@ -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
index 28ad26acef8ca50501283e82b4e67c4b0fee253d..4be63c767a3187a7527291b7e5788aab35216b56 100644 (file)
@@ -99,20 +99,3 @@ even though POSIX.1-2024 requires this:
 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
index 6667f426ad99460240543a92933ac3ee5f42b039..9d82f35b005abf562757b7d1335e4abd8b7a55ad 100644 (file)
@@ -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
index 6f9aeecb6d156278ed9ff80687a50d4d77635ea0..ff10e727ad71d1d6706c29de45933d89d31a9961 100644 (file)
@@ -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 ;;
index f4d78f9622e4250510f7a3751e56447ed9430b81..8fd220e883113a7fd666aedb2e83b5c5eaaca325 100644 (file)
@@ -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
index 68d98427b516d6b70f854c214721b955114bf1eb..87b63ff54e3551f756b7596410263c2aa29cf887 100644 (file)
@@ -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])
index ff0f838b99eede240706f2f14a65edee9beee486..4ad46a94ebece0cbfe38bb1f6f67c28812adaef9 100644 (file)
@@ -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 (file)
index c1dbe17..0000000
+++ /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 (file)
index 0000000..0361cdc
--- /dev/null
@@ -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
index 9646c3b336376d8840e1510a37db120299ec843b..3dffbf56bb52a16c52a17332bf545d61ce107b7f 100644 (file)
@@ -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-gnu.c
deleted file mode 100644 (file)
index f36866c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Test of realloc function.
-   Copyright (C) 2010-2024 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-/* Specification.  */
-#include <stdlib.h>
-
-#include <errno.h>
-#include <stdint.h>
-
-#include "macros.h"
-
-int
-main (int argc, _GL_UNUSED char **argv)
-{
-  /* Check that realloc (NULL, 0) is not a NULL pointer.  */
-  void *volatile p = realloc (NULL, 0);
-  ASSERT (p != NULL);
-
-  /* Check that realloc (p, n) fails when p is non-null and n exceeds
-     PTRDIFF_MAX.  */
-  if (PTRDIFF_MAX < SIZE_MAX)
-    {
-      size_t one = argc != 12345;
-      p = realloc (p, PTRDIFF_MAX + one);
-      ASSERT (p == NULL);
-      /* Avoid a test failure due to glibc bug
-         <https://sourceware.org/bugzilla/show_bug.cgi?id=27870>.  */
-      if (!getenv ("MALLOC_CHECK_"))
-        ASSERT (errno == ENOMEM);
-    }
-
-  free (p);
-  return test_exit_status;
-}
diff --git a/tests/test-realloc-posix.c b/tests/test-realloc-posix.c
new file mode 100644 (file)
index 0000000..79d430b
--- /dev/null
@@ -0,0 +1,65 @@
+/* Test of realloc function.
+   Copyright (C) 2010-2024 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <stdlib.h>
+
+#include <errno.h>
+#include <stdint.h>
+
+#include "macros.h"
+
+int
+main (int argc, _GL_UNUSED char **argv)
+{
+  void *volatile p;
+
+  /* Check that realloc (NULL, 0) is not a NULL pointer.  */
+  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.  */
+  if (PTRDIFF_MAX < SIZE_MAX)
+    {
+      size_t one = argc != 12345;
+      p = realloc (p, PTRDIFF_MAX + one);
+      ASSERT (p == NULL);
+      /* Avoid a test failure due to glibc bug
+         <https://sourceware.org/bugzilla/show_bug.cgi?id=27870>.  */
+      if (!getenv ("MALLOC_CHECK_"))
+        ASSERT (errno == ENOMEM);
+    }
+
+  free (p);
+  return test_exit_status;
+}