mmap() on 64K aligned address fails

Samuel Thibault samuel.thibault@ens-lyon.org
Mon Nov 28 18:16:00 GMT 2005


Hi,

Sam Steingold, le Mon 28 Nov 2005 09:55:52 -0500, a écrit :
> | #define my_shift 24
> | #define my_low   1
> | #ifdef FOR_SUN4_29
> | #define my_high  31
> | #define my_size  32768 /* hope that 32768 is a multiple of the page size */
> | /* i*32 KB for i=1..31 gives a total of 15.5 MB, which is close to what we need */
> | #else
> | #define my_high  64
> | #define my_size  8192 /* hope that 8192 is a multiple of the page size */
> | /* i*8 KB for i=1..64 gives a total of 16.25 MB, which is close to what we need */
> | #endif
>...
> |       { caddr_t addr = (caddr_t)(i << my_shift);
> | /* Check for 8 MB, not 16 MB. This is more likely to work on Solaris 2. */
> | #if bits_to_avoid
> |         long size = i*my_size;
> | #else
> |         long size = ((i+1)/2)*my_size;
> | #endif
> |         if (mmap(addr,size,PROT_READ|PROT_WRITE,flags|MAP_FIXED,fd,0) == (void*)-1) exit(1);

This test is just so strange... How can this ever work on many systems ?
A system is free to refuse to mmap anything in the 0x1000000 area...

Can't this test just be turned into mmaping 16MB (not fixed), unmap()
it, and then, from this address, try to mmap pagesize() ? (instead of
obviously wrong 8KB guess...)

Regards,
Samuel

--
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/



More information about the Cygwin mailing list