staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / vm / on-fault-limit.c
blob634d87dfb2a4ef5b1722839315c9abd88a2008f6
1 // SPDX-License-Identifier: GPL-2.0
2 #include <sys/mman.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <sys/time.h>
7 #include <sys/resource.h>
9 #ifndef MCL_ONFAULT
10 #define MCL_ONFAULT (MCL_FUTURE << 1)
11 #endif
13 static int test_limit(void)
15 int ret = 1;
16 struct rlimit lims;
17 void *map;
19 if (getrlimit(RLIMIT_MEMLOCK, &lims)) {
20 perror("getrlimit");
21 return ret;
24 if (mlockall(MCL_ONFAULT | MCL_FUTURE)) {
25 perror("mlockall");
26 return ret;
29 map = mmap(NULL, 2 * lims.rlim_max, PROT_READ | PROT_WRITE,
30 MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE, -1, 0);
31 if (map != MAP_FAILED)
32 printf("mmap should have failed, but didn't\n");
33 else {
34 ret = 0;
35 munmap(map, 2 * lims.rlim_max);
38 munlockall();
39 return ret;
42 int main(int argc, char **argv)
44 int ret = 0;
46 ret += test_limit();
47 return ret;