2016-04-08 15:59:15 +08:00
# include "tests.h"
# include <sys/syscall.h>
2016-05-09 21:46:17 +00:00
# ifdef __NR_epoll_ctl
2016-04-08 15:59:15 +08:00
# include <inttypes.h>
# include <stdio.h>
# include <sys / epoll.h>
# include <unistd.h>
2016-05-16 21:43:35 +00:00
static long
invoke_syscall ( unsigned long epfd , unsigned long op , unsigned long fd , void * ev )
{
op | = ( unsigned long ) 0xffffffff00000000 ;
return syscall ( __NR_epoll_ctl , epfd , op , fd , ( unsigned long ) ev ) ;
}
2016-04-08 15:59:15 +08:00
int
main ( void )
{
struct epoll_event * const ev = tail_alloc ( sizeof ( * ev ) ) ;
ev - > events = EPOLLIN ;
2016-05-16 21:43:35 +00:00
long rc = invoke_syscall ( - 1U , EPOLL_CTL_ADD , - 2U , ev ) ;
2016-04-08 15:59:15 +08:00
printf ( " epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN, "
2016-04-21 20:37:50 +00:00
" {u32=%u, u64=% " PRIu64 " }}) = %ld %s (%m) \n " ,
ev - > data . u32 , ev - > data . u64 , rc , errno2name ( ) ) ;
2016-04-08 15:59:15 +08:00
2016-05-16 21:43:35 +00:00
rc = invoke_syscall ( - 3U , EPOLL_CTL_DEL , - 4U , ev ) ;
2016-04-21 20:37:50 +00:00
printf ( " epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %ld %s (%m) \n " ,
2016-04-21 17:49:32 +00:00
ev , rc , errno2name ( ) ) ;
2016-04-10 22:38:00 +00:00
2016-05-16 21:43:35 +00:00
rc = invoke_syscall ( - 1UL , EPOLL_CTL_MOD , - 16UL , 0 ) ;
2016-04-21 20:37:50 +00:00
printf ( " epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %ld %s (%m) \n " ,
2016-04-21 17:49:32 +00:00
rc , errno2name ( ) ) ;
2016-04-10 22:38:00 +00:00
2016-04-08 15:59:15 +08:00
puts ( " +++ exited with 0 +++ " ) ;
return 0 ;
}
# else
2016-05-09 21:46:17 +00:00
SKIP_MAIN_UNDEFINED ( " __NR_epoll_ctl " )
2016-04-08 15:59:15 +08:00
# endif