While testing a current libunistring snapshot on AIX 7 in 64-bit mode, I get
a link error while creating the shared library:

  ld: 0711-317 ERROR: Undefined symbol: .rpl_malloc

What happens here is that
  - Among the main modules (those built in lib/), we have 'malloc-posix'
    as a dependency but not 'malloc-gnu'.
  - Among the tests modules, we have 'malloc-gnu' as a dependency.
  - Because of the latter, REPLACE_MALLOC gets set to 1, and this gets
    substituted into lib/stdlib.h, providing an '#define malloc rpl_malloc'
    indirection for *both* lib/ and tests/.

We knew that having 'malloc-gnu' as a dependency of tests modules would
be a problem, as witnessed by this

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

Unfortunately, we now have (since 2021-04-18) this dependency chain:

  Many tests --> xalloc --> malloc-gnu
                        --> calloc-gnu
                        --> realloc-gnu
                        --> reallocarray --> realloc-gnu
                        --> ialloc --> malloc-gnu
                                   --> calloc-gnu
                                   --> realloc-gnu
                                   --> reallocarray --> realloc-gnu

It would be a large effort (and a step backwards) to cut down all these
dependencies. Therefore here are patches that actually make it possible
to use 'malloc-gnu' as a dependency of tests modules, and likewise for
the others.

I'm leaving the fnmatch-gnu, getopt-gnu, and math (*-ieee) modules as
they are, because they already use a different but working mechanism,
based on m4_divert_text.


