]> granicus.if.org Git - strace/blob - tests/epoll_ctl.c
Assume that sys/epoll.h exists
[strace] / tests / epoll_ctl.c
1 #include "tests.h"
2 #include <sys/syscall.h>
3
4 #ifdef __NR_epoll_ctl
5
6 # include <inttypes.h>
7 # include <stdio.h>
8 # include <sys/epoll.h>
9 # include <unistd.h>
10
11 int
12 main(void)
13 {
14         struct epoll_event *const ev = tail_alloc(sizeof(*ev));
15         ev->events = EPOLLIN;
16
17         long rc = syscall(__NR_epoll_ctl, -1, EPOLL_CTL_ADD, -2, ev);
18         printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
19                " {u32=%u, u64=%" PRIu64 "}}) = %ld %s (%m)\n",
20                ev->data.u32, ev->data.u64, rc, errno2name());
21
22         rc = syscall(__NR_epoll_ctl, -3, EPOLL_CTL_DEL, -4, ev);
23         printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %ld %s (%m)\n",
24                ev, rc, errno2name());
25
26         rc = syscall(__NR_epoll_ctl, -1L, EPOLL_CTL_MOD, -16L, 0);
27         printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %ld %s (%m)\n",
28                rc, errno2name());
29
30         puts("+++ exited with 0 +++");
31         return 0;
32 }
33
34 #else
35
36 SKIP_MAIN_UNDEFINED("__NR_epoll_ctl")
37
38 #endif