immutable: Add tests.
[gnulib.git] / m4 / malloc_h.m4
blobd3112f58ae7a89d967d73edaeba77962fdfee04e
1 # malloc_h.m4 serial 1
2 dnl Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl Written by Bruno Haible.
9 AC_DEFUN([gl_MALLOC_H],
11   dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12   dnl once only, before all statements that occur in other macros.
13   AC_REQUIRE([gl_MALLOC_H_DEFAULTS])
15   gl_CHECK_NEXT_HEADERS([malloc.h])
16   if test $ac_cv_header_malloc_h = yes; then
17     HAVE_MALLOC_H=1
18   else
19     HAVE_MALLOC_H=0
20   fi
21   AC_SUBST([HAVE_MALLOC_H])
23   dnl Check for declarations of anything we want to poison if the
24   dnl corresponding gnulib module is not in use.
25   gl_WARN_ON_USE_PREPARE([[
26 #if HAVE_MALLOC_H
27 # include <malloc.h>
28 #endif
29     ]], [memalign])
32 AC_DEFUN([gl_MALLOC_MODULE_INDICATOR],
34   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
35   AC_REQUIRE([gl_MALLOC_H_DEFAULTS])
36   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
37   dnl Define it also as a C macro, for the benefit of the unit tests.
38   gl_MODULE_INDICATOR_FOR_TESTS([$1])
41 AC_DEFUN([gl_MALLOC_H_DEFAULTS],
43   GNULIB_MEMALIGN=0;      AC_SUBST([GNULIB_MEMALIGN])
44   dnl Assume proper GNU behavior unless another module says otherwise.
45   HAVE_MEMALIGN=1;        AC_SUBST([HAVE_MEMALIGN])
46   REPLACE_MEMALIGN=0;     AC_SUBST([REPLACE_MEMALIGN])