blob: 13ca3b69b009cb8beb1f8d6f3f392c6c8f0b464b [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
Dmitry V. Levinbecfc0e2016-04-21 20:37:50 +000018 long rc = syscall(__NR_epoll_ctl, -1, EPOLL_CTL_ADD, -2, ev);
Fei Jie258a2252016-04-08 15:59:15 +080019 printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
Dmitry V. Levinbecfc0e2016-04-21 20:37:50 +000020 " {u32=%u, u64=%" PRIu64 "}}) = %ld %s (%m)\n",
21 ev->data.u32, ev->data.u64, rc, errno2name());
Fei Jie258a2252016-04-08 15:59:15 +080022
Dmitry V. Levin2399a602016-04-10 22:38:00 +000023 rc = syscall(__NR_epoll_ctl, -3, EPOLL_CTL_DEL, -4, ev);
Dmitry V. Levinbecfc0e2016-04-21 20:37:50 +000024 printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %ld %s (%m)\n",
Dmitry V. Levin9f6611b2016-04-21 17:49:32 +000025 ev, rc, errno2name());
Dmitry V. Levin2399a602016-04-10 22:38:00 +000026
27 rc = syscall(__NR_epoll_ctl, -1L, EPOLL_CTL_MOD, -16L, 0);
Dmitry V. Levinbecfc0e2016-04-21 20:37:50 +000028 printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %ld %s (%m)\n",
Dmitry V. Levin9f6611b2016-04-21 17:49:32 +000029 rc, errno2name());
Dmitry V. Levin2399a602016-04-10 22:38:00 +000030
Fei Jie258a2252016-04-08 15:59:15 +080031 puts("+++ exited with 0 +++");
32 return 0;
33}
34
35#else
36
37SKIP_MAIN_UNDEFINED("__NR_epoll_ctl && HAVE_SYS_EPOLL_H")
38
39#endif