Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3F034280.6070908@agilent.com> Date: Wed, 02 Jul 2003 13:37:20 -0700 From: Earl Chew Organization: Agilent Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: mmap() and gcc precompiled headers Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I've been trying to get the new gcc PCH code working on Cygwin. The gcc PCH implementation works by using mmap() to quickly resurrect the precompiled header when compiling on a new file. To allow this to be done quickly, mmap() is used when creating the precompiled header and the precompiled information is relocated to the area returned by mmap(). When saving, mmap() is called like this: mmi.preferred_base = mmap (NULL, mmi.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno (state.f), mmi.offset); When restoring the precompiled header, mmap() must return the same memory address, otherwise the scheme fails. When restoring, mmap() is called like this: addr = mmap (mmi.preferred_base, mmi.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno (f), mmi.offset); 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. My question relates to fhandler_diskfile::mmap() in mmap.cc. This method calls MapViewOfFileEx() to create the mapping like this: void *base = MapViewofFileEx(h, access, high, low, len, (flags & MAP_FIXED) ? *addr : NULL); In other words, the lpBaseAddress parameter is NULL (ie allow Win32 to choose) unless MAP_FIXED is used -- and gcc does not use MAP_FIXED. Despite this, the two mmap() calls in gcc currently yield the same base address --- I suppose more by good fortune than anything else. 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. Are there other reasons why this shouldn't be done? This would require changes to mmap64() because addr may not be aligned on the allocation granularity. Earl -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/