2022-01-03  Bruno Haible  <br...@clisp.org>

        getpass-gnu: Allow use as dependency from test modules.
        * m4/getpass.m4 (gl_FUNC_GETPASS_GNU): Set
        REPLACE_GETPASS_FOR_GETPASS_GNU instead of REPLACE_GETPASS.
        * m4/unistd_h.m4 (gl_UNISTD_H_REQUIRE_DEFAULTS): Initialize the
        getpass-gnu module indicator.
        (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETPASS_FOR_GETPASS_GNU.
        * modules/unistd (Makefile.am): Substitute GNULIB_GETPASS_GNU,
        REPLACE_GETPASS_FOR_GETPASS_GNU.
        * modules/getpass-gnu (configure.ac): Test
        REPLACE_GETPASS_FOR_GETPASS_GNU instead of REPLACE_GETPASS. Set a module
        indicator.
        * lib/unistd.in.h (getpass): Test REPLACE_GETPASS,
        REPLACE_GETPASS_FOR_GETPASS_GNU, and the respective module indicators
        instead of just REPLACE_GETPASS.

2022-01-03  Bruno Haible  <br...@clisp.org>

        fopen-gnu: Allow use as dependency from test modules.
        * m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Set REPLACE_FOPEN_FOR_FOPEN_GNU
        instead of REPLACE_FOPEN.
        * m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize the fopen-gnu
        module indicator.
        (gl_STDIO_H_DEFAULTS): Initialize REPLACE_FOPEN_FOR_FOPEN_GNU.
        * modules/stdio (Makefile.am): Substitute GNULIB_FOPEN_GNU,
        REPLACE_FOPEN_FOR_FOPEN_GNU.
        * modules/fopen-gnu (Depends-on): Add more dependencies.
        (configure.ac): Test REPLACE_FOPEN_FOR_FOPEN_GNU instead of
        REPLACE_FOPEN.
        * lib/stdio.in.h (fopen): Test REPLACE_FOPEN,
        REPLACE_FOPEN_FOR_FOPEN_GNU, and the respective module indicators
        instead of just REPLACE_FOPEN.

2022-01-03  Bruno Haible  <br...@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  <br...@clisp.org>

        calloc-gnu: Allow use as dependency from test modules.
        * m4/calloc.m4 (gl_FUNC_CALLOC_GNU): Set REPLACE_CALLOC_FOR_CALLOC_GNU
        instead of REPLACE_CALLOC.
        (gl_FUNC_CALLOC_POSIX): Set REPLACE_CALLOC_FOR_CALLOC_POSIX instead of
        REPLACE_CALLOC.
        * m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
        calloc-gnu module indicator.
        (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_CALLOC_FOR_CALLOC_GNU,
        REPLACE_CALLOC_FOR_CALLOC_POSIX, not REPLACE_CALLOC.
        * modules/stdlib (Makefile.am): Substitute GNULIB_CALLOC_GNU,
        REPLACE_CALLOC_FOR_CALLOC_GNU, REPLACE_CALLOC_FOR_CALLOC_POSIX, not
        REPLACE_CALLOC.
        * modules/calloc-posix (Depends-on, configure.ac): Test
        REPLACE_CALLOC_FOR_CALLOC_POSIX instead of REPLACE_CALLOC.
        * modules/calloc-gnu (Depends-on): Add xalloc-oversized.
        (configure.ac): Test REPLACE_CALLOC_FOR_CALLOC_GNU instead of
        REPLACE_CALLOC. Set a module indicator.
        * lib/stdlib.in.h (calloc): Test REPLACE_CALLOC_FOR_CALLOC_POSIX,
        REPLACE_CALLOC_FOR_CALLOC_GNU, and the respective module indicators
        instead of just REPLACE_CALLOC.

2022-01-03  Bruno Haible  <br...@clisp.org>

        malloc-gnu: Allow use as dependency from test modules.
        * m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Set REPLACE_MALLOC_FOR_MALLOC_GNU
        instead of REPLACE_MALLOC.
        (gl_FUNC_MALLOC_PTRDIFF, gl_FUNC_MALLOC_POSIX): Set
        REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
        * m4/calloc.m4 (gl_FUNC_CALLOC_POSIX): Test
        REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
        * m4/realloc.m4 (gl_FUNC_REALLOC_POSIX): Likewise.
        * m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
        malloc-gnu module indicator.
        (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_MALLOC_FOR_MALLOC_GNU,
        REPLACE_MALLOC_FOR_MALLOC_POSIX, not REPLACE_MALLOC.
        * modules/stdlib (Makefile.am): Substitute GNULIB_MALLOC_GNU,
        REPLACE_MALLOC_FOR_MALLOC_GNU, REPLACE_MALLOC_FOR_MALLOC_POSIX, not
        REPLACE_MALLOC.
        * modules/malloc-posix (Depends-on, configure.ac): Test
        REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
        * modules/malloc-gnu (Comment): Remove section.
        (Depends-on): Add xalloc-oversized.
        (configure.ac): Test REPLACE_MALLOC_FOR_MALLOC_GNU instead of
        REPLACE_MALLOC. Set a module indicator.
        * lib/stdlib.in.h (malloc): Test REPLACE_MALLOC_FOR_MALLOC_POSIX,
        REPLACE_MALLOC_FOR_MALLOC_GNU, and the respective module indicators
        instead of just REPLACE_MALLOC.

>From 5427cd71962b646bbb084233c5847b02b94b8f06 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 3 Jan 2022 14:49:04 +0100
Subject: [PATCH 1/5] malloc-gnu: Allow use as dependency from test modules.

* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Set REPLACE_MALLOC_FOR_MALLOC_GNU
instead of REPLACE_MALLOC.
(gl_FUNC_MALLOC_PTRDIFF, gl_FUNC_MALLOC_POSIX): Set
REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
* m4/calloc.m4 (gl_FUNC_CALLOC_POSIX): Test
REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
* m4/realloc.m4 (gl_FUNC_REALLOC_POSIX): Likewise.
* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
malloc-gnu module indicator.
(gl_STDLIB_H_DEFAULTS): Initialize REPLACE_MALLOC_FOR_MALLOC_GNU,
REPLACE_MALLOC_FOR_MALLOC_POSIX, not REPLACE_MALLOC.
* modules/stdlib (Makefile.am): Substitute GNULIB_MALLOC_GNU,
REPLACE_MALLOC_FOR_MALLOC_GNU, REPLACE_MALLOC_FOR_MALLOC_POSIX, not
REPLACE_MALLOC.
* modules/malloc-posix (Depends-on, configure.ac): Test
REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
* modules/malloc-gnu (Comment): Remove section.
(Depends-on): Add xalloc-oversized.
(configure.ac): Test REPLACE_MALLOC_FOR_MALLOC_GNU instead of
REPLACE_MALLOC. Set a module indicator.
* lib/stdlib.in.h (malloc): Test REPLACE_MALLOC_FOR_MALLOC_POSIX,
REPLACE_MALLOC_FOR_MALLOC_GNU, and the respective module indicators
instead of just REPLACE_MALLOC.
---
 ChangeLog            | 27 +++++++++++++++++++++++++++
 lib/stdlib.in.h      |  3 ++-
 m4/calloc.m4         |  4 ++--
 m4/malloc.m4         | 11 ++++++-----
 m4/realloc.m4        |  4 ++--
 m4/stdlib_h.m4       |  6 ++++--
 modules/malloc-gnu   |  9 +++------
 modules/malloc-posix |  4 ++--
 modules/stdlib       |  4 +++-
 9 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2cb4da4cd..90c019dd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2022-01-03  Bruno Haible  <br...@clisp.org>
+
+	malloc-gnu: Allow use as dependency from test modules.
+	* m4/malloc.m4 (gl_FUNC_MALLOC_GNU): Set REPLACE_MALLOC_FOR_MALLOC_GNU
+	instead of REPLACE_MALLOC.
+	(gl_FUNC_MALLOC_PTRDIFF, gl_FUNC_MALLOC_POSIX): Set
+	REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
+	* m4/calloc.m4 (gl_FUNC_CALLOC_POSIX): Test
+	REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
+	* m4/realloc.m4 (gl_FUNC_REALLOC_POSIX): Likewise.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
+	malloc-gnu module indicator.
+	(gl_STDLIB_H_DEFAULTS): Initialize REPLACE_MALLOC_FOR_MALLOC_GNU,
+	REPLACE_MALLOC_FOR_MALLOC_POSIX, not REPLACE_MALLOC.
+	* modules/stdlib (Makefile.am): Substitute GNULIB_MALLOC_GNU,
+	REPLACE_MALLOC_FOR_MALLOC_GNU, REPLACE_MALLOC_FOR_MALLOC_POSIX, not
+	REPLACE_MALLOC.
+	* modules/malloc-posix (Depends-on, configure.ac): Test
+	REPLACE_MALLOC_FOR_MALLOC_POSIX instead of REPLACE_MALLOC.
+	* modules/malloc-gnu (Comment): Remove section.
+	(Depends-on): Add xalloc-oversized.
+	(configure.ac): Test REPLACE_MALLOC_FOR_MALLOC_GNU instead of
+	REPLACE_MALLOC. Set a module indicator.
+	* lib/stdlib.in.h (malloc): Test REPLACE_MALLOC_FOR_MALLOC_POSIX,
+	REPLACE_MALLOC_FOR_MALLOC_GNU, and the respective module indicators
+	instead of just REPLACE_MALLOC.
+
 2022-01-02  Bruno Haible  <br...@clisp.org>
 
 	striconveh: Make the last change also work on Solaris 11.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index c14f31b7e..5664fd216 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -474,7 +474,8 @@ _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
    by never specifying a zero size), so it does not need malloc or
    realloc to be redefined.  */
 #if @GNULIB_MALLOC_POSIX@
-# if @REPLACE_MALLOC@
+# if (@GNULIB_MALLOC_POSIX@ && @REPLACE_MALLOC_FOR_MALLOC_POSIX@) \
+     || (@GNULIB_MALLOC_GNU@ && @REPLACE_MALLOC_FOR_MALLOC_GNU@)
 #  if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
         || _GL_USE_STDLIB_ALLOC)
 #   undef malloc
diff --git a/m4/calloc.m4 b/m4/calloc.m4
index 9cba28f2a..3cc21c524 100644
--- a/m4/calloc.m4
+++ b/m4/calloc.m4
@@ -1,4 +1,4 @@
-# calloc.m4 serial 27
+# calloc.m4 serial 28
 
 # Copyright (C) 2004-2022 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -72,7 +72,7 @@ AC_DEFUN([gl_FUNC_CALLOC_POSIX],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
-  if test $REPLACE_MALLOC = 1; then
+  if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
     REPLACE_CALLOC=1
   fi
   dnl Although in theory we should also test for size_t overflow,
diff --git a/m4/malloc.m4 b/m4/malloc.m4
index 2a6d3e1e1..6b76c1e64 100644
--- a/m4/malloc.m4
+++ b/m4/malloc.m4
@@ -1,4 +1,4 @@
-# malloc.m4 serial 27
+# malloc.m4 serial 28
 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,9 @@ AC_DEFUN([gl_FUNC_MALLOC_GNU],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
-  if test $REPLACE_MALLOC = 0; then
-    _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC=1])
+  REPLACE_MALLOC_FOR_MALLOC_GNU="$REPLACE_MALLOC_FOR_MALLOC_POSIX"
+  if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 0; then
+    _AC_FUNC_MALLOC_IF([], [REPLACE_MALLOC_FOR_MALLOC_GNU=1])
   fi
 ])
 
@@ -56,7 +57,7 @@ AC_DEFUN([gl_FUNC_MALLOC_PTRDIFF],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_CHECK_MALLOC_PTRDIFF])
-  test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC=1
+  test "$gl_cv_malloc_ptrdiff" = yes || REPLACE_MALLOC_FOR_MALLOC_POSIX=1
 ])
 
 # Test whether malloc, realloc, calloc refuse to create objects
@@ -109,7 +110,7 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
     AC_DEFINE([HAVE_MALLOC_POSIX], [1],
       [Define if malloc, realloc, and calloc set errno on allocation failure.])
   else
-    REPLACE_MALLOC=1
+    REPLACE_MALLOC_FOR_MALLOC_POSIX=1
   fi
 ])
 
