degenerate let forms
[bpt/guile.git] / m4 / mmap-anon.m4
CommitLineData
005de2e8 1# mmap-anon.m4 serial 10
5e69ceb7 2dnl Copyright (C) 2005, 2007, 2009-2014 Free Software Foundation, Inc.
c4b681fd
LC
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# Detect how mmap can be used to create anonymous (not file-backed) memory
8# mappings.
9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
10# and MAP_ANON exist and have the same value.
11# - On HP-UX, only MAP_ANONYMOUS exists.
005de2e8 12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists.
c4b681fd
LC
13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
14# used.
15
16AC_DEFUN([gl_FUNC_MMAP_ANON],
17[
c4b681fd
LC
18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20
21 # Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it
22 # fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is
23 # irrelevant for anonymous mappings.
24 AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no])
25
26 # Try to allow MAP_ANONYMOUS.
27 gl_have_mmap_anonymous=no
28 if test $gl_have_mmap = yes; then
29 AC_MSG_CHECKING([for MAP_ANONYMOUS])
005de2e8 30 AC_EGREP_CPP([I cannot identify this map], [
c4b681fd
LC
31#include <sys/mman.h>
32#ifdef MAP_ANONYMOUS
005de2e8 33 I cannot identify this map
c4b681fd
LC
34#endif
35],
36 [gl_have_mmap_anonymous=yes])
37 if test $gl_have_mmap_anonymous != yes; then
005de2e8 38 AC_EGREP_CPP([I cannot identify this map], [
c4b681fd
LC
39#include <sys/mman.h>
40#ifdef MAP_ANON
005de2e8 41 I cannot identify this map
c4b681fd
LC
42#endif
43],
44 [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
45 [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.])
46 gl_have_mmap_anonymous=yes])
47 fi
48 AC_MSG_RESULT([$gl_have_mmap_anonymous])
49 if test $gl_have_mmap_anonymous = yes; then
50 AC_DEFINE([HAVE_MAP_ANONYMOUS], [1],
51 [Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including
52 config.h and <sys/mman.h>.])
53 fi
54 fi
55])