Use an all-permissive copyright notice, recommended by RMS.
[gnulib.git] / m4 / free.m4
1 # Check whether free (NULL) is supposed to work.
2
3 # Copyright (C) 2003, 2004 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 # Written by Paul Eggert.
9
10 # We can't test for free (NULL) even at runtime, since it might
11 # happen to "work" for our test program, but not in general.  So, be
12 # conservative and use feature tests for relatively modern hosts,
13 # where free (NULL) is known to work.  This costs a bit of
14 # performance on some older hosts, but we can fix that later if
15 # needed.
16
17 AC_DEFUN([gl_FUNC_FREE],
18 [
19   AC_CHECK_HEADERS_ONCE(unistd.h)
20   AC_CACHE_CHECK([whether free (NULL) is known to work],
21     [gl_cv_func_free],
22     [AC_COMPILE_IFELSE(
23        [AC_LANG_PROGRAM(
24           [[@%:@if HAVE_UNISTD_H
25               @%:@include <unistd.h>
26             @%:@endif]],
27           [[@%:@if _POSIX_VERSION < 199009L && \
28                 (defined unix || defined _unix || defined _unix_ \
29                  || defined __unix || defined __unix__)
30               @%:@error "'free (NULL)' is not known to work"
31             @%:@endif]])],
32        [gl_cv_func_free=yes],
33        [gl_cv_func_free=no])])
34
35   if test $gl_cv_func_free = no; then
36     AC_LIBOBJ(free)
37     AC_DEFINE(free, rpl_free,
38       [Define to rpl_free if the replacement function should be used.])
39   fi
40 ])
41
42 # Prerequisites of lib/free.c.
43 AC_DEFUN([gl_PREREQ_FREE], [:])