diff --git a/m4/realloc.m4 b/m4/realloc.m4
index 62c72f88f..eb981328b 100644
--- a/m4/realloc.m4
+++ b/m4/realloc.m4
@@ -1,4 +1,4 @@
-# realloc.m4 serial 24
+# realloc.m4 serial 25
 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,
@@ -57,7 +57,7 @@ AC_DEFUN([gl_FUNC_REALLOC_POSIX],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
-  if test $REPLACE_MALLOC = 1; then
+  if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
     REPLACE_REALLOC=1
   fi
 ])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 66fe0975b..69ab51aa3 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 63
+# stdlib_h.m4 serial 64
 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,
@@ -74,6 +74,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_POSIX])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MBTOWC])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKDTEMP])
@@ -168,7 +169,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_FREE=0;            AC_SUBST([REPLACE_FREE])
   REPLACE_INITSTATE=0;       AC_SUBST([REPLACE_INITSTATE])
-  REPLACE_MALLOC=0;          AC_SUBST([REPLACE_MALLOC])
+  REPLACE_MALLOC_FOR_MALLOC_GNU=0;    AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
+  REPLACE_MALLOC_FOR_MALLOC_POSIX=0;  AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
   REPLACE_MBTOWC=0;          AC_SUBST([REPLACE_MBTOWC])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
   REPLACE_POSIX_MEMALIGN=0;  AC_SUBST([REPLACE_POSIX_MEMALIGN])
diff --git a/modules/malloc-gnu b/modules/malloc-gnu
index f8bcdae55..b0fa1739e 100644
--- a/modules/malloc-gnu
+++ b/modules/malloc-gnu
@@ -1,22 +1,19 @@
 Description:
 malloc() 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/malloc.c
 
 Depends-on:
 malloc-posix
+xalloc-oversized     [test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1]
 
 configure.ac:
 gl_FUNC_MALLOC_GNU
-if test $REPLACE_MALLOC = 1; then
+if test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1; then
   AC_LIBOBJ([malloc])
 fi
+gl_STDLIB_MODULE_INDICATOR([malloc-gnu])
 
 Makefile.am:
 
diff --git a/modules/malloc-posix b/modules/malloc-posix
index bafcf3801..86687aa8a 100644
--- a/modules/malloc-posix
+++ b/modules/malloc-posix
@@ -7,11 +7,11 @@ m4/malloc.m4
 
 Depends-on:
 stdlib
-xalloc-oversized     [test $REPLACE_MALLOC = 1]
+xalloc-oversized     [test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1]
 
 configure.ac:
 AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
-if test $REPLACE_MALLOC = 1; then
+if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
   AC_LIBOBJ([malloc])
 fi
 gl_STDLIB_MODULE_INDICATOR([malloc-posix])
diff --git a/modules/stdlib b/modules/stdlib
index a5a3c9f75..ed7912b9f 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -43,6 +43,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \
 	      -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \
 	      -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \
+	      -e 's/@''GNULIB_MALLOC_GNU''@/$(GNULIB_MALLOC_GNU)/g' \
 	      -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \
 	      -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \
 	      -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \
@@ -128,7 +129,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
 	      -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
-	      -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
+	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
+	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
 	      -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
-- 
2.25.1

>From 316ba778dc74385399d7bc10ec0fa1dfb8374e49 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 3 Jan 2022 15:17:02 +0100
Subject: [PATCH 2/5] calloc-gnu: Allow use as dependency from test modules.

* m4/calloc.m4 (gl_FUNC_CALLOC_GNU): Set REPLACE_CALLOC_FOR_CALLOC_GNU
instead of REPLACE_CALLOC.
(gl_FUNC_CALLOC_POSIX): Set REPLACE_CALLOC_FOR_CALLOC_POSIX instead of
REPLACE_CALLOC.
* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
calloc-gnu module indicator.
(gl_STDLIB_H_DEFAULTS): Initialize REPLACE_CALLOC_FOR_CALLOC_GNU,
REPLACE_CALLOC_FOR_CALLOC_POSIX, not REPLACE_CALLOC.
* modules/stdlib (Makefile.am): Substitute GNULIB_CALLOC_GNU,
REPLACE_CALLOC_FOR_CALLOC_GNU, REPLACE_CALLOC_FOR_CALLOC_POSIX, not
REPLACE_CALLOC.
* modules/calloc-posix (Depends-on, configure.ac): Test
REPLACE_CALLOC_FOR_CALLOC_POSIX instead of REPLACE_CALLOC.
* modules/calloc-gnu (Depends-on): Add xalloc-oversized.
(configure.ac): Test REPLACE_CALLOC_FOR_CALLOC_GNU instead of
REPLACE_CALLOC. Set a module indicator.
* lib/stdlib.in.h (calloc): Test REPLACE_CALLOC_FOR_CALLOC_POSIX,
REPLACE_CALLOC_FOR_CALLOC_GNU, and the respective module indicators
instead of just REPLACE_CALLOC.
---
 ChangeLog            | 23 +++++++++++++++++++++++
 lib/stdlib.in.h      |  3 ++-
 m4/calloc.m4         |  9 +++++----
 m4/stdlib_h.m4       |  6 ++++--
 modules/calloc-gnu   |  4 +++-
 modules/calloc-posix |  4 ++--
 modules/stdlib       |  4 +++-
 7 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 90c019dd4..ee1ede3d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2022-01-03  Bruno Haible  <br...@clisp.org>
+
+	calloc-gnu: Allow use as dependency from test modules.
+	* m4/calloc.m4 (gl_FUNC_CALLOC_GNU): Set REPLACE_CALLOC_FOR_CALLOC_GNU
+	instead of REPLACE_CALLOC.
+	(gl_FUNC_CALLOC_POSIX): Set REPLACE_CALLOC_FOR_CALLOC_POSIX instead of
+	REPLACE_CALLOC.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize the
+	calloc-gnu module indicator.
+	(gl_STDLIB_H_DEFAULTS): Initialize REPLACE_CALLOC_FOR_CALLOC_GNU,
+	REPLACE_CALLOC_FOR_CALLOC_POSIX, not REPLACE_CALLOC.
+	* modules/stdlib (Makefile.am): Substitute GNULIB_CALLOC_GNU,
+	REPLACE_CALLOC_FOR_CALLOC_GNU, REPLACE_CALLOC_FOR_CALLOC_POSIX, not
+	REPLACE_CALLOC.
+	* modules/calloc-posix (Depends-on, configure.ac): Test
+	REPLACE_CALLOC_FOR_CALLOC_POSIX instead of REPLACE_CALLOC.
+	* modules/calloc-gnu (Depends-on): Add xalloc-oversized.
+	(configure.ac): Test REPLACE_CALLOC_FOR_CALLOC_GNU instead of
+	REPLACE_CALLOC. Set a module indicator.
+	* lib/stdlib.in.h (calloc): Test REPLACE_CALLOC_FOR_CALLOC_POSIX,
+	REPLACE_CALLOC_FOR_CALLOC_GNU, and the respective module indicators
+	instead of just REPLACE_CALLOC.
+
 2022-01-03  Bruno Haible  <br...@clisp.org>
 
 	malloc-gnu: Allow use as dependency from test modules.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 5664fd216..64231c2d5 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -260,7 +260,8 @@ _GL_WARN_ON_USE (atoll, "atoll is unportable - "
 #endif
 
 #if @GNULIB_CALLOC_POSIX@
-# if @REPLACE_CALLOC@
+# if (@GNULIB_CALLOC_POSIX@ && @REPLACE_CALLOC_FOR_CALLOC_POSIX@) \
+     || (@GNULIB_CALLOC_GNU@ && @REPLACE_CALLOC_FOR_CALLOC_GNU@)
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef calloc
 #   define calloc rpl_calloc
diff --git a/m4/calloc.m4 b/m4/calloc.m4
index 3cc21c524..c01520e53 100644
--- a/m4/calloc.m4
+++ b/m4/calloc.m4
@@ -1,4 +1,4 @@
-# calloc.m4 serial 28
+# calloc.m4 serial 29
 
 # Copyright (C) 2004-2022 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -58,8 +58,9 @@ AC_DEFUN([gl_FUNC_CALLOC_GNU],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_CALLOC_POSIX])
-  if test $REPLACE_CALLOC = 0; then
-    _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC=1])
+  REPLACE_CALLOC_FOR_CALLOC_GNU="$REPLACE_CALLOC_FOR_CALLOC_POSIX"
+  if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 0; then
+    _AC_FUNC_CALLOC_IF([], [REPLACE_CALLOC_FOR_CALLOC_GNU=1])
   fi
 ])# gl_FUNC_CALLOC_GNU
 
