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