1 /* 2 * This file is in public domain. 3 * Written by Konstantin Belousov <kib@freebsd.org> 4 * 5 * $FreeBSD$ 6 */ 7 8 #include <sys/mman.h> 9 #include <err.h> 10 #include <stdlib.h> 11 #include <stdint.h> 12 #include <stdio.h> 13 #include <unistd.h> 14 15 static void 16 test_pagesizes(void) 17 { 18 size_t *ps; 19 int i, nelem; 20 21 nelem = getpagesizes(NULL, 0); 22 if (nelem == -1) 23 err(1, "getpagesizes(NULL, 0)"); 24 ps = malloc(nelem * sizeof(size_t)); 25 if (ps == NULL) 26 err(1, "malloc"); 27 nelem = getpagesizes(ps, nelem); 28 if (nelem == -1) 29 err(1, "getpagesizes"); 30 printf("Supported page sizes:"); 31 for (i = 0; i < nelem; i++) 32 printf(" %jd", (intmax_t)ps[i]); 33 printf("\n"); 34 } 35 36 static void 37 test_pagesize(void) 38 { 39 40 printf("Pagesize: %d\n", getpagesize()); 41 } 42 43 static void 44 test_osreldate(void) 45 { 46 47 printf("OSRELDATE: %d\n", getosreldate()); 48 } 49 50 int 51 main(int argc __unused, char *argv[] __unused) 52 { 53 54 test_pagesizes(); 55 test_pagesize(); 56 test_osreldate(); 57 return (0); 58 } 59