@@ -73,7 +74,7 @@ AC_DEFUN([gl_FUNC_CALLOC_POSIX],
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MALLOC_POSIX])
   if test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1; then
-    REPLACE_CALLOC=1
+    REPLACE_CALLOC_FOR_CALLOC_POSIX=1
   fi
   dnl Although in theory we should also test for size_t overflow,
   dnl in practice testing for ptrdiff_t overflow suffices
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 69ab51aa3..4e1d99668 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 64
+# stdlib_h.m4 serial 65
 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,
@@ -68,6 +68,7 @@ AC_DEFUN([gl_STDLIB_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB__EXIT])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALIGNED_ALLOC])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ATOLL])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_GNU])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CALLOC_POSIX])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
@@ -165,7 +166,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_UNLOCKPT=1;           AC_SUBST([HAVE_UNLOCKPT])
   HAVE_DECL_UNSETENV=1;      AC_SUBST([HAVE_DECL_UNSETENV])
   REPLACE_ALIGNED_ALLOC=0;   AC_SUBST([REPLACE_ALIGNED_ALLOC])
-  REPLACE_CALLOC=0;          AC_SUBST([REPLACE_CALLOC])
+  REPLACE_CALLOC_FOR_CALLOC_GNU=0;    AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
+  REPLACE_CALLOC_FOR_CALLOC_POSIX=0;  AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_FREE=0;            AC_SUBST([REPLACE_FREE])
   REPLACE_INITSTATE=0;       AC_SUBST([REPLACE_INITSTATE])
diff --git a/modules/calloc-gnu b/modules/calloc-gnu
index bbd2a4933..037345bad 100644
--- a/modules/calloc-gnu
+++ b/modules/calloc-gnu
@@ -7,12 +7,14 @@ m4/calloc.m4
 
 Depends-on:
 calloc-posix
+xalloc-oversized     [test $REPLACE_REALLOC_FOR_CALLOC_GNU = 1]
 
 configure.ac:
 gl_FUNC_CALLOC_GNU
-if test $REPLACE_CALLOC = 1; then
+if test $REPLACE_CALLOC_FOR_CALLOC_GNU = 1; then
   AC_LIBOBJ([calloc])
 fi
+gl_STDLIB_MODULE_INDICATOR([calloc-gnu])
 
 Makefile.am:
 
diff --git a/modules/calloc-posix b/modules/calloc-posix
index dc9cadd5c..9ff6913b8 100644
--- a/modules/calloc-posix
+++ b/modules/calloc-posix
@@ -8,11 +8,11 @@ m4/malloc.m4
 
 Depends-on:
 stdlib
-xalloc-oversized     [test $REPLACE_REALLOC = 1]
+xalloc-oversized     [test $REPLACE_REALLOC_FOR_CALLOC_POSIX = 1]
 
 configure.ac:
 gl_FUNC_CALLOC_POSIX
-if test $REPLACE_CALLOC = 1; then
+if test $REPLACE_CALLOC_FOR_CALLOC_POSIX = 1; then
   AC_LIBOBJ([calloc])
 fi
 gl_STDLIB_MODULE_INDICATOR([calloc-posix])
diff --git a/modules/stdlib b/modules/stdlib
index ed7912b9f..63e600d13 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -37,6 +37,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \
 	      -e 's/@''GNULIB_ALIGNED_ALLOC''@/$(GNULIB_ALIGNED_ALLOC)/g' \
 	      -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \
+	      -e 's/@''GNULIB_CALLOC_GNU''@/$(GNULIB_CALLOC_GNU)/g' \
 	      -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \
 	      -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \
 	      -e 's/@''GNULIB_FREE_POSIX''@/$(GNULIB_FREE_POSIX)/g' \
@@ -125,7 +126,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
 	      -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
 	      -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
-	      -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
+	      -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
+	      -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
 	      -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
-- 
2.25.1

>From 918e06951df709672d744e7600cc808b065a8e9e Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 3 Jan 2022 15:31:53 +0100
Subject: [PATCH 3/5] 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.
---
 ChangeLog             | 24 ++++++++++++++++++++++++
 lib/stdlib.in.h       |  3 ++-
 m4/realloc.m4         |  8 ++++----
 m4/stdlib_h.m4        |  6 ++++--
 modules/realloc-gnu   | 11 +++++------
 modules/realloc-posix |  8 ++++----
 modules/stdlib        |  4 +++-
 7 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ee1ede3d6..655529e83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2022-01-03  Bruno Haible  <br...@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  <br...@clisp.org>
 
 	calloc-gnu: Allow use as dependency from test modules.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 64231c2d5..d52c2f796 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -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
diff --git a/m4/realloc.m4 b/m4/realloc.m4
index eb981328b..86e57c259 100644
--- a/m4/realloc.m4
+++ b/m4/realloc.m4
@@ -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
 ])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 4e1d99668..9e2096976 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -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])
diff --git a/modules/realloc-gnu b/modules/realloc-gnu
index 7752d8c6a..b06a237dd 100644
--- a/modules/realloc-gnu
+++ b/modules/realloc-gnu
@@ -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:
 
diff --git a/modules/realloc-posix b/modules/realloc-posix
index a30356f31..c87d7edd4 100644
--- a/modules/realloc-posix
+++ b/modules/realloc-posix
@@ -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])
diff --git a/modules/stdlib b/modules/stdlib
index 63e600d13..45d8f5933 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -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' \
-- 
2.25.1

