Debian Codegraph @

m4/mmap-anon.m4

raw
1 # mmap-anon.m4
2 # serial 15
3 dnl Copyright (C) 2005, 2007, 2009-2026 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 # Detect how mmap can be used to create anonymous (not file-backed) memory
10 # mappings.
11 # - On Linux, AIX, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS and
12 # MAP_ANON exist and have the same value.
13 # - On HP-UX, only MAP_ANONYMOUS exists.
14 # - On Mac OS X, FreeBSD, NetBSD, OpenBSD, Minix, only MAP_ANON exists.
15
16 AC_DEFUN_ONCE([gl_FUNC_MMAP_ANON],
17 [
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 # Instead, assume that mmap() exists if and only if <sys/mman.h> exists.
25 # Code needs to tests HAVE_SYS_MMAN_H, not HAVE_MMAP.
26 AC_CHECK_HEADERS_ONCE([sys/mman.h])
27
28 # Try to allow MAP_ANONYMOUS.
29 gl_have_mmap_anonymous=no
30 if test $ac_cv_header_sys_mman_h = yes; then
31 AC_MSG_CHECKING([for MAP_ANONYMOUS])
32 AC_EGREP_CPP([I cannot identify this map], [
33 #include <sys/mman.h>
34 #ifdef MAP_ANONYMOUS
35 I cannot identify this map
36 #endif
37 ],
38 [gl_have_mmap_anonymous=yes])
39 if test $gl_have_mmap_anonymous != yes; then
40 AC_EGREP_CPP([I cannot identify this map], [
41 #include <sys/mman.h>
42 #ifdef MAP_ANON
43 I cannot identify this map
44 #endif
45 ],
46 [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
47 [Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.])
48 gl_have_mmap_anonymous=yes])
49 fi
50 AC_MSG_RESULT([$gl_have_mmap_anonymous])
51 fi
52 ])