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