>From a690f1be8debcbe5d5265915233d533a7f9dcbaf Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 3 Jan 2022 16:17:18 +0100
Subject: [PATCH 4/5] fopen-gnu: Allow use as dependency from test modules.

* m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Set REPLACE_FOPEN_FOR_FOPEN_GNU
instead of REPLACE_FOPEN.
* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize the fopen-gnu
module indicator.
(gl_STDIO_H_DEFAULTS): Initialize REPLACE_FOPEN_FOR_FOPEN_GNU.
* modules/stdio (Makefile.am): Substitute GNULIB_FOPEN_GNU,
REPLACE_FOPEN_FOR_FOPEN_GNU.
* modules/fopen-gnu (Depends-on): Add more dependencies.
(configure.ac): Test REPLACE_FOPEN_FOR_FOPEN_GNU instead of
REPLACE_FOPEN.
* lib/stdio.in.h (fopen): Test REPLACE_FOPEN,
REPLACE_FOPEN_FOR_FOPEN_GNU, and the respective module indicators
instead of just REPLACE_FOPEN.
---
 ChangeLog         | 17 +++++++++++++++++
 lib/stdio.in.h    |  3 ++-
 m4/fopen.m4       |  7 ++++---
 m4/stdio_h.m4     |  4 +++-
 modules/fopen-gnu |  9 +++++++--
 modules/stdio     |  2 ++
 6 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 655529e83..9824e5793 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2022-01-03  Bruno Haible  <br...@clisp.org>
+
+	fopen-gnu: Allow use as dependency from test modules.
+	* m4/fopen.m4 (gl_FUNC_FOPEN_GNU): Set REPLACE_FOPEN_FOR_FOPEN_GNU
+	instead of REPLACE_FOPEN.
+	* m4/stdio_h.m4 (gl_STDIO_H_REQUIRE_DEFAULTS): Initialize the fopen-gnu
+	module indicator.
+	(gl_STDIO_H_DEFAULTS): Initialize REPLACE_FOPEN_FOR_FOPEN_GNU.
+	* modules/stdio (Makefile.am): Substitute GNULIB_FOPEN_GNU,
+	REPLACE_FOPEN_FOR_FOPEN_GNU.
+	* modules/fopen-gnu (Depends-on): Add more dependencies.
+	(configure.ac): Test REPLACE_FOPEN_FOR_FOPEN_GNU instead of
+	REPLACE_FOPEN.
+	* lib/stdio.in.h (fopen): Test REPLACE_FOPEN,
+	REPLACE_FOPEN_FOR_FOPEN_GNU, and the respective module indicators
+	instead of just REPLACE_FOPEN.
+
 2022-01-03  Bruno Haible  <br...@clisp.org>
 
 	realloc-gnu: Allow use as dependency from test modules.
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 8fcec011d..7b36dac2f 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -399,7 +399,8 @@ _GL_CXXALIASWARN (fileno);
 #endif
 
 #if @GNULIB_FOPEN@
-# if @REPLACE_FOPEN@
+# if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
+     || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef fopen
 #   define fopen rpl_fopen
diff --git a/m4/fopen.m4 b/m4/fopen.m4
index a17719743..50767f828 100644
--- a/m4/fopen.m4
+++ b/m4/fopen.m4
@@ -1,4 +1,4 @@
-# fopen.m4 serial 12
+# fopen.m4 serial 13
 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,
@@ -136,11 +136,12 @@ int main ()
        ])
      rm -f conftest.x
     ])
+  REPLACE_FOPEN_FOR_FOPEN_GNU="$REPLACE_FOPEN"
   case "$gl_cv_func_fopen_mode_x" in
-    *no) REPLACE_FOPEN=1 ;;
+    *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
   esac
   case "$gl_cv_func_fopen_mode_e" in
-    *no) REPLACE_FOPEN=1 ;;
+    *no) REPLACE_FOPEN_FOR_FOPEN_GNU=1 ;;
   esac
 ])
 
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 3180d43f4..cc80e7736 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 56
+# stdio_h.m4 serial 57
 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,
@@ -119,6 +119,7 @@ AC_DEFUN([gl_STDIO_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETC])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FGETS])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FOPEN_GNU])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPRINTF_POSIX])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FPURGE])
@@ -202,6 +203,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   REPLACE_FDOPEN=0;              AC_SUBST([REPLACE_FDOPEN])
   REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
   REPLACE_FOPEN=0;               AC_SUBST([REPLACE_FOPEN])
+  REPLACE_FOPEN_FOR_FOPEN_GNU=0; AC_SUBST([REPLACE_FOPEN_FOR_FOPEN_GNU])
   REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
   REPLACE_FPURGE=0;              AC_SUBST([REPLACE_FPURGE])
   REPLACE_FREOPEN=0;             AC_SUBST([REPLACE_FREOPEN])
diff --git a/modules/fopen-gnu b/modules/fopen-gnu
index 9252c749b..86635a140 100644
--- a/modules/fopen-gnu
+++ b/modules/fopen-gnu
@@ -6,11 +6,16 @@ lib/fopen.c
 
 Depends-on:
 fopen
-open            [test $REPLACE_FOPEN = 1]
+open            [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1]
+fcntl-h         [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1]
+stdbool         [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1]
+unistd          [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1]
+close           [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1]
+fstat           [test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1]
 
 configure.ac:
 gl_FUNC_FOPEN_GNU
-if test $REPLACE_FOPEN = 1; then
+if test $REPLACE_FOPEN_FOR_FOPEN_GNU = 1; then
   AC_LIBOBJ([fopen])
   gl_PREREQ_FOPEN
 fi
diff --git a/modules/stdio b/modules/stdio
index dab8d4e8b..0f250558d 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -66,6 +66,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
 	      -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \
 	      -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \
 	      -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \
+	      -e 's/@''GNULIB_FOPEN_GNU''@/$(GNULIB_FOPEN_GNU)/g' \
 	      -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \
 	      -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \
 	      -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \
@@ -141,6 +142,7 @@ stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
 	      -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
 	      -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
 	      -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+	      -e 's|@''REPLACE_FOPEN_FOR_FOPEN_GNU''@|$(REPLACE_FOPEN_FOR_FOPEN_GNU)|g' \
 	      -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
 	      -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
 	      -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
-- 
2.25.1

>From 11d41f8739f2c4ea375e785682935b11f0ab1967 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 3 Jan 2022 16:34:39 +0100
Subject: [PATCH 5/5] getpass-gnu: Allow use as dependency from test modules.

