1 #include <stdio.h>
2 #include "tests/sys_mman.h"
3 #include <stdlib.h>
4 #include <unistd.h>
5
main()6 int main()
7 {
8
9 void *first = NULL;
10 void *last;
11 void *res;
12
13 while (1) {
14 res = mmap (NULL, 64 * 1024,
15 PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_32BIT,
16 -1, 0);
17 if (first == NULL) {
18 first = res;
19 if (first == (void *)-1) {
20 perror ("first mmap");
21 exit (1);
22 }
23 fprintf(stderr, "first mmap : %p\n", first);
24 }
25 if (res == (void *)-1) {
26 fprintf(stderr, "last mmap ok: %p\n", last);
27 break;
28 }
29 last = res;
30 }
31
32 /* And now, retry without MAP_32BIT */
33 res = mmap (NULL, 64 * 1024,
34 PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
35 -1, 0);
36 if (res == (void *)-1) {
37 perror ("retry mmap");
38 exit (1);
39 }
40 fprintf(stderr, "retry mmap ok: %p\n", res);
41
42 return 0;
43 }
44