3
# Copyright (C) 2004-2011 Free Software Foundation, Inc.
3
# Copyright (C) 2004-2012 Free Software Foundation, Inc.
4
4
# This file is free software; the Free Software Foundation
5
5
# gives unlimited permission to copy and/or distribute it,
6
6
# with or without modifications, as long as this notice is preserved.
15
15
# _AC_FUNC_CALLOC_IF([IF-WORKS], [IF-NOT])
16
16
# -------------------------------------
17
# If `calloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
17
# If 'calloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
18
18
AC_DEFUN([_AC_FUNC_CALLOC_IF],
20
20
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
21
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
21
22
AC_CACHE_CHECK([for GNU libc compatible calloc],
22
23
[ac_cv_func_calloc_0_nonnull],
33
34
[ac_cv_func_calloc_0_nonnull=yes],
34
35
[ac_cv_func_calloc_0_nonnull=no],
35
[ac_cv_func_calloc_0_nonnull=no])])
36
AS_IF([test $ac_cv_func_calloc_0_nonnull = yes], [$1], [$2])
37
# Guess yes on glibc systems.
38
*-gnu*) ac_cv_func_calloc_0_nonnull="guessing yes" ;;
39
# If we don't know, assume the worst.
40
*) ac_cv_func_calloc_0_nonnull="guessing no" ;;
43
case "$ac_cv_func_calloc_0_nonnull" in
40
54
# gl_FUNC_CALLOC_GNU
41
55
# ------------------
42
# Report whether `calloc (0, 0)' is properly handled, and replace calloc if
56
# Report whether 'calloc (0, 0)' is properly handled, and replace calloc if
44
58
AC_DEFUN([gl_FUNC_CALLOC_GNU],
46
60
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
47
61
_AC_FUNC_CALLOC_IF(
48
62
[AC_DEFINE([HAVE_CALLOC_GNU], [1],
49
[Define to 1 if your system has a GNU libc compatible `calloc'
63
[Define to 1 if your system has a GNU libc compatible 'calloc'
50
64
function, and to 0 otherwise.])],
51
65
[AC_DEFINE([HAVE_CALLOC_GNU], [0])