Project

General

Profile

Bug #3785 ยป mmap-test-3785.c

Test case. - Theo Schlossnagle, 2013-05-25 01:53 PM

 
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <sys/mman.h>
4

    
5
#define ITER 1000
6
#define SIZE 1048576
7
static int flags = MAP_PRIVATE|MAP_ANON;
8

    
9
void map32() {
10
  int i;
11
  void *p = 0, *ptrs[ITER] = { 0 };
12
  printf("MAP_32BIT test... ");
13
#ifdef MAP_32BIT
14
  if (sizeof(void *) < 8) {
15
    printf("skipped (32-bit process)\n");
16
  }
17
  else {
18
    for (i=0; i < ITER && p <= (void *)0xffffffff; i++) {
19
      ptrs[i] = p = mmap(0, SIZE, PROT_READ|PROT_WRITE, flags|MAP_32BIT, -1, 0);
20
    }
21
    if(p < (void *)0xffffffff) printf("passed.\n");
22
    else printf("failed.\n");
23
  }
24
#else
25
  printf("skipped (no implementation).\n");
26
#endif
27
}
28

    
29
int main() {
30
  map32();
31
  return 0;
32
}
    (1-1/1)