6 #include <sys/resource.h>
9 #define MCL_ONFAULT (MCL_FUTURE << 1)
12 static int test_limit(void)
18 if (getrlimit(RLIMIT_MEMLOCK
, &lims
)) {
23 if (mlockall(MCL_CURRENT
| MCL_ONFAULT
| MCL_FUTURE
)) {
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");
34 munmap(map
, 2 * lims
.rlim_max
);
41 int main(int argc
, char **argv
)