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 11static long 12invoke_syscall(unsigned long epfd, unsigned long op, unsigned long fd, void *ev) 13{ 14 op |= (unsigned long) 0xffffffff00000000ULL; 15 return syscall(__NR_epoll_ctl, epfd, op, fd, (unsigned long) ev); 16} 17 18int 19main(void) 20{ 21 struct epoll_event *const ev = tail_alloc(sizeof(*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 43SKIP_MAIN_UNDEFINED("__NR_epoll_ctl") 44 45#endif 46