drd/tests/std_thread2: Make this test independent of the libstdc++ version
[valgrind.git] / none / tests / map_unaligned.c
blobe09fea6f719576d1f8fb83163a8fe698b434cc59
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "tests/sys_mman.h"
5 int main(int argc, char **argv)
7 void *p1;
8 void *p2;
10 if ( ( p1 = mmap( 0, 4096, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0 ) ) == MAP_FAILED )
12 perror( "aligned mmap failed" );
13 exit( 1 );
16 if ( munmap( p1, 4096 ) != 0 )
18 perror( "aligned munmap failed" );
19 exit( 1 );
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" );
28 exit( 1 );
31 if ( munmap( p2, 4096 ) != 0 )
33 perror( "unaligned munmap failed" );
34 exit( 1 );
37 exit( 0 );