Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / vm / mmap-overlap.c
1 #include <stdio.h>
2 #include <string.h>
3 #ifdef PINTOS
4 #include <syscall.h>
5 #else
6 #include "posix-compat.h"
7 #endif
8 #include "sample.inc"
9
10 int
11 main (void) 
12 {
13   char *start = (char *) 0x10000000;
14   size_t i;
15   int fd[2];
16
17 #ifndef PINTOS
18   printf ("Sorry, this test won't work on POSIX,\n"
19           "because POSIX will accept overlapping mmaps.\n");
20   abort ();
21 #endif
22
23   printf ("(mmap-overlap) begin\n");
24
25   for (i = 0; i < 2; i++) 
26     {
27       fd[i] = open ("zeros");
28       if (fd[i] < 0) 
29         {
30           printf ("(mmap-overlap) open() failed\n");
31           return 1;
32         }
33       if (mmap (fd[i], start) == MAP_FAILED)
34         {
35           if (i == 1) 
36             return 0;
37           else
38             {
39               printf ("(mmap-overlap) mmap() failed\n");
40               return 1; 
41             }
42         }
43       start += 4096;
44     }
45
46   printf ("(mmap-overlap) fail: mmap of overlapped blocks succeeded\n");
47
48   /* Done. */
49   printf ("(mmap-overlap) end\n");
50
51   return 0;
52 }