1 # mmap-anon.m4 serial 8
2 dnl Copyright (C) 2009 Christian Thaeter <ct@pipapo.org>
3 dnl parts are borrowed from gnulib:
4 dnl Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Detect how mmap can be used to create anonymous (not file-backed) memory
11 # - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
12 # and MAP_ANON exist and have the same value.
13 # - On HP-UX, only MAP_ANONYMOUS exists.
14 # - On MacOS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists.
15 # - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
18 AC_DEFUN([nobug_FUNC_MMAP_ANON],
20 dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
21 AC_REQUIRE([AC_PROG_CPP])
22 AC_REQUIRE([AC_PROG_EGREP])
26 # Try to allow MAP_ANONYMOUS.
27 nobug_have_mmap_anonymous=no
28 if test x$ac_cv_func_mmap_fixed_mapped = xyes; then
29 AC_MSG_CHECKING([for MAP_ANONYMOUS])
30 AC_EGREP_CPP([I cant identify this map.],
34 I cant identify this map.
37 [nobug_have_mmap_anonymous=yes])
38 if test $nobug_have_mmap_anonymous != yes; then
39 AC_EGREP_CPP([I cant identify this map.],
43 I cant identify this map.
46 [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
47 [Define to a substitute value for mmaps MAP_ANONYMOUS flag.])
48 nobug_have_mmap_anonymous=yes])
50 AC_MSG_RESULT([$nobug_have_mmap_anonymous])
51 if test $nobug_have_mmap_anonymous = yes; then
52 AC_DEFINE([HAVE_MAP_ANONYMOUS], [1],
53 [Define to 1 if mmaps MAP_ANONYMOUS flag is available.])