X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: =?ISO-8859-1?Q?Ren=E9_Berber?= Subject: Re: mmap() on 64K aligned address fails Date: Sat, 26 Nov 2005 16:52:17 -0600 Lines: 50 Message-ID: References: <20051126180331 DOT GI5074 AT bouh DOT residence DOT ens-lyon DOT fr> <20051126214701 DOT GW5074 AT bouh DOT residence DOT ens-lyon DOT fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) In-Reply-To: <20051126214701.GW5074@bouh.residence.ens-lyon.fr> OpenPGP: url=ldap://keyserver.pgp.com X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: 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 Samuel Thibault wrote: [snip] >>No, in windows there is a requirement that mmap uses memory aligned to 64= k (the >>infamous granularity). >=20 > Then the result of pagesize() is not sufficiently big: POSIX says that > mmap() can return EINVAL if =AB the address [...] is not a multiple of > the page size, or is considered invalid by the implementation =BB. Well, > we could consider non-16-pages-alignment as `considered invalid', but I > guess this expression was meant as `not in a mmap()-able area'. mmap() is returning an error code, probably EINVAL I just ddisn't care to l= ook what was it because there shouldn't be an error. [snip] > 16 pages > are still not enough: if malloc() returns 0x0001 for instance, you'll > round up that to 16*pagesize, which is out the allocated area. 17 pages > are necessary. Yes, that would produce an error... not the one you are saying but the "ali= gned" result will fall at the end with less than a pagesize available for mmap. > BTW, I don't understand why using so complicated code: > p +=3D (align - ((long) p & (align-1))) & (align-1) > Isn't > p =3D ((long) p + (align-1)) & (align-1) > both faster (tested) and more readable ? I didn't write the original code, it is from gcc-4.0.2 and it's used all ov= er the place to make libraries (libstdc, libgcj, perhaps others) and tools. T= here are other mmap() tests that fail (mmap from /dev/zero, mmap with MAP_ANON) = I'm just starting to look around to see what is the problem, and perhaps send a patch to the gcc maintainers so we can have a fully functional set of libra= ries. Regards. --=20 Ren=E9 Berber -- 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/