(get_version): Adjust prototype.
[gnulib.git] / m4 / malloc.m4
1 #serial 2
2
3 dnl From Jim Meyering.
4 dnl Determine whether malloc accepts 0 as its argument.
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_malloc if the replacement function should be used.  */
10 dnl  #undef malloc
11 dnl
12
13 AC_DEFUN(jm_FUNC_MALLOC,
14 [
15  dnl xmalloc.c requires that this symbol be defined so it doesn't
16  dnl mistakenly use a broken malloc -- as it might if this test were omitted.
17  AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
18                     [Define if the malloc check has been performed. ])
19
20  AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
21   [AC_TRY_RUN([
22     char *malloc ();
23     int
24     main ()
25     {
26       exit (malloc (0) ? 0 : 1);
27     }
28           ],
29          jm_cv_func_working_malloc=yes,
30          jm_cv_func_working_malloc=no,
31          dnl When crosscompiling, assume malloc is broken.
32          jm_cv_func_working_malloc=no)
33   ])
34   if test $jm_cv_func_working_malloc = no; then
35     LIBOBJS="$LIBOBJS malloc.o"
36     AC_DEFINE_UNQUOTED(malloc, rpl_malloc)
37   fi
38 ])