thermal: use %d to print S32 parameters
[linux/fpc-iii.git] / tools / testing / selftests / vm / on-fault-limit.c
blob245acccce42d8e2b64842451f75a058ba499562f
1 #include <sys/mman.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <sys/time.h>
6 #include <sys/resource.h>
8 #ifndef MCL_ONFAULT
9 #define MCL_ONFAULT (MCL_FUTURE << 1)
10 #endif
12 static int test_limit(void)
14 int ret = 1;
15 struct rlimit lims;
16 void *map;
18 if (getrlimit(RLIMIT_MEMLOCK, &lims)) {
19 perror("getrlimit");
20 return ret;
23 if (mlockall(MCL_CURRENT | MCL_ONFAULT | MCL_FUTURE)) {
24 perror("mlockall");
25 return ret;
28 map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE,
29 MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, 0, 0);
30 if (map != MAP_FAILED)
31 printf("mmap should have failed, but didn't\n");
32 else {
33 ret = 0;
34 munmap(map, 2 * lims.rlim_max);
37 munlockall();
38 return ret;
41 int main(int argc, char **argv)
43 int ret = 0;
45 ret += test_limit();
46 return ret;