+2022-01-03 Bruno Haible <bruno@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 <bruno@clisp.org>
striconveh: Make the last change also work on Solaris 11.
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
-# 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
[
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,
-# 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,
[
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
])
[
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
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
])
-# 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,
[
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
])
-# 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,
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])
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])
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:
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])
-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' \
-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' \