166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# 266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# Check for the ability to mmap a file. 366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman# 466b8ab22586debccb1f787d4d52b7f042d4ddeb8John BaumanAC_DEFUN([AC_FUNC_MMAP_FILE], 566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman[AC_CACHE_CHECK(for mmap of files, 666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanac_cv_func_mmap_file, 766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman[ AC_LANG_PUSH([C]) 866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman AC_RUN_IFELSE([ 966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman AC_LANG_PROGRAM([[ 1066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include <sys/types.h> 1166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include <sys/mman.h> 1266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include <fcntl.h> 1366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman]],[[ 1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman int fd; 1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman fd = creat ("foo",0777); 1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman fd = (int) mmap (0, 1, PROT_READ, MAP_SHARED, fd, 0); 1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman unlink ("foo"); 1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman return (fd != (int) MAP_FAILED);]])], 1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman [ac_cv_func_mmap_file=yes],[ac_cv_func_mmap_file=no],[ac_cv_func_mmap_file=no]) 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman AC_LANG_POP([C]) 2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman]) 2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanif test "$ac_cv_func_mmap_file" = yes; then 2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman AC_DEFINE([HAVE_MMAP_FILE],[],[Define if mmap() can map files into memory]) 2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman AC_SUBST(MMAP_FILE,[yes]) 2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumanfi 2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman]) 27