[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Check for `mmap' fails on Cygwin/Windows
From: |
Corinna Vinschen |
Subject: |
Check for `mmap' fails on Cygwin/Windows |
Date: |
Wed, 25 Oct 2000 11:38:40 +0200 |
When running configure on a Cygwin system, the check for `mmap()'
fails for the following reason:
Windows doesn't support the mmap flags MAP_FIXED the same way
Unix/Linux does. The returned address may be different from the
given address as well as it may fail if the address is in a mem
range already allocated by the calling process.
The reason I think it's a bug in autoconf, though, is that the
usage of MAP_FIXED is discouraged which is documented in the Linux
man pages as well as in SUSv2 documentation:
"Use of MAP_FIXED may result in unspecified behaviour in further
use of brk(), sbrk(), malloc() and shmat(). The use of MAP_FIXED is
discouraged, as it may prevent an implementation from making the
most effective use of resources."
I have attached a patch to acfunctions.m4 which will result in a
working check for `mmap()' on all systems.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:address@hidden
Red Hat, Inc.
mailto:address@hidden
Index: acfunctions.m4
===================================================================
RCS file: /cvs/autoconf/acfunctions.m4,v
retrieving revision 1.9
diff -u -p -r1.9 acfunctions.m4
--- acfunctions.m4 2000/09/28 14:26:50 1.9
+++ acfunctions.m4 2000/10/05 09:17:26
@@ -1033,12 +1033,8 @@ main ()
fd = open ("conftestmmap", O_RDWR);
if (fd < 0)
exit (1);
- data2 = (char *) malloc (2 * pagesize);
- if (!data2)
- exit (1);
- data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
- if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ if ((data2 = mmap (NULL, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE, fd, 0L)) == MAP_FAILED)
exit (1);
for (i = 0; i < pagesize; ++i)
if (*(data + i) != *(data2 + i))
- Check for `mmap' fails on Cygwin/Windows,
Corinna Vinschen <=