1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

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.
This commit is contained in:
Bruno Haible
2022-01-03 14:49:04 +01:00
parent 402e0d0d93
commit 5427cd7196
9 changed files with 51 additions and 21 deletions

View File

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

View 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

View 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,

View 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
])

View 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
])

View 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])

View 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:

View 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])

View 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' \