blob: b636a7d45064064b08533f37f91e70f8d60e86f4 [file] [log] [blame]
Fei Jie258a2252016-04-08 15:59:15 +08001#include "tests.h"
2#include <sys/syscall.h>
3
4#if defined __NR_epoll_ctl && defined HAVE_SYS_EPOLL_H
5
6# include <errno.h>
7# include <inttypes.h>
8# include <stdio.h>
9# include <sys/epoll.h>
10# include <unistd.h>
11
12int
13main(void)
14{
15 struct epoll_event *const ev = tail_alloc(sizeof(*ev));
16 ev->events = EPOLLIN;
17
18 int rc = syscall(__NR_epoll_ctl, -1, EPOLL_CTL_ADD, -2, ev);
19 printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
20 " {u32=%u, u64=%" PRIu64 "}}) = %d %s (%m)\n",
21 ev->data.u32, ev->data.u64, rc,
Dmitry V. Levin9f6611b2016-04-21 17:49:32 +000022 errno2name());
Fei Jie258a2252016-04-08 15:59:15 +080023
Dmitry V. Levin2399a602016-04-10 22:38:00 +000024 rc = syscall(__NR_epoll_ctl, -3, EPOLL_CTL_DEL, -4, ev);
25 printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %d %s (%m)\n",
Dmitry V. Levin9f6611b2016-04-21 17:49:32 +000026 ev, rc, errno2name());
Dmitry V. Levin2399a602016-04-10 22:38:00 +000027
28 rc = syscall(__NR_epoll_ctl, -1L, EPOLL_CTL_MOD, -16L, 0);
29 printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %d %s (%m)\n",
Dmitry V. Levin9f6611b2016-04-21 17:49:32 +000030 rc, errno2name());
Dmitry V. Levin2399a602016-04-10 22:38:00 +000031
Fei Jie258a2252016-04-08 15:59:15 +080032 puts("+++ exited with 0 +++");
33 return 0;
34}
35
36#else
37
38SKIP_MAIN_UNDEFINED("__NR_epoll_ctl && HAVE_SYS_EPOLL_H")
39
40#endif