Blame acinclude.m4

Packit Service 3f3093
# mmap(2) blacklisting.  Some platforms provide the mmap library routine
Packit Service 3f3093
# but don't support all of the features we need from it.
Packit Service 3f3093
AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
Packit Service 3f3093
[
Packit Service 3f3093
AC_CHECK_HEADER([sys/mman.h],
Packit Service 3f3093
		[libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no])
Packit Service 3f3093
AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no])
Packit Service 3f3093
if test "$libffi_header_sys_mman_h" != yes \
Packit Service 3f3093
 || test "$libffi_func_mmap" != yes; then
Packit Service 3f3093
   ac_cv_func_mmap_file=no
Packit Service 3f3093
   ac_cv_func_mmap_dev_zero=no
Packit Service 3f3093
   ac_cv_func_mmap_anon=no
Packit Service 3f3093
else
Packit Service 3f3093
   AC_CACHE_CHECK([whether read-only mmap of a plain file works],
Packit Service 3f3093
  ac_cv_func_mmap_file,
Packit Service 3f3093
  [# Add a system to this blacklist if
Packit Service 3f3093
   # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
Packit Service 3f3093
   # memory area containing the same data that you'd get if you applied
Packit Service 3f3093
   # read() to the same fd.  The only system known to have a problem here
Packit Service 3f3093
   # is VMS, where text files have record structure.
Packit Service 3f3093
   case "$host_os" in
Packit Service 3f3093
     vms* | ultrix*)
Packit Service 3f3093
	ac_cv_func_mmap_file=no ;;
Packit Service 3f3093
     *)
Packit Service 3f3093
	ac_cv_func_mmap_file=yes;;
Packit Service 3f3093
   esac])
Packit Service 3f3093
   AC_CACHE_CHECK([whether mmap from /dev/zero works],
Packit Service 3f3093
  ac_cv_func_mmap_dev_zero,
Packit Service 3f3093
  [# Add a system to this blacklist if it has mmap() but /dev/zero
Packit Service 3f3093
   # does not exist, or if mmapping /dev/zero does not give anonymous
Packit Service 3f3093
   # zeroed pages with both the following properties:
Packit Service 3f3093
   # 1. If you map N consecutive pages in with one call, and then
Packit Service 3f3093
   #    unmap any subset of those pages, the pages that were not
Packit Service 3f3093
   #    explicitly unmapped remain accessible.
Packit Service 3f3093
   # 2. If you map two adjacent blocks of memory and then unmap them
Packit Service 3f3093
   #    both at once, they must both go away.
Packit Service 3f3093
   # Systems known to be in this category are Windows (all variants),
Packit Service 3f3093
   # VMS, and Darwin.
Packit Service 3f3093
   case "$host_os" in
Packit Service 3f3093
     vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
Packit Service 3f3093
	ac_cv_func_mmap_dev_zero=no ;;
Packit Service 3f3093
     *)
Packit Service 3f3093
	ac_cv_func_mmap_dev_zero=yes;;
Packit Service 3f3093
   esac])
Packit Service 3f3093
Packit Service 3f3093
   # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
Packit Service 3f3093
   AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
Packit Service 3f3093
    [AC_TRY_COMPILE(
Packit Service 3f3093
[#include <sys/types.h>
Packit Service 3f3093
#include <sys/mman.h>
Packit Service 3f3093
#include <unistd.h>
Packit Service 3f3093
Packit Service 3f3093
#ifndef MAP_ANONYMOUS
Packit Service 3f3093
#define MAP_ANONYMOUS MAP_ANON
Packit Service 3f3093
#endif
Packit Service 3f3093
],
Packit Service 3f3093
[int n = MAP_ANONYMOUS;],
Packit Service 3f3093
    ac_cv_decl_map_anon=yes,
Packit Service 3f3093
    ac_cv_decl_map_anon=no)])
Packit Service 3f3093
Packit Service 3f3093
   if test $ac_cv_decl_map_anon = no; then
Packit Service 3f3093
     ac_cv_func_mmap_anon=no
Packit Service 3f3093
   else
Packit Service 3f3093
     AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
Packit Service 3f3093
     ac_cv_func_mmap_anon,
Packit Service 3f3093
  [# Add a system to this blacklist if it has mmap() and MAP_ANON or
Packit Service 3f3093
   # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
Packit Service 3f3093
   # doesn't give anonymous zeroed pages with the same properties listed
Packit Service 3f3093
   # above for use of /dev/zero.
Packit Service 3f3093
   # Systems known to be in this category are Windows, VMS, and SCO Unix.
Packit Service 3f3093
   case "$host_os" in
Packit Service 3f3093
     vms* | cygwin* | pe | mingw* | sco* | udk* )
Packit Service 3f3093
	ac_cv_func_mmap_anon=no ;;
Packit Service 3f3093
     *)
Packit Service 3f3093
	ac_cv_func_mmap_anon=yes;;
Packit Service 3f3093
   esac])
Packit Service 3f3093
   fi
Packit Service 3f3093
fi
Packit Service 3f3093
Packit Service 3f3093
if test $ac_cv_func_mmap_file = yes; then
Packit Service 3f3093
  AC_DEFINE(HAVE_MMAP_FILE, 1,
Packit Service 3f3093
	    [Define if read-only mmap of a plain file works.])
Packit Service 3f3093
fi
Packit Service 3f3093
if test $ac_cv_func_mmap_dev_zero = yes; then
Packit Service 3f3093
  AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
Packit Service 3f3093
	    [Define if mmap of /dev/zero works.])
Packit Service 3f3093
fi
Packit Service 3f3093
if test $ac_cv_func_mmap_anon = yes; then
Packit Service 3f3093
  AC_DEFINE(HAVE_MMAP_ANON, 1,
Packit Service 3f3093
	    [Define if mmap with MAP_ANON(YMOUS) works.])
Packit Service 3f3093
fi
Packit Service 3f3093
])