This is the mail archive of the
mailing list for the Cygwin project.
Re: mmap() and gcc precompiled headers
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Thu, 3 Jul 2003 11:47:28 +0200
- Subject: Re: mmap() and gcc precompiled headers
- References: <3F034280.firstname.lastname@example.org>
- Reply-to: cygwin at cygwin dot com
On Wed, Jul 02, 2003 at 01:37:20PM -0700, Earl Chew wrote:
> The current implementation does not know anything about the
> Cygwin 64k granularity, and does not use MAP_FIXED because
> MAP_FIXED may have bad side-effects on other implementations.
So it can't rely on getting the mmap at the same location. If it
does, it's a bug in gcc.
> From the FreeBSD man page:
> If addr is non-zero, it is used as a hint to the system. (As a
> convenience to the system, the actual address of the region may
> differ from the address supplied.) If addr is zero, an address will
> be selected by the system.
> I'd like to suggest that the mmap() behaviour in this regard be
> changed to mimic the BSD mmap(). I think this is possible.
The problem is that the addr given to MapViewOfFileEx is not treated
as just a hint by Windows. If the addr is not 64K aligend, the
function fails immediately. If addr is already occupied, it fails.
If there's not enough space to fulfil the memory requirement beginning
at addr, it fails. The bottom line is, Windows doesn't have an
adequate way to "hint" the system to an address. Either it works
exactly as Windows wants it or you're stuck. Therefore, to go out
of any problem, mmap() uses NULL if MAP_FIXED isn't given.
> Are there other reasons why this shouldn't be done?
Somebody must code it.
> This would require changes to mmap64() because addr may not
> be aligned on the allocation granularity.
Do you mean something like this:
If addr is given, check if it's 64K aligned. If not, align and
raise the memory requirement accordingly. Call MapViewOfFileEx
with the aligned address. If it works, return the addr given as
parameter, otherwise return MapViewOfFileEx(NULL).
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:email@example.com
Red Hat, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html