blob: a56dc1f4bfb765fe082d9d800a9840554d3300b3 [file] [log] [blame]
Fei Jieb45a1e72016-04-27 16:54:19 +08001#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
9const int size = 1024;
10
11int
12main(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
35SKIP_MAIN_DEFINED("__NR_mlock && __NR_munlock")
36
37#endif