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