* m4/getpass.m4 (gl_FUNC_GETPASS_GNU): Set
REPLACE_GETPASS_FOR_GETPASS_GNU instead of REPLACE_GETPASS.
* m4/unistd_h.m4 (gl_UNISTD_H_REQUIRE_DEFAULTS): Initialize the
getpass-gnu module indicator.
(gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETPASS_FOR_GETPASS_GNU.
* modules/unistd (Makefile.am): Substitute GNULIB_GETPASS_GNU,
REPLACE_GETPASS_FOR_GETPASS_GNU.
* modules/getpass-gnu (configure.ac): Test
REPLACE_GETPASS_FOR_GETPASS_GNU instead of REPLACE_GETPASS. Set a module
indicator.
* lib/unistd.in.h (getpass): Test REPLACE_GETPASS,
REPLACE_GETPASS_FOR_GETPASS_GNU, and the respective module indicators
instead of just REPLACE_GETPASS.
---
 ChangeLog           |  17 ++++
 lib/unistd.in.h     |   3 +-
 m4/getpass.m4       |   4 +-
 m4/unistd_h.m4      | 188 ++++++++++++++++++++++----------------------
 modules/getpass-gnu |   4 +-
 modules/unistd      |   2 +
 6 files changed, 120 insertions(+), 98 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9824e5793..8c86e4f77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2022-01-03  Bruno Haible  <br...@clisp.org>
+
+	getpass-gnu: Allow use as dependency from test modules.
+	* m4/getpass.m4 (gl_FUNC_GETPASS_GNU): Set
+	REPLACE_GETPASS_FOR_GETPASS_GNU instead of REPLACE_GETPASS.
+	* m4/unistd_h.m4 (gl_UNISTD_H_REQUIRE_DEFAULTS): Initialize the
+	getpass-gnu module indicator.
+	(gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETPASS_FOR_GETPASS_GNU.
+	* modules/unistd (Makefile.am): Substitute GNULIB_GETPASS_GNU,
+	REPLACE_GETPASS_FOR_GETPASS_GNU.
+	* modules/getpass-gnu (configure.ac): Test
+	REPLACE_GETPASS_FOR_GETPASS_GNU instead of REPLACE_GETPASS. Set a module
+	indicator.
+	* lib/unistd.in.h (getpass): Test REPLACE_GETPASS,
+	REPLACE_GETPASS_FOR_GETPASS_GNU, and the respective module indicators
+	instead of just REPLACE_GETPASS.
+
 2022-01-03  Bruno Haible  <br...@clisp.org>
 
 	fopen-gnu: Allow use as dependency from test modules.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index b626eb41e..3386f0b0f 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1409,7 +1409,8 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
      Read a password from /dev/tty or stdin.
    Function getpass() from module 'getpass-gnu':
      Read a password of arbitrary length from /dev/tty or stdin.  */
-# if @REPLACE_GETPASS@
+# if (@GNULIB_GETPASS@ && @REPLACE_GETPASS@) \
+     || (@GNULIB_GETPASS_GNU@ && @REPLACE_GETPASS_FOR_GETPASS_GNU@)
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef getpass
 #   define getpass rpl_getpass
diff --git a/m4/getpass.m4 b/m4/getpass.m4
index 2238a5e78..863cb3548 100644
--- a/m4/getpass.m4
+++ b/m4/getpass.m4
@@ -1,4 +1,4 @@
-# getpass.m4 serial 16
+# getpass.m4 serial 17
 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2022 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -42,7 +42,7 @@ AC_DEFUN([gl_FUNC_GETPASS_GNU],
          [gl_cv_func_getpass_good=no])
       ])
     if test $gl_cv_func_getpass_good != yes; then
-      REPLACE_GETPASS=1
+      REPLACE_GETPASS_FOR_GETPASS_GNU=1
     fi
   fi
 ])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index d9b34a932..f93f97a1b 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 89
+# unistd_h.m4 serial 90
 dnl Copyright (C) 2006-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,
