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