3 #include "tests/sys_mman.h"
5 int main(int argc
, char **argv
)
10 if ( ( p1
= mmap( 0, 4096, PROT_READ
, MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0 ) ) == MAP_FAILED
)
12 perror( "aligned mmap failed" );
16 if ( munmap( p1
, 4096 ) != 0 )
18 perror( "aligned munmap failed" );
22 // This fails because MAP_FIXED is specified and p1+1 isn't page-aligned.
23 // (On Linux, just non-page-alignment is enough for failure, but on Darwin
24 // MAP_FIXED has to also be specified.)
25 if ( ( p2
= mmap( p1
+ 1, 4096, PROT_READ
, MAP_PRIVATE
| MAP_ANONYMOUS
| MAP_FIXED
, -1, 0 ) ) == MAP_FAILED
)
27 perror( "unaligned mmap failed" );
31 if ( munmap( p2
, 4096 ) != 0 )
33 perror( "unaligned munmap failed" );