Linearized checks for if_tun.h
[tinc] / m4 / realloc.m4
1 #serial 1
2
3 dnl From Jim Meyering.
4 dnl Determine whether realloc works when both arguments are 0.
5 dnl If it doesn't, arrange to use the replacement function.
6 dnl
7 dnl If you use this macro in a package, you should
8 dnl add the following two lines to acconfig.h:
9 dnl  /* Define to rpl_realloc if the replacement function should be used.  */
10 dnl  #undef realloc
11 dnl
12
13 AC_DEFUN(jm_FUNC_REALLOC,
14 [
15  if test x = y; then
16    dnl This code is deliberately never run via ./configure.
17    dnl FIXME: this is a gross hack to make autoheader put an entry
18    dnl for this symbol in config.h.in.
19    AC_CHECK_FUNCS(DONE_WORKING_REALLOC_CHECK)
20  fi
21  dnl xmalloc.c requires that this symbol be defined so it doesn't
22  dnl mistakenly use a broken realloc -- as it might if this test were omitted.
23  ac_kludge=HAVE_DONE_WORKING_REALLOC_CHECK
24  AC_DEFINE_UNQUOTED($ac_kludge)
25
26  AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
27   [AC_TRY_RUN([
28     char *realloc ();
29     int
30     main ()
31     {
32       exit (realloc (0, 0) ? 0 : 1);
33     }
34           ],
35          jm_cv_func_working_realloc=yes,
36          jm_cv_func_working_realloc=no,
37          dnl When crosscompiling, assume realloc is broken.
38          jm_cv_func_working_realloc=no)
39   ])
40   if test $jm_cv_func_working_realloc = no; then
41     LIBOBJS="$LIBOBJS realloc.o"
42     AC_DEFINE_UNQUOTED(realloc, rpl_realloc)
43   fi
44 ])