This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fixincl mmap problem on Solaris
- To: Zack Weinberg <zack at wolery dot cumb dot org>
- Subject: Re: fixincl mmap problem on Solaris
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Date: Wed, 6 Sep 2000 21:26:29 +0200
- Cc: Bruce Korb <bkorb at sco dot COM>, Graham Stott <grahams at redhat dot com>, bkorb at gnu dot org, GNU Compiler <gcc at gcc dot gnu dot org>
- References: <39B4DB2D.8EFE0C77@redhat.com> <39B51A2A.7F88605F@sco.com> <20000905092607.G295@wolery.cumb.org>
Zack Weinberg wrote:
> My suggestion would be to notice when the file size is an exact
> multiple of the page size, and map a page of /dev/zero right after it
> using MAP_FIXED. If that fails, punt and read the file with read(2).
Don't do that. The fixed /dev/zero mapping can land on top of another
mapping say from malloc(). It would silently clobber the other mapping.
Instead, if the file size warrants it, first map /dev/zero for the
number of files in the page + 1 (without MAP_FIXED), and than MAP_FIXED
the file _over_ the /dev/zero mapping.
Does anyone know of an mmap implementation where this does not work?
thanks,
-- Jamie