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: fixincl mmap problem on Solaris


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



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