>From 918e06951df709672d744e7600cc808b065a8e9e Mon Sep 17 00:00:00 2001 From: Bruno Haible 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 + + 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 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