[Fwd] autoconf update for mmap

Russ Allbery rra at stanford.edu
Tue Sep 28 17:48:07 UTC 1999


We may want to look at this for our configure checks; it may detect the
brokenness we're seeing on some platforms.  We're currently checking for
working mmap() and whether read() sees changes made to an mmap()'d region,
but we're not checking the other direction (whether mmap() sees changes
made with write()).

The autoconf code just needs some changequotes applied to it.

-- 
Russ Allbery (rra at stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

------- Start of forwarded message -------
From: jlnance at sailboat.mis.uncwil.edu (James Lewis Nance)
Newsgroups: netscape.public.mozilla.patches,netscape.public.mozilla.unix
Subject: autoconf update for mmap
Date: 28 Sep 1999 12:11:37 GMT

Hello all,
    I am trying to get autoconf to figure out if mmap() and write() play
nicely together.  I have attached a patch that is supposed to do this.
Unfortunatly I do not know how to escape the [] characters in M4, so autoconf
is eating all my arrays :-(  I have tested the C code and it works.  If
someone could either fix my autoconf patch and apply it, or tell me how to
do it I would be most grateful.

Thanks,

Jim

Index: configure.in
===================================================================
RCS file: /cvsroot/mozilla/configure.in,v
retrieving revision 1.504
diff -u -r1.504 configure.in
--- configure.in	1999/09/27 20:47:47	1.504
+++ configure.in	1999/09/28 12:06:16
@@ -1692,6 +1692,50 @@
    MOZ_NATIVE_NSPR=1
 fi
 
+dnl See if mmap sees writes
+dnl ========================================================
+dnl For cross compiling, just define it as no, which is a safe default
+AC_MSG_CHECKING(if mmap() sees write()s)
+AC_TRY_RUN(
+    #include <stdlib.h>
+    #include <unistd.h>
+    #include <sys/mman.h>
+    #include <sys/types.h>
+    #include <sys/stat.h>
+    #include <fcntl.h>
+
+    char fname[] = "conftest.file";
+    char zbuff[1024]; /* Fractional page is probably worst case */
+
+    int main() {
+	char *map;
+	int fd;
+	int i;
+	unlink(fname);
+	fd = open(fname, O_RDWR | O_CREAT, 0660);
+	if(fd<0) return 1;
+	unlink(fname);
+	write(fd, zbuff, sizeof(zbuff));
+	lseek(fd, 0, SEEK_SET);
+	map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
+	if(map==(char*)-1) return 2;
+	for(i=0; fname[i]; i++) {
+	    int rc = write(fd, &fname[i], 1);
+	    if(map[i]!=fname[i]) return 4;
+	}
+	return 0;
+    }
+    , [ result="yes"],
+    [result="no"], 
+    [result="yes"] )
+
+AC_MSG_RESULT("$result")
+
+if test "$result" = "no"; then
+    AC_DEFINE(MMAP_MISSES_WRITES)
+fi
+
+
 dnl Checks for library functions.
 dnl ========================================================
 AC_PROG_GCC_TRADITIONAL
------- End of forwarded message -------


More information about the inn-workers mailing list