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