2 dnl Copyright (C) 2007, 2009-2012 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 m4_version_prereq([2.70], [] ,[
9 # This is taken from the following Autoconf patch:
10 # http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
11 AC_DEFUN([_AC_FUNC_REALLOC_IF],
13 AC_REQUIRE([AC_HEADER_STDC])dnl
14 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
15 AC_CHECK_HEADERS([stdlib.h])
16 AC_CACHE_CHECK([for GNU libc compatible realloc],
17 [ac_cv_func_realloc_0_nonnull],
20 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
26 [[return ! realloc (0, 0);]])
28 [ac_cv_func_realloc_0_nonnull=yes],
29 [ac_cv_func_realloc_0_nonnull=no],
31 # Guess yes on platforms where we know the result.
32 *-gnu* | freebsd* | netbsd* | openbsd* \
33 | hpux* | solaris* | cygwin* | mingw*)
34 ac_cv_func_realloc_0_nonnull=yes ;;
35 # If we don't know, assume the worst.
36 *) ac_cv_func_realloc_0_nonnull=no ;;
40 AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
47 # Test whether 'realloc (0, 0)' is handled like in GNU libc, and replace
48 # realloc if it is not.
49 AC_DEFUN([gl_FUNC_REALLOC_GNU],
51 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
52 dnl _AC_FUNC_REALLOC_IF is defined in Autoconf.
54 [AC_DEFINE([HAVE_REALLOC_GNU], [1],
55 [Define to 1 if your system has a GNU libc compatible 'realloc'
56 function, and to 0 otherwise.])],
57 [AC_DEFINE([HAVE_REALLOC_GNU], [0])
60 ])# gl_FUNC_REALLOC_GNU
62 # gl_FUNC_REALLOC_POSIX
63 # ---------------------
64 # Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
65 # fails), and replace realloc if it is not.
66 AC_DEFUN([gl_FUNC_REALLOC_POSIX],
68 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
69 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
70 if test $gl_cv_func_malloc_posix = yes; then
71 AC_DEFINE([HAVE_REALLOC_POSIX], [1],
72 [Define if the 'realloc' function is POSIX compliant.])