Statistics
| Branch: | Revision:

root / tests / cris / check_mmap3.c @ dd43edf4

History | View | Annotate | Download (668 Bytes)

1 dd43edf4 ths
/*
2 dd43edf4 ths
#notarget: cris*-*-elf
3 dd43edf4 ths
*/
4 dd43edf4 ths
5 dd43edf4 ths
#define _GNU_SOURCE
6 dd43edf4 ths
#include <string.h>
7 dd43edf4 ths
#include <stdlib.h>
8 dd43edf4 ths
#include <stdio.h>
9 dd43edf4 ths
#include <sys/types.h>
10 dd43edf4 ths
#include <sys/stat.h>
11 dd43edf4 ths
#include <unistd.h>
12 dd43edf4 ths
#include <sys/mman.h>
13 dd43edf4 ths
14 dd43edf4 ths
int main (int argc, char *argv[])
15 dd43edf4 ths
{
16 dd43edf4 ths
  volatile unsigned char *a;
17 dd43edf4 ths
18 dd43edf4 ths
  /* Check that we can map a non-multiple of a page and still get a full page.  */
19 dd43edf4 ths
  a = mmap (NULL, 0x4c, PROT_READ | PROT_WRITE | PROT_EXEC,
20 dd43edf4 ths
            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
21 dd43edf4 ths
  if (a == NULL || a == (unsigned char *) -1)
22 dd43edf4 ths
    abort ();
23 dd43edf4 ths
24 dd43edf4 ths
  a[0] = 0xbe;
25 dd43edf4 ths
  a[8191] = 0xef;
26 dd43edf4 ths
  memset ((char *) a + 1, 0, 8190);
27 dd43edf4 ths
28 dd43edf4 ths
  if (a[0] != 0xbe || a[8191] != 0xef)
29 dd43edf4 ths
    abort ();
30 dd43edf4 ths
31 dd43edf4 ths
  printf ("pass\n");
32 dd43edf4 ths
  exit (0);
33 dd43edf4 ths
}