1
# mmap(2) blacklisting. Some platforms provide the mmap library routine
2
# but don't support all of the features we need from it.
3
AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
5
AC_CHECK_HEADER([sys/mman.h],
6
[libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no])
7
AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no])
8
if test "$libffi_header_sys_mman_h" != yes \
9
|| test "$libffi_func_mmap" != yes; then
10
ac_cv_func_mmap_file=no
11
ac_cv_func_mmap_dev_zero=no
12
ac_cv_func_mmap_anon=no
14
AC_CACHE_CHECK([whether read-only mmap of a plain file works],
16
[# Add a system to this blacklist if
17
# mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
18
# memory area containing the same data that you'd get if you applied
19
# read() to the same fd. The only system known to have a problem here
20
# is VMS, where text files have record structure.
23
ac_cv_func_mmap_file=no ;;
25
ac_cv_func_mmap_file=yes;;
27
AC_CACHE_CHECK([whether mmap from /dev/zero works],
28
ac_cv_func_mmap_dev_zero,
29
[# Add a system to this blacklist if it has mmap() but /dev/zero
30
# does not exist, or if mmapping /dev/zero does not give anonymous
31
# zeroed pages with both the following properties:
32
# 1. If you map N consecutive pages in with one call, and then
33
# unmap any subset of those pages, the pages that were not
34
# explicitly unmapped remain accessible.
35
# 2. If you map two adjacent blocks of memory and then unmap them
36
# both at once, they must both go away.
37
# Systems known to be in this category are Windows (all variants),
40
vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
41
ac_cv_func_mmap_dev_zero=no ;;
43
ac_cv_func_mmap_dev_zero=yes;;
46
# Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
47
AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
49
[#include <sys/types.h>
54
#define MAP_ANONYMOUS MAP_ANON
57
[int n = MAP_ANONYMOUS;],
58
ac_cv_decl_map_anon=yes,
59
ac_cv_decl_map_anon=no)])
61
if test $ac_cv_decl_map_anon = no; then
62
ac_cv_func_mmap_anon=no
64
AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
66
[# Add a system to this blacklist if it has mmap() and MAP_ANON or
67
# MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
68
# doesn't give anonymous zeroed pages with the same properties listed
69
# above for use of /dev/zero.
70
# Systems known to be in this category are Windows, VMS, and SCO Unix.
72
vms* | cygwin* | pe | mingw* | sco* | udk* )
73
ac_cv_func_mmap_anon=no ;;
75
ac_cv_func_mmap_anon=yes;;
80
if test $ac_cv_func_mmap_file = yes; then
81
AC_DEFINE(HAVE_MMAP_FILE, 1,
82
[Define if read-only mmap of a plain file works.])
84
if test $ac_cv_func_mmap_dev_zero = yes; then
85
AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
86
[Define if mmap of /dev/zero works.])
88
if test $ac_cv_func_mmap_anon = yes; then
89
AC_DEFINE(HAVE_MMAP_ANON, 1,
90
[Define if mmap with MAP_ANON(YMOUS) works.])