1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
/* COVERAGE: epoll_create epoll_create1 epoll_ctl epoll_wait epoll_pwait */
/* COVERAGE: poll ppoll */
#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <poll.h>
#include <signal.h>
#include <sys/syscall.h>
#ifdef SYS_epoll_pwait
int __epoll_pwait(int epfd, struct epoll_event *events, int maxevents, int timeout,
sigset_t *set)
{
return syscall(__NR_epoll_pwait,
++epfd,
(struct epoll_events *)((char *)events - 1),
++maxevents,
--timeout,
(sigset_t *)((char *)set + 1),
_NSIG / 8 - 1);
}
#endif
#ifdef EPOLL_CLOEXEC
int _epoll_create1(int flags)
{
return epoll_create1(flags - 1);
}
#else
int _epoll_create(int size)
{
return epoll_create(size + 1);
}
#endif
int _epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) {
return epoll_ctl(--epfd, ++op, --fd, (struct epoll_event *)((char *)event - 1));
}
int _epoll_wait(int epfd, struct epoll_event *events, int maxevents,
int timeout)
{
return epoll_wait(++epfd, (struct epoll_event *)((char *)events - 1), ++maxevents, --timeout);
}
int _poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
return poll((struct pollfd *)((char *)fds + 1), --nfds, ++timeout);
}
#ifdef SYS_ppoll
int _ppoll(struct pollfd *fds, nfds_t nfds, struct timespec *tmo_p, sigset_t *sigmask)
{
return ppoll((struct pollfd *)((char *)fds + 1), --nfds, (struct timespec *)((char *)tmo_p + 1),
(sigset_t *)((char *)sigmask - 1));
}
#endif
int main()
{
struct epoll_event ev, events[17];
struct pollfd pfd = {7, 0x23, 0};
int fd;
// struct timespec tim = {.tv_sec=0, .tv_nsec=200000000};
struct timespec tim = {.tv_sec=0, .tv_nsec=0};
sigset_t sigs;
sigemptyset(&sigs);
sigaddset(&sigs,SIGUSR2);
#ifdef EPOLL_CLOEXEC
fd = _epoll_create1(EPOLL_CLOEXEC);
//staptest// epoll_create1 (EPOLL_CLOEXEC) = NNNN
_epoll_create1(-1);
//staptest// epoll_create1 (EPOLL_CLOEXEC|0xfff7ffff) = -NNNN (EINVAL)
#else
fd = _epoll_create(32);
//staptest// epoll_create (32) = NNNN
_epoll_create(-1);
//staptest// epoll_create (-1) = -NNNN (EINVAL)
#endif
_epoll_ctl(fd, EPOLL_CTL_ADD, 13, &ev);
//staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, XXXX) = -NNNN (EBADF)
_epoll_ctl(-1, EPOLL_CTL_ADD, 13, &ev);
//staptest// epoll_ctl (-1, EPOLL_CTL_ADD, 13, XXXX) = -NNNN (EBADF)
_epoll_ctl(fd, -1, 13, &ev);
//staptest// epoll_ctl (NNNN, 0xffffffff, 13, XXXX) = -NNNN (EBADF)
_epoll_ctl(fd, EPOLL_CTL_ADD, -1, &ev);
//staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, -1, XXXX) = -NNNN (EBADF)
_epoll_ctl(fd, EPOLL_CTL_ADD, 13, (struct epoll_event *)-1);
#ifdef __s390__
//staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, 0x[7]?[f]+) = -NNNN (EFAULT)
#else
//staptest// epoll_ctl (NNNN, EPOLL_CTL_ADD, 13, 0x[f]+) = -NNNN (EFAULT)
#endif
__epoll_pwait(fd, events, 17, 0, NULL);
// epoll_wait() can be implemented in terms of epoll_pwait()
//staptest// [[[[epoll_wait (NNNN, XXXX, 17, 0)!!!!epoll_pwait (NNNN, XXXX, 17, 0, XXXX, NNNN)]]]] = 0
__epoll_pwait(-1, events, 17, 0, NULL);
//staptest// [[[[epoll_wait (-1, XXXX, 17, 0)!!!!epoll_pwait (-1, XXXX, 17, 0, XXXX, NNNN)]]]] = -NNNN (EBADF)
__epoll_pwait(fd, (struct epoll_event *)-1, 17, 0, NULL);
#ifdef __s390__
//staptest// [[[[epoll_wait (NNNN, 0x[7]?[f]+, 17, 0)!!!!epoll_pwait (NNNN, 0x[7]?[f]+, 17, 0, XXXX, NNNN)]]]] = NNNN
#else
//staptest// [[[[epoll_wait (NNNN, 0x[f]+, 17, 0)!!!!epoll_pwait (NNNN, 0x[f]+, 17, 0, XXXX, NNNN)]]]] = NNNN
#endif
__epoll_pwait(fd, events, -1, 0, NULL);
//staptest// [[[[epoll_wait (NNNN, XXXX, -1, 0)!!!!epoll_pwait (NNNN, XXXX, -1, 0, XXXX, NNNN)]]]] = NNNN (EINVAL)
__epoll_pwait(-1, events, 17, -1, NULL);
//staptest// [[[[epoll_wait (-1, XXXX, 17, -1)!!!!epoll_pwait (-1, XXXX, 17, -1, XXXX, NNNN)]]]] = NNNN (EBADF)
// RHEL5 x86_64 defines SYS_epoll_pwait, but doesn't have epoll_pwait()
#ifdef SYS_epoll_pwait
__epoll_pwait(fd, events, 17, 0, NULL);
//staptest// [[[[epoll_pwait (NNNN, XXXX, 17, 0, 0x0, NNNN) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]]
__epoll_pwait(fd, events, 17, 0, &sigs);
//staptest// [[[[epoll_pwait (NNNN, XXXX, 17, 0, XXXX, NNNN) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]]
__epoll_pwait(-1, events, 17, 0, &sigs);
//staptest// [[[[epoll_pwait (-1, XXXX, 17, 0, XXXX, NNNN) = -NNNN (EBADF)!!!!ni_syscall () = -38 (ENOSYS)]]]]
__epoll_pwait(fd, (struct epoll_event *)-1, 17, 0, &sigs);
#ifdef __s390__
//staptest// epoll_pwait (NNNN, 0x[7]?[f]+, 17, 0, XXXX, NNNN) =
#else
//staptest// [[[[epoll_pwait (NNNN, 0x[f]+, 17, 0, XXXX, NNNN) =!!!!ni_syscall () = -38 (ENOSYS)]]]]
#endif
__epoll_pwait(fd, events, -1, 0, &sigs);
//staptest// [[[[epoll_pwait (NNNN, XXXX, -1, 0, XXXX, NNNN) = -NNNN (EINVAL)!!!!ni_syscall () = -38 (ENOSYS)]]]]
__epoll_pwait(-1, events, 17, -1, &sigs);
//staptest// [[[[epoll_pwait (-1, XXXX, 17, -1, XXXX, NNNN) = -NNNN (EBADF)!!!!ni_syscall () = -38 (ENOSYS)]]]]
__epoll_pwait(fd, events, 17, 0, (sigset_t *)-1);
#ifdef __s390__
//staptest// epoll_pwait (NNNN, XXXX, 17, 0, 0x[7]?[f]+, NNNN) = -NNNN (EFAULT)
#else
//staptest// [[[[epoll_pwait (NNNN, XXXX, 17, 0, 0x[f]+, NNNN) = -NNNN (EFAULT)!!!!ni_syscall () = -38 (ENOSYS)]]]]
#endif
#endif
close(fd);
//staptest// close (NNNN) = 0
_poll(&pfd, 1, 0);
#if defined(__aarch64__)
//staptest// ppoll (XXXX, 1, NULL!!!!\[0.000000000\], XXXX, NNNN) = NNNN
#else
//staptest// poll (XXXX, 1, 0) = NNNN
#endif
_poll((struct pollfd *)-1, 1, 0);
#ifdef __s390__
//staptest// poll (0x[7]?[f]+, 1, 0) = -NNNN (EFAULT)
#elif defined(__aarch64__)
//staptest// ppoll (0x[f]+, 1, NULL!!!!\[0.000000000\], XXXX, NNNN) = -NNNN (EFAULT)
#else
//staptest// poll (0x[f]+, 1, 0) = -NNNN (EFAULT)
#endif
_poll(&pfd, -1, 0);
#if defined(__aarch64__)
//staptest// ppoll (XXXX, 4294967295!!!!18446744073709551615, NULL!!!!\[0.000000000\], XXXX, NNNN) = -NNNN (EINVAL)
#else
//staptest// poll (XXXX, 4294967295!!!!18446744073709551615, 0) = -NNNN (EINVAL)
#endif
// A timetout value of -1 means an infinite timeout. So, we'll also
// send a NULL pollfd structure pointer.
_poll(NULL, 1, -1);
#if defined(__aarch64__)
//staptest// ppoll (0x0, 1, NULL!!!!\[0.000000000\] XXXX, NNNN) = -NNNN (EFAULT)
#else
//staptest// poll (0x0, 1, -1) = -NNNN (EFAULT)
#endif
return 0;
}
|