Debian Codegraph @

testsuite/systemtap.syscall/arg_write/poll.c

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