Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / cris / libc / check_mmap3.c
blobcb890ef12005d31d9da52ef6ff364e75dca704b1
1 /*
2 #notarget: cris*-*-elf
3 */
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>
14 int main (int argc, char *argv[])
16 volatile unsigned char *a;
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 ();
24 a[0] = 0xbe;
25 a[8191] = 0xef;
26 memset ((char *) a + 1, 0, 8190);
28 if (a[0] != 0xbe || a[8191] != 0xef)
29 abort ();
31 printf ("pass\n");
32 exit (0);