mmap-anon.m4 revision 2
0N/A# mmap-anon.m4 serial 8
1879N/Adnl Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc.
0N/Adnl This file is free software; the Free Software Foundation
0N/Adnl gives unlimited permission to copy and/or distribute it,
0N/Adnl with or without modifications, as long as this notice is preserved.
0N/A
0N/A# Detect how mmap can be used to create anonymous (not file-backed) memory
0N/A# mappings.
0N/A# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
0N/A# and MAP_ANON exist and have the same value.
0N/A# - On HP-UX, only MAP_ANONYMOUS exists.
0N/A# - On MacOS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists.
0N/A# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
0N/A# used.
0N/A
0N/AAC_DEFUN([gl_FUNC_MMAP_ANON],
0N/A[
0N/A dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
1472N/A AC_REQUIRE([AC_PROG_CPP])
1472N/A AC_REQUIRE([AC_PROG_EGREP])
1472N/A
0N/A dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
0N/A AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
0N/A
1879N/A # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
1879N/A # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
1879N/A # irrelevant for anonymous mappings.
1879N/A AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no])
1879N/A
1879N/A # Try to allow MAP_ANONYMOUS.
1879N/A gl_have_mmap_anonymous=no
1879N/A if test $gl_have_mmap = yes; then
1879N/A AC_MSG_CHECKING([for MAP_ANONYMOUS])
1879N/A AC_EGREP_CPP([I cant identify this map.], [
0N/A#include <sys/mman.h>
0N/A#ifdef MAP_ANONYMOUS
0N/A I cant identify this map.
1522N/A#endif
1522N/A],
1522N/A [gl_have_mmap_anonymous=yes])
1522N/A if test $gl_have_mmap_anonymous != yes; then
0N/A AC_EGREP_CPP([I cant identify this map.], [
0N/A#include <sys/mman.h>
0N/A#ifdef MAP_ANON
0N/A I cant identify this map.
0N/A#endif
0N/A],
0N/A [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
0N/A [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.])
973N/A gl_have_mmap_anonymous=yes])
0N/A fi
973N/A AC_MSG_RESULT([$gl_have_mmap_anonymous])
973N/A if test $gl_have_mmap_anonymous = yes; then
973N/A AC_DEFINE([HAVE_MAP_ANONYMOUS], [1],
973N/A [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including
0N/A config.h and <sys/mman.h>.])
0N/A fi
0N/A fi
0N/A])
0N/A