]> Savannah Git Hosting - gnulib.git/commitdiff
malloc-gnu: Allow use as dependency from test modules.
authorBruno Haible <bruno@clisp.org>
Mon, 3 Jan 2022 13:49:04 +0000 (14:49 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 3 Jan 2022 14:16:38 +0000 (15:16 +0100)
* 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
lib/stdlib.in.h
m4/calloc.m4
m4/malloc.m4
m4/realloc.m4
m4/stdlib_h.m4
modules/malloc-gnu
modules/malloc-posix
modules/stdlib

index 2cb4da4cdca0e02b8c89b21d49876ebf903dc60b..90c019dd4a26ba0234d4154db3d05acc93fe6626 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+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.
index c14f31b7e7e2412a4b5099e6caa50fb79e5761e8..5664fd216fbf5173398025656daebd6da538eef1 100644 (file)
@@ -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
index 9cba28f2a20a237dd555cf68bca84b5a50a693b6..3cc21c5243a10b2268dff89690b96da716b92ede 100644 (file)
@@ -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,
index 2a6d3e1e1ba28ab4e5392fbaa32052ca60dc4b36..6b76c1e64dd3e83e964888ef9f5f92e0196fd7f7 100644 (file)
@@ -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
 ])
 
index 62c72f88f23cfce7de7690ceddf1087a4236c5c2..eb981328baeb743ab305306c5f9a5c102c66d4c4 100644 (file)
@@ -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
 ])
index 66fe0975bda650f46ea63d7816ea1776dee236c9..69ab51aa3dc2fb937ec9ef76d75ca3ab8500e397 100644 (file)
@@ -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])
index f8bcdae55b71ca8f4e1c213aa5bf04ed787adb08..b0fa1739e8233b816d3ba598e8843ee5dfe12b7f 100644 (file)
@@ -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:
 
index bafcf38018b90f74f86bd7f30088833933b56dcc..86687aa8aaad6da8e51296ac03d674ce7b8d637e 100644 (file)
@@ -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])
index a5a3c9f75e799c60f255d4ee1e58eb2e2d5f8bbf..ed7912b9ff1e513cb342e7b11e6196fbaae0197c 100644 (file)
@@ -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' \