• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "tests/sys_mman.h"
4 
main(int argc,char ** argv)5 int main(int argc, char **argv)
6 {
7    void *a1;
8 
9    if ((a1 = mmap((void *)0x200000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0)) == MAP_FAILED)
10    {
11       perror("mmap1");
12       exit(1);
13    }
14 
15    if (munmap(a1, 4096) < 0)
16    {
17       perror("munmap1");
18       exit(1);
19    }
20 
21    if (mmap((void *)0x100000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) == MAP_FAILED)
22    {
23       perror("mmap2");
24       exit(1);
25    }
26 
27    if (mmap((void *)0x100000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) == MAP_FAILED)
28    {
29       perror("mmap2");
30       exit(1);
31    }
32 
33    printf("success\n");
34    exit(0);
35 }
36