Blame m4/mmap-anon.m4

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