1# mmap(2) blacklisting. Some platforms provide the mmap library routine 2# but don't support all of the features we need from it. 3AC_DEFUN([AC_FUNC_MMAP_BLACKLIST], 4[ 5AC_CHECK_HEADER([sys/mman.h], 6 [libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no]) 7AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no]) 8if 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 13else 14 AC_CACHE_CHECK([whether read-only mmap of a plain file works], 15 ac_cv_func_mmap_file, 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. 21 case "$host_os" in 22 vms* | ultrix*) 23 ac_cv_func_mmap_file=no ;; 24 *) 25 ac_cv_func_mmap_file=yes;; 26 esac]) 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), 38 # VMS, and Darwin. 39 case "$host_os" in 40 vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00) 41 ac_cv_func_mmap_dev_zero=no ;; 42 *) 43 ac_cv_func_mmap_dev_zero=yes;; 44 esac]) 45 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, 48 [AC_TRY_COMPILE( 49[#include <sys/types.h> 50#include <sys/mman.h> 51#include <unistd.h> 52 53#ifndef MAP_ANONYMOUS 54#define MAP_ANONYMOUS MAP_ANON 55#endif 56], 57[int n = MAP_ANONYMOUS;], 58 ac_cv_decl_map_anon=yes, 59 ac_cv_decl_map_anon=no)]) 60 61 if test $ac_cv_decl_map_anon = no; then 62 ac_cv_func_mmap_anon=no 63 else 64 AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works], 65 ac_cv_func_mmap_anon, 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. 71 case "$host_os" in 72 vms* | cygwin* | pe | mingw* | sco* | udk* ) 73 ac_cv_func_mmap_anon=no ;; 74 *) 75 ac_cv_func_mmap_anon=yes;; 76 esac]) 77 fi 78fi 79 80if 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.]) 83fi 84if 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.]) 87fi 88if test $ac_cv_func_mmap_anon = yes; then 89 AC_DEFINE(HAVE_MMAP_ANON, 1, 90 [Define if mmap with MAP_ANON(YMOUS) works.]) 91fi 92]) 93