@@ -112,6 +112,7 @@ AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY])
@@ -170,98 +171,99 @@ AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS],
 AC_DEFUN([gl_UNISTD_H_DEFAULTS],
 [
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_CHOWN=1;           AC_SUBST([HAVE_CHOWN])
-  HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
-  HAVE_DUP3=1;            AC_SUBST([HAVE_DUP3])
-  HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
-  HAVE_EXECVPE=1;         AC_SUBST([HAVE_EXECVPE])
-  HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
-  HAVE_FCHDIR=1;          AC_SUBST([HAVE_FCHDIR])
-  HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
-  HAVE_FDATASYNC=1;       AC_SUBST([HAVE_FDATASYNC])
-  HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
-  HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
-  HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
-  HAVE_GETENTROPY=1;      AC_SUBST([HAVE_GETENTROPY])
-  HAVE_GETGROUPS=1;       AC_SUBST([HAVE_GETGROUPS])
-  HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
-  HAVE_GETLOGIN=1;        AC_SUBST([HAVE_GETLOGIN])
-  HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
-  HAVE_GETPASS=1;         AC_SUBST([HAVE_GETPASS])
-  HAVE_GROUP_MEMBER=1;    AC_SUBST([HAVE_GROUP_MEMBER])
-  HAVE_LCHOWN=1;          AC_SUBST([HAVE_LCHOWN])
-  HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
-  HAVE_LINKAT=1;          AC_SUBST([HAVE_LINKAT])
-  HAVE_PIPE=1;            AC_SUBST([HAVE_PIPE])
-  HAVE_PIPE2=1;           AC_SUBST([HAVE_PIPE2])
-  HAVE_PREAD=1;           AC_SUBST([HAVE_PREAD])
-  HAVE_PWRITE=1;          AC_SUBST([HAVE_PWRITE])
-  HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
-  HAVE_READLINKAT=1;      AC_SUBST([HAVE_READLINKAT])
-  HAVE_SETHOSTNAME=1;     AC_SUBST([HAVE_SETHOSTNAME])
-  HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
-  HAVE_SYMLINK=1;         AC_SUBST([HAVE_SYMLINK])
-  HAVE_SYMLINKAT=1;       AC_SUBST([HAVE_SYMLINKAT])
-  HAVE_UNLINKAT=1;        AC_SUBST([HAVE_UNLINKAT])
-  HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
-  HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
-  HAVE_DECL_EXECVPE=1;    AC_SUBST([HAVE_DECL_EXECVPE])
-  HAVE_DECL_FCHDIR=1;     AC_SUBST([HAVE_DECL_FCHDIR])
-  HAVE_DECL_FDATASYNC=1;  AC_SUBST([HAVE_DECL_FDATASYNC])
-  HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
-  HAVE_DECL_GETLOGIN=1;   AC_SUBST([HAVE_DECL_GETLOGIN])
-  HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
-  HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
-  HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
-  HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
-  HAVE_DECL_TRUNCATE=1;   AC_SUBST([HAVE_DECL_TRUNCATE])
-  HAVE_DECL_TTYNAME_R=1;  AC_SUBST([HAVE_DECL_TTYNAME_R])
-  HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
-  HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
-  REPLACE_ACCESS=0;       AC_SUBST([REPLACE_ACCESS])
-  REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
-  REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
-  REPLACE_DUP=0;          AC_SUBST([REPLACE_DUP])
-  REPLACE_DUP2=0;         AC_SUBST([REPLACE_DUP2])
-  REPLACE_EXECL=0;        AC_SUBST([REPLACE_EXECL])
-  REPLACE_EXECLE=0;       AC_SUBST([REPLACE_EXECLE])
-  REPLACE_EXECLP=0;       AC_SUBST([REPLACE_EXECLP])
-  REPLACE_EXECV=0;        AC_SUBST([REPLACE_EXECV])
-  REPLACE_EXECVE=0;       AC_SUBST([REPLACE_EXECVE])
-  REPLACE_EXECVP=0;       AC_SUBST([REPLACE_EXECVP])
-  REPLACE_EXECVPE=0;      AC_SUBST([REPLACE_EXECVPE])
-  REPLACE_FACCESSAT=0;    AC_SUBST([REPLACE_FACCESSAT])
-  REPLACE_FCHOWNAT=0;     AC_SUBST([REPLACE_FCHOWNAT])
-  REPLACE_FTRUNCATE=0;    AC_SUBST([REPLACE_FTRUNCATE])
-  REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
-  REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
-  REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
-  REPLACE_GETLOGIN_R=0;   AC_SUBST([REPLACE_GETLOGIN_R])
-  REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
-  REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
-  REPLACE_GETPASS=0;      AC_SUBST([REPLACE_GETPASS])
-  REPLACE_ISATTY=0;       AC_SUBST([REPLACE_ISATTY])
-  REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
-  REPLACE_LINK=0;         AC_SUBST([REPLACE_LINK])
-  REPLACE_LINKAT=0;       AC_SUBST([REPLACE_LINKAT])
-  REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
-  REPLACE_PREAD=0;        AC_SUBST([REPLACE_PREAD])
-  REPLACE_PWRITE=0;       AC_SUBST([REPLACE_PWRITE])
-  REPLACE_READ=0;         AC_SUBST([REPLACE_READ])
-  REPLACE_READLINK=0;     AC_SUBST([REPLACE_READLINK])
-  REPLACE_READLINKAT=0;   AC_SUBST([REPLACE_READLINKAT])
-  REPLACE_RMDIR=0;        AC_SUBST([REPLACE_RMDIR])
-  REPLACE_SLEEP=0;        AC_SUBST([REPLACE_SLEEP])
-  REPLACE_SYMLINK=0;      AC_SUBST([REPLACE_SYMLINK])
-  REPLACE_SYMLINKAT=0;    AC_SUBST([REPLACE_SYMLINKAT])
-  REPLACE_TRUNCATE=0;     AC_SUBST([REPLACE_TRUNCATE])
-  REPLACE_TTYNAME_R=0;    AC_SUBST([REPLACE_TTYNAME_R])
-  REPLACE_UNLINK=0;       AC_SUBST([REPLACE_UNLINK])
-  REPLACE_UNLINKAT=0;     AC_SUBST([REPLACE_UNLINKAT])
-  REPLACE_USLEEP=0;       AC_SUBST([REPLACE_USLEEP])
-  REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
-  UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
-  UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
+  HAVE_CHOWN=1;                      AC_SUBST([HAVE_CHOWN])
+  HAVE_COPY_FILE_RANGE=1;            AC_SUBST([HAVE_COPY_FILE_RANGE])
+  HAVE_DUP3=1;                       AC_SUBST([HAVE_DUP3])
+  HAVE_EUIDACCESS=1;                 AC_SUBST([HAVE_EUIDACCESS])
+  HAVE_EXECVPE=1;                    AC_SUBST([HAVE_EXECVPE])
+  HAVE_FACCESSAT=1;                  AC_SUBST([HAVE_FACCESSAT])
+  HAVE_FCHDIR=1;                     AC_SUBST([HAVE_FCHDIR])
+  HAVE_FCHOWNAT=1;                   AC_SUBST([HAVE_FCHOWNAT])
+  HAVE_FDATASYNC=1;                  AC_SUBST([HAVE_FDATASYNC])
+  HAVE_FSYNC=1;                      AC_SUBST([HAVE_FSYNC])
+  HAVE_FTRUNCATE=1;                  AC_SUBST([HAVE_FTRUNCATE])
+  HAVE_GETDTABLESIZE=1;              AC_SUBST([HAVE_GETDTABLESIZE])
+  HAVE_GETENTROPY=1;                 AC_SUBST([HAVE_GETENTROPY])
+  HAVE_GETGROUPS=1;                  AC_SUBST([HAVE_GETGROUPS])
+  HAVE_GETHOSTNAME=1;                AC_SUBST([HAVE_GETHOSTNAME])
+  HAVE_GETLOGIN=1;                   AC_SUBST([HAVE_GETLOGIN])
+  HAVE_GETPAGESIZE=1;                AC_SUBST([HAVE_GETPAGESIZE])
+  HAVE_GETPASS=1;                    AC_SUBST([HAVE_GETPASS])
+  HAVE_GROUP_MEMBER=1;               AC_SUBST([HAVE_GROUP_MEMBER])
+  HAVE_LCHOWN=1;                     AC_SUBST([HAVE_LCHOWN])
+  HAVE_LINK=1;                       AC_SUBST([HAVE_LINK])
+  HAVE_LINKAT=1;                     AC_SUBST([HAVE_LINKAT])
+  HAVE_PIPE=1;                       AC_SUBST([HAVE_PIPE])
+  HAVE_PIPE2=1;                      AC_SUBST([HAVE_PIPE2])
+  HAVE_PREAD=1;                      AC_SUBST([HAVE_PREAD])
+  HAVE_PWRITE=1;                     AC_SUBST([HAVE_PWRITE])
+  HAVE_READLINK=1;                   AC_SUBST([HAVE_READLINK])
+  HAVE_READLINKAT=1;                 AC_SUBST([HAVE_READLINKAT])
+  HAVE_SETHOSTNAME=1;                AC_SUBST([HAVE_SETHOSTNAME])
+  HAVE_SLEEP=1;                      AC_SUBST([HAVE_SLEEP])
+  HAVE_SYMLINK=1;                    AC_SUBST([HAVE_SYMLINK])
+  HAVE_SYMLINKAT=1;                  AC_SUBST([HAVE_SYMLINKAT])
+  HAVE_UNLINKAT=1;                   AC_SUBST([HAVE_UNLINKAT])
+  HAVE_USLEEP=1;                     AC_SUBST([HAVE_USLEEP])
+  HAVE_DECL_ENVIRON=1;               AC_SUBST([HAVE_DECL_ENVIRON])
+  HAVE_DECL_EXECVPE=1;               AC_SUBST([HAVE_DECL_EXECVPE])
+  HAVE_DECL_FCHDIR=1;                AC_SUBST([HAVE_DECL_FCHDIR])
+  HAVE_DECL_FDATASYNC=1;             AC_SUBST([HAVE_DECL_FDATASYNC])
+  HAVE_DECL_GETDOMAINNAME=1;         AC_SUBST([HAVE_DECL_GETDOMAINNAME])
+  HAVE_DECL_GETLOGIN=1;              AC_SUBST([HAVE_DECL_GETLOGIN])
+  HAVE_DECL_GETLOGIN_R=1;            AC_SUBST([HAVE_DECL_GETLOGIN_R])
+  HAVE_DECL_GETPAGESIZE=1;           AC_SUBST([HAVE_DECL_GETPAGESIZE])
+  HAVE_DECL_GETUSERSHELL=1;          AC_SUBST([HAVE_DECL_GETUSERSHELL])
+  HAVE_DECL_SETHOSTNAME=1;           AC_SUBST([HAVE_DECL_SETHOSTNAME])
+  HAVE_DECL_TRUNCATE=1;              AC_SUBST([HAVE_DECL_TRUNCATE])
+  HAVE_DECL_TTYNAME_R=1;             AC_SUBST([HAVE_DECL_TTYNAME_R])
+  HAVE_OS_H=0;                       AC_SUBST([HAVE_OS_H])
+  HAVE_SYS_PARAM_H=0;                AC_SUBST([HAVE_SYS_PARAM_H])
+  REPLACE_ACCESS=0;                  AC_SUBST([REPLACE_ACCESS])
+  REPLACE_CHOWN=0;                   AC_SUBST([REPLACE_CHOWN])
+  REPLACE_CLOSE=0;                   AC_SUBST([REPLACE_CLOSE])
+  REPLACE_DUP=0;                     AC_SUBST([REPLACE_DUP])
+  REPLACE_DUP2=0;                    AC_SUBST([REPLACE_DUP2])
+  REPLACE_EXECL=0;                   AC_SUBST([REPLACE_EXECL])
+  REPLACE_EXECLE=0;                  AC_SUBST([REPLACE_EXECLE])
+  REPLACE_EXECLP=0;                  AC_SUBST([REPLACE_EXECLP])
+  REPLACE_EXECV=0;                   AC_SUBST([REPLACE_EXECV])
+  REPLACE_EXECVE=0;                  AC_SUBST([REPLACE_EXECVE])
+  REPLACE_EXECVP=0;                  AC_SUBST([REPLACE_EXECVP])
+  REPLACE_EXECVPE=0;                 AC_SUBST([REPLACE_EXECVPE])
+  REPLACE_FACCESSAT=0;               AC_SUBST([REPLACE_FACCESSAT])
+  REPLACE_FCHOWNAT=0;                AC_SUBST([REPLACE_FCHOWNAT])
+  REPLACE_FTRUNCATE=0;               AC_SUBST([REPLACE_FTRUNCATE])
+  REPLACE_GETCWD=0;                  AC_SUBST([REPLACE_GETCWD])
+  REPLACE_GETDOMAINNAME=0;           AC_SUBST([REPLACE_GETDOMAINNAME])
+  REPLACE_GETDTABLESIZE=0;           AC_SUBST([REPLACE_GETDTABLESIZE])
+  REPLACE_GETLOGIN_R=0;              AC_SUBST([REPLACE_GETLOGIN_R])
+  REPLACE_GETGROUPS=0;               AC_SUBST([REPLACE_GETGROUPS])
+  REPLACE_GETPAGESIZE=0;             AC_SUBST([REPLACE_GETPAGESIZE])
+  REPLACE_GETPASS=0;                 AC_SUBST([REPLACE_GETPASS])
+  REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
+  REPLACE_ISATTY=0;                  AC_SUBST([REPLACE_ISATTY])
+  REPLACE_LCHOWN=0;                  AC_SUBST([REPLACE_LCHOWN])
+  REPLACE_LINK=0;                    AC_SUBST([REPLACE_LINK])
+  REPLACE_LINKAT=0;                  AC_SUBST([REPLACE_LINKAT])
+  REPLACE_LSEEK=0;                   AC_SUBST([REPLACE_LSEEK])
+  REPLACE_PREAD=0;                   AC_SUBST([REPLACE_PREAD])
+  REPLACE_PWRITE=0;                  AC_SUBST([REPLACE_PWRITE])
+  REPLACE_READ=0;                    AC_SUBST([REPLACE_READ])
+  REPLACE_READLINK=0;                AC_SUBST([REPLACE_READLINK])
+  REPLACE_READLINKAT=0;              AC_SUBST([REPLACE_READLINKAT])
+  REPLACE_RMDIR=0;                   AC_SUBST([REPLACE_RMDIR])
+  REPLACE_SLEEP=0;                   AC_SUBST([REPLACE_SLEEP])
+  REPLACE_SYMLINK=0;                 AC_SUBST([REPLACE_SYMLINK])
+  REPLACE_SYMLINKAT=0;               AC_SUBST([REPLACE_SYMLINKAT])
+  REPLACE_TRUNCATE=0;                AC_SUBST([REPLACE_TRUNCATE])
+  REPLACE_TTYNAME_R=0;               AC_SUBST([REPLACE_TTYNAME_R])
+  REPLACE_UNLINK=0;                  AC_SUBST([REPLACE_UNLINK])
+  REPLACE_UNLINKAT=0;                AC_SUBST([REPLACE_UNLINKAT])
+  REPLACE_USLEEP=0;                  AC_SUBST([REPLACE_USLEEP])
+  REPLACE_WRITE=0;                   AC_SUBST([REPLACE_WRITE])
+  UNISTD_H_HAVE_SYS_RANDOM_H=0;      AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
+  UNISTD_H_HAVE_WINSOCK2_H=0;        AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
   UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
                            AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
 ])
