realloc-gnu: Allow use as dependency from test modules.
authorBruno Haible <bruno@clisp.org>
Mon, 3 Jan 2022 14:31:53 +0000 (15:31 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 3 Jan 2022 14:31:53 +0000 (15:31 +0100)
* m4/realloc.m4 (gl_FUNC_REALLOC_GNU): Set
REPLACE_REALLOC_FOR_REALLOC_GNU instead of REPLACE_REALLOC.
(gl_FUNC_REALLOC_POSIX): Set REPLACE_REALLOC_FOR_REALLOC_POSIX instead
of REPLACE_REALLOC.
* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
realloc-gnu module indicator.
(gl_STDLIB_H_DEFAULTS): Initialize REPLACE_REALLOC_FOR_REALLOC_GNU,
REPLACE_REALLOC_FOR_REALLOC_POSIX, not REPLACE_REALLOC.
* modules/stdlib (Makefile.am): Substitute GNULIB_REALLOC_GNU,
REPLACE_REALLOC_FOR_REALLOC_GNU, REPLACE_REALLOC_FOR_REALLOC_POSIX, not
REPLACE_REALLOC.
* modules/realloc-posix (Depends-on, configure.ac): Test
REPLACE_REALLOC_FOR_REALLOC_POSIX instead of REPLACE_REALLOC.
* modules/realloc-gnu (Comment): Remove section.
(Depends-on): Add free-posix, malloc-gnu, xalloc-oversized.
(configure.ac): Test REPLACE_REALLOC_FOR_REALLOC_GNU instead of
REPLACE_REALLOC. Set a module indicator.
* lib/stdlib.in.h (realloc): Test REPLACE_REALLOC_FOR_REALLOC_POSIX,
REPLACE_REALLOC_FOR_REALLOC_GNU, and the respective module indicators
instead of just REPLACE_REALLOC.

ChangeLog
lib/stdlib.in.h
m4/realloc.m4
m4/stdlib_h.m4
modules/realloc-gnu
modules/realloc-posix
modules/stdlib

index ee1ede3d6963b7282e0fdafff5d8dd7ed1c2fb72..655529e83395d312adab492d3f2cd3ecbc1fdc47 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2022-01-03  Bruno Haible  <bruno@clisp.org>
+
+       realloc-gnu: Allow use as dependency from test modules.
+       * m4/realloc.m4 (gl_FUNC_REALLOC_GNU): Set
+       REPLACE_REALLOC_FOR_REALLOC_GNU instead of REPLACE_REALLOC.
+       (gl_FUNC_REALLOC_POSIX): Set REPLACE_REALLOC_FOR_REALLOC_POSIX instead
+       of REPLACE_REALLOC.
+       * m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
+       realloc-gnu module indicator.
+       (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_REALLOC_FOR_REALLOC_GNU,
+       REPLACE_REALLOC_FOR_REALLOC_POSIX, not REPLACE_REALLOC.
+       * modules/stdlib (Makefile.am): Substitute GNULIB_REALLOC_GNU,
+       REPLACE_REALLOC_FOR_REALLOC_GNU, REPLACE_REALLOC_FOR_REALLOC_POSIX, not
+       REPLACE_REALLOC.
+       * modules/realloc-posix (Depends-on, configure.ac): Test
+       REPLACE_REALLOC_FOR_REALLOC_POSIX instead of REPLACE_REALLOC.
+       * modules/realloc-gnu (Comment): Remove section.
+       (Depends-on): Add free-posix, malloc-gnu, xalloc-oversized.
+       (configure.ac): Test REPLACE_REALLOC_FOR_REALLOC_GNU instead of
+       REPLACE_REALLOC. Set a module indicator.
+       * lib/stdlib.in.h (realloc): Test REPLACE_REALLOC_FOR_REALLOC_POSIX,
+       REPLACE_REALLOC_FOR_REALLOC_GNU, and the respective module indicators
+       instead of just REPLACE_REALLOC.
+
 2022-01-03  Bruno Haible  <bruno@clisp.org>
 
        calloc-gnu: Allow use as dependency from test modules.
index 64231c2d5f4978a4a851753c77fa4ad8f3f4f864..d52c2f796382fdcc49962db6357471d7fc91fd0b 100644 (file)
@@ -1109,7 +1109,8 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
 
 
 #if @GNULIB_REALLOC_POSIX@
-# if @REPLACE_REALLOC@
+# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
+     || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
 #  if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
         || _GL_USE_STDLIB_ALLOC)
 #   undef realloc
index eb981328baeb743ab305306c5f9a5c102c66d4c4..86e57c259f39de7c6ccae1e76d4eeb47de388540 100644 (file)
@@ -1,4 +1,4 @@
-# realloc.m4 serial 25
+# realloc.m4 serial 26
 dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -43,8 +43,8 @@ AC_DEFUN([gl_FUNC_REALLOC_GNU],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
-  if test $REPLACE_REALLOC = 0; then
-    _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC=1])
+  if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
+    _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
   fi
 ])# gl_FUNC_REALLOC_GNU
 
