summaryrefslogtreecommitdiff
path: root/gcc/aclocal.m4
diff options
context:
space:
mode:
authoroliva <oliva@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-16 18:16:55 +0000
committeroliva <oliva@138bc75d-0d04-0410-961f-82ee72b054a4>2000-01-16 18:16:55 +0000
commit8ee6d486b7847592c74a196d67b249009132819d (patch)
tree559155e6d3b9e86e367d612eb679ecc404bda823 /gcc/aclocal.m4
parenta161d435a10c24b5e94eecf428202fd77369f28a (diff)
downloadgcc-8ee6d486b7847592c74a196d67b249009132819d.tar.gz
* aclocal.m4 (AC_FUNC_MMAP_ZERO): New macro.
* configure.in (AC_FUNC_MMAP_ZERO): Use instead of AC_FUNC_MMAP. * ggc-page.c: Replace HAVE_MMAP with HAVE_MMAP_ZERO. * configure, config.in: Rebuilt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31444 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/aclocal.m4')
-rw-r--r--gcc/aclocal.m482
1 files changed, 82 insertions, 0 deletions
diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4
index 300127f2931..d56b8f0847f 100644
--- a/gcc/aclocal.m4
+++ b/gcc/aclocal.m4
@@ -680,3 +680,85 @@ else
fi
AC_SUBST($1)dnl
])
+
+# Check whether mmap can map an arbitrary page from /dev/zero, without
+# MAP_FIXED.
+AC_DEFUN([AC_FUNC_MMAP_ANYWHERE],
+[AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_FUNCS(getpagesize)
+AC_CACHE_CHECK(for working mmap from /dev/zero, ac_cv_func_mmap_zero,
+[AC_TRY_RUN([
+/* Test by Richard Henderson and Alexandre Oliva.
+ Check whether mmap from /dev/zero works. */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+int main()
+{
+ char *x;
+ int fd, pg;
+
+ fd = open("/dev/zero", O_RDWR);
+ if (fd < 0)
+ exit(1);
+
+ pg = getpagesize();
+ x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (x == (char *) -1)
+ exit(2);
+
+ *(int *)x += 1;
+
+ if (munmap(x, pg) < 0)
+ exit(3);
+
+ exit(0);
+}], ac_cv_func_mmap_anywhere=yes, ac_cv_func_mmap_anywhere=no,
+ac_cv_func_mmap_anywhere=no)])
+if test $ac_cv_func_mmap_anywhere = yes; then
+ AC_DEFINE(HAVE_MMAP_ANYWHERE, 1,
+ [Define if mmap can get us zeroed pages from /dev/zero.])
+fi
+])