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