diff --git a/modules/getpass-gnu b/modules/getpass-gnu
index 2c9f76e3f..d968af7e3 100644
--- a/modules/getpass-gnu
+++ b/modules/getpass-gnu
@@ -11,11 +11,11 @@ getpass
 
 configure.ac:
 gl_FUNC_GETPASS_GNU
-if test $HAVE_GETPASS = 0 || test $REPLACE_GETPASS = 1; then
+if test $HAVE_GETPASS = 0 || test $REPLACE_GETPASS_FOR_GETPASS_GNU = 1; then
   AC_LIBOBJ([getpass])
   gl_PREREQ_GETPASS
 fi
-gl_UNISTD_MODULE_INDICATOR([getpass])
+gl_UNISTD_MODULE_INDICATOR([getpass-gnu])
 
 Makefile.am:
 
diff --git a/modules/unistd b/modules/unistd
index faec2da65..326bae0e4 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -74,6 +74,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's/@''GNULIB_GETOPT_POSIX''@/$(GNULIB_GETOPT_POSIX)/g' \
 	      -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \
 	      -e 's/@''GNULIB_GETPASS''@/$(GNULIB_GETPASS)/g' \
+	      -e 's/@''GNULIB_GETPASS_GNU''@/$(GNULIB_GETPASS_GNU)/g' \
 	      -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \
 	      -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \
 	      -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \
@@ -194,6 +195,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
 	      -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
 	      -e 's|@''REPLACE_GETPASS''@|$(REPLACE_GETPASS)|g' \
+	      -e 's|@''REPLACE_GETPASS_FOR_GETPASS_GNU''@|$(REPLACE_GETPASS_FOR_GETPASS_GNU)|g' \
 	      -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
 	      -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
 	      -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
-- 
2.25.1

Reply via email to