1sinclude(../libtool.m4)
2dnl The lines below arrange for aclocal not to bring libtool.m4
3dnl AC_PROG_LIBTOOL into aclocal.m4, while still arranging for automake
4dnl to add a definition of LIBTOOL to Makefile.in.
5ifelse(yes,no,[
6AC_DEFUN([AC_PROG_LIBTOOL],)
7AC_DEFUN([AM_PROG_LIBTOOL],)
8AC_SUBST(LIBTOOL)
9])
10
11# mmap(2) blacklisting.  Some platforms provide the mmap library routine
12# but don't support all of the features we need from it.
13AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
14[if test $ac_cv_header_sys_mman_h != yes \
15 || test $ac_cv_func_mmap != yes; then
16   ac_cv_func_mmap_file=no
17   ac_cv_func_mmap_dev_zero=no
18   ac_cv_func_mmap_anon=no
19else
20   AC_CACHE_CHECK([whether read-only mmap of a plain file works],
21  ac_cv_func_mmap_file,
22  [# Add a system to this blacklist if
23   # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
24   # memory area containing the same data that you'd get if you applied
25   # read() to the same fd.  The only system known to have a problem here
26   # is VMS, where text files have record structure.
27   case "$host_os" in
28     vms* | ultrix*)
29	ac_cv_func_mmap_file=no ;;
30     *)
31	ac_cv_func_mmap_file=yes;;
32   esac])
33   AC_CACHE_CHECK([whether mmap from /dev/zero works],
34  ac_cv_func_mmap_dev_zero,
35  [# Add a system to this blacklist if it has mmap() but /dev/zero
36   # does not exist, or if mmapping /dev/zero does not give anonymous
37   # zeroed pages with both the following properties:
38   # 1. If you map N consecutive pages in with one call, and then
39   #    unmap any subset of those pages, the pages that were not
40   #    explicitly unmapped remain accessible.
41   # 2. If you map two adjacent blocks of memory and then unmap them
42   #    both at once, they must both go away.
43   # Systems known to be in this category are Windows (all variants),
44   # VMS, and Darwin.
45   case "$host_os" in
46     vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
47	ac_cv_func_mmap_dev_zero=no ;;
48     *)
49	ac_cv_func_mmap_dev_zero=yes;;
50   esac])
51
52   # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
53   AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
54    [AC_TRY_COMPILE(
55[#include <sys/types.h>
56#include <sys/mman.h>
57#include <unistd.h>
58
59#ifndef MAP_ANONYMOUS
60#define MAP_ANONYMOUS MAP_ANON
61#endif
62],
63[int n = MAP_ANONYMOUS;],
64    ac_cv_decl_map_anon=yes,
65    ac_cv_decl_map_anon=no)])
66
67   if test $ac_cv_decl_map_anon = no; then
68     ac_cv_func_mmap_anon=no
69   else
70     AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
71     ac_cv_func_mmap_anon,
72  [# Add a system to this blacklist if it has mmap() and MAP_ANON or
73   # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
74   # doesn't give anonymous zeroed pages with the same properties listed
75   # above for use of /dev/zero.
76   # Systems known to be in this category are Windows, VMS, and SCO Unix.
77   case "$host_os" in
78     vms* | cygwin* | pe | mingw* | sco* | udk* )
79	ac_cv_func_mmap_anon=no ;;
80     *)
81	ac_cv_func_mmap_anon=yes;;
82   esac])
83   fi
84fi
85
86if test $ac_cv_func_mmap_file = yes; then
87  AC_DEFINE(HAVE_MMAP_FILE, 1,
88	    [Define if read-only mmap of a plain file works.])
89fi
90if test $ac_cv_func_mmap_dev_zero = yes; then
91  AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
92	    [Define if mmap of /dev/zero works.])
93fi
94if test $ac_cv_func_mmap_anon = yes; then
95  AC_DEFINE(HAVE_MMAP_ANON, 1,
96	    [Define if mmap with MAP_ANON(YMOUS) works.])
97fi
98])
99
100sinclude(../config/accross.m4)
101