@@ -58,6 +58,6 @@ AC_DEFUN([gl_FUNC_REALLOC_POSIX],
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
   if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
-    REPLACE_REALLOC=1
+    REPLACE_REALLOC_FOR_REALLOC_POSIX=1
   fi
 ])
index 4e1d99668f0556196f5d421674760d71966f63a2..9e2096976f3108e72ae54a6cb0f1dbfcd63c3379 100644 (file)
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 65
+# stdlib_h.m4 serial 66
 dnl Copyright (C) 2007-2022 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -92,6 +92,7 @@ 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])
@@ -182,7 +183,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_QSORT_R=0;         AC_SUBST([REPLACE_QSORT_R])
   REPLACE_RANDOM=0;          AC_SUBST([REPLACE_RANDOM])
   REPLACE_RANDOM_R=0;        AC_SUBST([REPLACE_RANDOM_R])
-  REPLACE_REALLOC=0;         AC_SUBST([REPLACE_REALLOC])
+  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])
   REPLACE_SETENV=0;          AC_SUBST([REPLACE_SETENV])
index 7752d8c6a4dfe5e40364aedb7580d1f9ea1158b8..b06a237dd351945c8a5a0306a0eefe1f15ef554d 100644 (file)
@@ -1,22 +1,21 @@
 Description:
 realloc() function that is glibc compatible.
 
-Comment:
-This module should not be used as a dependency from a test module,
-otherwise when this module occurs as a tests-related module, it will
-have side effects on the compilation of the main modules in lib/.
-
 Files:
 lib/realloc.c
 
 Depends-on:
 realloc-posix
+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 = 1; then
+if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
   AC_LIBOBJ([realloc])
 fi
+gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
 
 Makefile.am:
 
index a30356f31adf31e6f9a946b0034db7dc1a5f31e4..c87d7edd476a56846a23e94c348a51d9b0c67c74 100644 (file)
@@ -8,13 +8,13 @@ m4/malloc.m4
 
 Depends-on:
 stdlib
-free-posix           [test $REPLACE_REALLOC = 1]
-malloc-posix         [test $REPLACE_REALLOC = 1]
-xalloc-oversized     [test $REPLACE_REALLOC = 1]
+free-posix           [test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1]
+malloc-posix         [test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1]
+xalloc-oversized     [test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1]
 
 configure.ac:
 gl_FUNC_REALLOC_POSIX
-if test $REPLACE_REALLOC = 1; then
+if test $REPLACE_REALLOC_FOR_REALLOC_POSIX = 1; then
   AC_LIBOBJ([realloc])
 fi
 gl_STDLIB_MODULE_INDICATOR([realloc-posix])
index 63e600d13231cf6ebf5a3d95d51f503f2c9fceb7..45d8f5933160133e14260b8f09206d4264ea6be3 100644 (file)
@@ -60,6 +60,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
              -e 's/@''GNULIB_QSORT_R''@/$(GNULIB_QSORT_R)/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' \
@@ -142,7 +143,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
              -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
              -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
              -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
-             -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|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' \
              -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \