fixincl mmap problem on Solaris
Jamie Lokier
egcs@tantalophile.demon.co.uk
Wed Sep 6 12:26:00 GMT 2000
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
More information about the Gcc
mailing list