mmap() on 64K aligned address fails

Samuel Thibault samuel.thibault@ens-lyon.org
Sat Nov 26 22:10:00 GMT 2005


Hi,

René Berber, le Fri 25 Nov 2005 22:34:26 -0600, a écrit :
> #if !defined(__CYGWIN32__)
>   data2 = (char *) malloc (2 * pagesize);
>   if (!data2) {
>     printf("second malloc failed\n");
>     exit (1);
>   }
>   data2 += (pagesize - ((long) data2 & (pagesize - 1))) & (pagesize - 1);
> #else
>   data2 = (char *) malloc (16 * pagesize);
>   if (!data2) {
>     printf("second malloc failed\n");
>     exit (1);
>   }
>   printf("data2 before is %p\n", data2);
>   data2 += (16*pagesize - ((long) data2 & (16*pagesize - 1))) & (16*pagesize - 1);
>   printf("data2 after  is %p\n", data2);
> #endif

This seems odd. In the cygwin case, pagesize() would not be sufficient ??
And anyway, it should rather be 
   data2 = (char *) malloc (2 * 16 * pagesize);
Not only 16 (since it is further 16*pagesize -aligned).

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