Fei Jie | b45a1e7 | 2016-04-27 16:54:19 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #if defined __NR_mlock && defined __NR_munlock |
| 5 | |
| 6 | # include <stdio.h> |
| 7 | # include <unistd.h> |
| 8 | |
| 9 | const int size = 1024; |
| 10 | |
| 11 | int |
| 12 | main(void) |
| 13 | { |
| 14 | const char *addr = tail_alloc(size); |
| 15 | if (syscall(__NR_mlock, addr, size) == 0) { |
| 16 | printf("mlock(%p, %d) = 0\n", addr, size); |
| 17 | } else { |
| 18 | printf("mlock(%p, %d) = -1 %s (%m)\n", |
| 19 | addr, size, errno2name()); |
| 20 | } |
| 21 | |
| 22 | if (syscall(__NR_munlock, addr, size) == 0) { |
| 23 | printf("munlock(%p, %d) = 0\n", addr, size); |
| 24 | } else { |
| 25 | printf("munlock(%p, %d) = -1 %s (%m)\n", |
| 26 | addr, size, errno2name()); |
| 27 | } |
| 28 | |
| 29 | puts("+++ exited with 0 +++"); |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | #else |
| 34 | |
| 35 | SKIP_MAIN_DEFINED("__NR_mlock && __NR_munlock") |
| 36 | |
| 37 | #endif |