diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-04-17 17:25:57 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-04-17 17:25:57 +0000 |
commit | 39af12e553adb9c2fed434f69b01587b42320828 (patch) | |
tree | f937ac865b7e421b193a33b4b32088ee5560ba72 /gcc/aclocal.m4 | |
parent | 89cfe6e5e9de57da5f37c19da247bb81ce13cca8 (diff) | |
download | gcc-39af12e553adb9c2fed434f69b01587b42320828.tar.gz |
* aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE([AC_FUNC_MMAP]).
(AC_FUNC_MMAP_FILE): New macro, tests read-only private map of
a plain file.
* configure.in: Call AC_FUNC_MMAP_FILE.
* configure: Regenerate.
* config.in: Regenerate.
* intl/loadmsgcat.c: Test HAVE_MMAP_FILE not HAVE_MMAP.
* fixinc/fixincl.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33212 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/aclocal.m4')
-rw-r--r-- | gcc/aclocal.m4 | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4 index 31230b0724f..a0c1c3be7dc 100644 --- a/gcc/aclocal.m4 +++ b/gcc/aclocal.m4 @@ -503,7 +503,6 @@ AC_DEFUN(AM_GNU_GETTEXT, AC_REQUIRE([AC_TYPE_OFF_T])dnl AC_REQUIRE([AC_TYPE_SIZE_T])dnl AC_REQUIRE([AC_FUNC_ALLOCA])dnl - AC_REQUIRE([AC_FUNC_MMAP])dnl AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ unistd.h sys/param.h]) @@ -762,3 +761,55 @@ if test $ac_cv_func_mmap_anywhere = yes; then [Define if mmap can get us zeroed pages from /dev/zero.]) fi ]) + +# Check whether mmap can map a plain file, without MAP_FIXED. +AC_DEFUN([AC_FUNC_MMAP_FILE], +[AC_REQUIRE([AC_FUNC_MMAP_ANYWHERE])dnl +AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file, +[# Create a file one thousand bytes long. +for i in 1 2 3 4 5 6 7 8 9 0 +do for j in 1 2 3 4 5 6 7 8 9 0 +do echo $i $j xxxxx +done +done > conftestdata$$ + +AC_TRY_RUN([ +/* Test by Zack Weinberg. Modified from MMAP_ANYWHERE test by + Richard Henderson and Alexandre Oliva. + Check whether read-only mmap of a plain file works. */ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <sys/mman.h> + +int main() +{ + char *x; + int fd; + struct stat st; + + fd = open("conftestdata$$", O_RDONLY); + if (fd < 0) + exit(1); + + if (fstat (fd, &st)) + exit(2); + + x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (x == (char *) -1) + exit(3); + + if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ') + exit(4); + + if (munmap(x, st.st_size) < 0) + exit(5); + + exit(0); +}], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no, +ac_cv_func_mmap_file=no)]) +if test $ac_cv_func_mmap_file = yes; then + AC_DEFINE(HAVE_MMAP_FILE, 1, + [Define if read-only mmap of a plain file works.]) +fi +]) |