1 #include "tests.h"
2 #include <asm/unistd.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 static long
invoke_syscall(unsigned long epfd,unsigned long op,unsigned long fd,void * ev)12 invoke_syscall(unsigned long epfd, unsigned long op, unsigned long fd, void *ev)
13 {
14 return syscall(__NR_epoll_ctl, epfd, F8ILL_KULONG_MASK | op,
15 fd, (unsigned long) ev);
16 }
17
18 int
main(void)19 main(void)
20 {
21 TAIL_ALLOC_OBJECT_CONST_PTR(struct epoll_event, ev);
22 ev->events = EPOLLIN;
23
24 long rc = invoke_syscall(-1U, EPOLL_CTL_ADD, -2U, ev);
25 printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
26 " {u32=%u, u64=%" PRIu64 "}}) = %ld %s (%m)\n",
27 ev->data.u32, ev->data.u64, rc, errno2name());
28
29 rc = invoke_syscall(-3U, EPOLL_CTL_DEL, -4U, ev);
30 printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %ld %s (%m)\n",
31 ev, rc, errno2name());
32
33 rc = invoke_syscall(-1UL, EPOLL_CTL_MOD, -16UL, 0);
34 printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %ld %s (%m)\n",
35 rc, errno2name());
36
37 puts("+++ exited with 0 +++");
38 return 0;
39 }
40
41 #else
42
43 SKIP_MAIN_UNDEFINED("__NR_epoll_ctl")
44
45 #endif
46