This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: hpux 10.20 and mmap everywhere


> No, just extend the HAVE_MMAP_ANYWHERE test.  All that test is
> trying to find out is if we can get zeroed pages anywhere in the
> address space.
> 
> Something like
> 
> #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
> #define MAP_ANONYMOUS MAP_ANON
> #endif
> ...
> #ifdef MAP_ANONYMOUS
>   fd = -1;
> #else
>   fd = open("/dev/zero", O_RDWR);
>   if (fd < 0)
>     exit(1);
> #endif

The enclosed patch implements ~r's suggestion.  I revised various cooments.
I have run it through a complete bootstrap and test cycle under hpux 10.20.
There were no regressions observed.  Thus, the mmap MAP_ANONYMOUS support
under hpux appears to work ok for ggc.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2000-07-10  J. David Anglin  <dave@hiauly1.hia.nrc.ca>

	* aclocal.m4 (AC_FUNC_MMAP_ANYWHERE): Extend test to detect systems
	with MAP_ANONYMOUS and MAP_ANON.
	* configure, config.in: Rebuilt.

--- aclocal.m4.orig	Mon Jun 26 12:39:16 2000
+++ aclocal.m4	Mon Jul 10 13:57:32 2000
@@ -684,19 +684,24 @@
 AC_SUBST($1)dnl
 ])
 
-# Check whether mmap can map an arbitrary page from /dev/zero, without
-# MAP_FIXED.
+# Check whether mmap can map an arbitrary page from /dev/zero or with
+# MAP_ANONYMOUS, 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_anywhere,
+AC_CACHE_CHECK(for working mmap which provides zeroed pages anywhere,
+  ac_cv_func_mmap_anywhere,
 [AC_TRY_RUN([
 /* Test by Richard Henderson and Alexandre Oliva.
-   Check whether mmap from /dev/zero works. */
+   Check whether mmap MAP_ANONYMOUS or mmap from /dev/zero works. */
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/mman.h>
 
+#if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+
 /* This mess was copied from the GNU getpagesize.h.  */
 #ifndef HAVE_GETPAGESIZE
 # ifdef HAVE_UNISTD_H
@@ -743,12 +748,19 @@
   char *x;
   int fd, pg;
 
+#ifndef MAP_ANONYMOUS
   fd = open("/dev/zero", O_RDWR);
   if (fd < 0)
     exit(1);
+#endif
 
   pg = getpagesize();
+#ifdef MAP_ANONYMOUS
+  x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE,
+                  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+#else
   x = (char*)mmap(0, pg, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+#endif
   if (x == (char *) -1)
     exit(2);
 
@@ -762,7 +774,7 @@
 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.])
+	    [Define if mmap can get us zeroed pages without MAP_FIXED.])
 fi
 ])
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]