1*cf84ac9aSAndroid Build Coastguard Worker /*
2*cf84ac9aSAndroid Build Coastguard Worker * Check decoding of poll syscall.
3*cf84ac9aSAndroid Build Coastguard Worker *
4*cf84ac9aSAndroid Build Coastguard Worker * Copyright (c) 2016-2018 Dmitry V. Levin <[email protected]>
5*cf84ac9aSAndroid Build Coastguard Worker * All rights reserved.
6*cf84ac9aSAndroid Build Coastguard Worker *
7*cf84ac9aSAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without
8*cf84ac9aSAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions
9*cf84ac9aSAndroid Build Coastguard Worker * are met:
10*cf84ac9aSAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright
11*cf84ac9aSAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer.
12*cf84ac9aSAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright
13*cf84ac9aSAndroid Build Coastguard Worker * notice, this list of conditions and the following disclaimer in the
14*cf84ac9aSAndroid Build Coastguard Worker * documentation and/or other materials provided with the distribution.
15*cf84ac9aSAndroid Build Coastguard Worker * 3. The name of the author may not be used to endorse or promote products
16*cf84ac9aSAndroid Build Coastguard Worker * derived from this software without specific prior written permission.
17*cf84ac9aSAndroid Build Coastguard Worker *
18*cf84ac9aSAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19*cf84ac9aSAndroid Build Coastguard Worker * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20*cf84ac9aSAndroid Build Coastguard Worker * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21*cf84ac9aSAndroid Build Coastguard Worker * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22*cf84ac9aSAndroid Build Coastguard Worker * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23*cf84ac9aSAndroid Build Coastguard Worker * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24*cf84ac9aSAndroid Build Coastguard Worker * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25*cf84ac9aSAndroid Build Coastguard Worker * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26*cf84ac9aSAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27*cf84ac9aSAndroid Build Coastguard Worker * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*cf84ac9aSAndroid Build Coastguard Worker */
29*cf84ac9aSAndroid Build Coastguard Worker
30*cf84ac9aSAndroid Build Coastguard Worker #include "tests.h"
31*cf84ac9aSAndroid Build Coastguard Worker #include <asm/unistd.h>
32*cf84ac9aSAndroid Build Coastguard Worker
33*cf84ac9aSAndroid Build Coastguard Worker #ifdef __NR_poll
34*cf84ac9aSAndroid Build Coastguard Worker
35*cf84ac9aSAndroid Build Coastguard Worker # include <assert.h>
36*cf84ac9aSAndroid Build Coastguard Worker # include <errno.h>
37*cf84ac9aSAndroid Build Coastguard Worker # include <poll.h>
38*cf84ac9aSAndroid Build Coastguard Worker # include <stdio.h>
39*cf84ac9aSAndroid Build Coastguard Worker # include <stdlib.h>
40*cf84ac9aSAndroid Build Coastguard Worker # include <string.h>
41*cf84ac9aSAndroid Build Coastguard Worker # include <unistd.h>
42*cf84ac9aSAndroid Build Coastguard Worker
43*cf84ac9aSAndroid Build Coastguard Worker #define PRINT_EVENT(flag, member) \
44*cf84ac9aSAndroid Build Coastguard Worker do { \
45*cf84ac9aSAndroid Build Coastguard Worker if (member & flag) { \
46*cf84ac9aSAndroid Build Coastguard Worker if (member != pfd->member) \
47*cf84ac9aSAndroid Build Coastguard Worker tprintf("|"); \
48*cf84ac9aSAndroid Build Coastguard Worker tprintf(#flag); \
49*cf84ac9aSAndroid Build Coastguard Worker member &= ~flag; \
50*cf84ac9aSAndroid Build Coastguard Worker } \
51*cf84ac9aSAndroid Build Coastguard Worker } while (0)
52*cf84ac9aSAndroid Build Coastguard Worker
53*cf84ac9aSAndroid Build Coastguard Worker static void
print_pollfd_entering(const struct pollfd * const pfd)54*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_entering(const struct pollfd *const pfd)
55*cf84ac9aSAndroid Build Coastguard Worker {
56*cf84ac9aSAndroid Build Coastguard Worker tprintf("{fd=%d", pfd->fd);
57*cf84ac9aSAndroid Build Coastguard Worker if (pfd->fd >= 0) {
58*cf84ac9aSAndroid Build Coastguard Worker tprintf(", events=");
59*cf84ac9aSAndroid Build Coastguard Worker short events = pfd->events;
60*cf84ac9aSAndroid Build Coastguard Worker
61*cf84ac9aSAndroid Build Coastguard Worker if (pfd->events) {
62*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLIN, events);
63*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLPRI, events);
64*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLOUT, events);
65*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLRDNORM
66*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLRDNORM, events);
67*cf84ac9aSAndroid Build Coastguard Worker #endif
68*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLWRNORM
69*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLWRNORM, events);
70*cf84ac9aSAndroid Build Coastguard Worker #endif
71*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLRDBAND
72*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLRDBAND, events);
73*cf84ac9aSAndroid Build Coastguard Worker #endif
74*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLWRBAND
75*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLWRBAND, events);
76*cf84ac9aSAndroid Build Coastguard Worker #endif
77*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLERR, events);
78*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLHUP, events);
79*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLNVAL, events);
80*cf84ac9aSAndroid Build Coastguard Worker } else
81*cf84ac9aSAndroid Build Coastguard Worker tprintf("0");
82*cf84ac9aSAndroid Build Coastguard Worker }
83*cf84ac9aSAndroid Build Coastguard Worker tprintf("}");
84*cf84ac9aSAndroid Build Coastguard Worker }
85*cf84ac9aSAndroid Build Coastguard Worker
86*cf84ac9aSAndroid Build Coastguard Worker static void
print_pollfd_array_entering(const struct pollfd * const pfd,const unsigned int size,const unsigned int valid,const unsigned int abbrev)87*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(const struct pollfd *const pfd,
88*cf84ac9aSAndroid Build Coastguard Worker const unsigned int size,
89*cf84ac9aSAndroid Build Coastguard Worker const unsigned int valid,
90*cf84ac9aSAndroid Build Coastguard Worker const unsigned int abbrev)
91*cf84ac9aSAndroid Build Coastguard Worker {
92*cf84ac9aSAndroid Build Coastguard Worker tprintf("[");
93*cf84ac9aSAndroid Build Coastguard Worker unsigned int i;
94*cf84ac9aSAndroid Build Coastguard Worker for (i = 0; i < size; ++i) {
95*cf84ac9aSAndroid Build Coastguard Worker if (i)
96*cf84ac9aSAndroid Build Coastguard Worker tprintf(", ");
97*cf84ac9aSAndroid Build Coastguard Worker if (i >= valid) {
98*cf84ac9aSAndroid Build Coastguard Worker tprintf("... /* %p */", &pfd[i]);
99*cf84ac9aSAndroid Build Coastguard Worker break;
100*cf84ac9aSAndroid Build Coastguard Worker }
101*cf84ac9aSAndroid Build Coastguard Worker if (i >= abbrev) {
102*cf84ac9aSAndroid Build Coastguard Worker tprintf("...");
103*cf84ac9aSAndroid Build Coastguard Worker break;
104*cf84ac9aSAndroid Build Coastguard Worker }
105*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_entering(&pfd[i]);
106*cf84ac9aSAndroid Build Coastguard Worker }
107*cf84ac9aSAndroid Build Coastguard Worker tprintf("]");
108*cf84ac9aSAndroid Build Coastguard Worker }
109*cf84ac9aSAndroid Build Coastguard Worker
110*cf84ac9aSAndroid Build Coastguard Worker static void
print_pollfd_exiting(const struct pollfd * const pfd,unsigned int * const seen,const unsigned int abbrev)111*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_exiting(const struct pollfd *const pfd,
112*cf84ac9aSAndroid Build Coastguard Worker unsigned int *const seen,
113*cf84ac9aSAndroid Build Coastguard Worker const unsigned int abbrev)
114*cf84ac9aSAndroid Build Coastguard Worker {
115*cf84ac9aSAndroid Build Coastguard Worker if (!pfd->revents || pfd->fd < 0 || *seen > abbrev)
116*cf84ac9aSAndroid Build Coastguard Worker return;
117*cf84ac9aSAndroid Build Coastguard Worker
118*cf84ac9aSAndroid Build Coastguard Worker if (*seen)
119*cf84ac9aSAndroid Build Coastguard Worker tprintf(", ");
120*cf84ac9aSAndroid Build Coastguard Worker ++(*seen);
121*cf84ac9aSAndroid Build Coastguard Worker
122*cf84ac9aSAndroid Build Coastguard Worker if (*seen > abbrev) {
123*cf84ac9aSAndroid Build Coastguard Worker tprintf("...");
124*cf84ac9aSAndroid Build Coastguard Worker return;
125*cf84ac9aSAndroid Build Coastguard Worker }
126*cf84ac9aSAndroid Build Coastguard Worker tprintf("{fd=%d, revents=", pfd->fd);
127*cf84ac9aSAndroid Build Coastguard Worker short revents = pfd->revents;
128*cf84ac9aSAndroid Build Coastguard Worker
129*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLIN, revents);
130*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLPRI, revents);
131*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLOUT, revents);
132*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLRDNORM
133*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLRDNORM, revents);
134*cf84ac9aSAndroid Build Coastguard Worker #endif
135*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLWRNORM
136*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLWRNORM, revents);
137*cf84ac9aSAndroid Build Coastguard Worker #endif
138*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLRDBAND
139*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLRDBAND, revents);
140*cf84ac9aSAndroid Build Coastguard Worker #endif
141*cf84ac9aSAndroid Build Coastguard Worker #ifdef POLLWRBAND
142*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLWRBAND, revents);
143*cf84ac9aSAndroid Build Coastguard Worker #endif
144*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLERR, revents);
145*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLHUP, revents);
146*cf84ac9aSAndroid Build Coastguard Worker PRINT_EVENT(POLLNVAL, revents);
147*cf84ac9aSAndroid Build Coastguard Worker tprintf("}");
148*cf84ac9aSAndroid Build Coastguard Worker }
149*cf84ac9aSAndroid Build Coastguard Worker
150*cf84ac9aSAndroid Build Coastguard Worker static void
print_pollfd_array_exiting(const struct pollfd * const pfd,const unsigned int size,const unsigned int abbrev)151*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_exiting(const struct pollfd *const pfd,
152*cf84ac9aSAndroid Build Coastguard Worker const unsigned int size,
153*cf84ac9aSAndroid Build Coastguard Worker const unsigned int abbrev)
154*cf84ac9aSAndroid Build Coastguard Worker {
155*cf84ac9aSAndroid Build Coastguard Worker tprintf("[");
156*cf84ac9aSAndroid Build Coastguard Worker unsigned int seen = 0;
157*cf84ac9aSAndroid Build Coastguard Worker unsigned int i;
158*cf84ac9aSAndroid Build Coastguard Worker for (i = 0; i < size; ++i)
159*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_exiting(&pfd[i], &seen, abbrev);
160*cf84ac9aSAndroid Build Coastguard Worker tprintf("]");
161*cf84ac9aSAndroid Build Coastguard Worker }
162*cf84ac9aSAndroid Build Coastguard Worker
163*cf84ac9aSAndroid Build Coastguard Worker int
main(int ac,char ** av)164*cf84ac9aSAndroid Build Coastguard Worker main(int ac, char **av)
165*cf84ac9aSAndroid Build Coastguard Worker {
166*cf84ac9aSAndroid Build Coastguard Worker # ifdef PATH_TRACING_FD
167*cf84ac9aSAndroid Build Coastguard Worker skip_if_unavailable("/proc/self/fd/");
168*cf84ac9aSAndroid Build Coastguard Worker # endif
169*cf84ac9aSAndroid Build Coastguard Worker
170*cf84ac9aSAndroid Build Coastguard Worker tprintf("%s", "");
171*cf84ac9aSAndroid Build Coastguard Worker
172*cf84ac9aSAndroid Build Coastguard Worker assert(syscall(__NR_poll, NULL, 42, 0) == -1);
173*cf84ac9aSAndroid Build Coastguard Worker if (ENOSYS == errno)
174*cf84ac9aSAndroid Build Coastguard Worker perror_msg_and_skip("poll");
175*cf84ac9aSAndroid Build Coastguard Worker
176*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
177*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(NULL, 42, 0) = -1 EFAULT (%m)\n");
178*cf84ac9aSAndroid Build Coastguard Worker # endif
179*cf84ac9aSAndroid Build Coastguard Worker
180*cf84ac9aSAndroid Build Coastguard Worker int fds[2];
181*cf84ac9aSAndroid Build Coastguard Worker if (pipe(fds) || pipe(fds))
182*cf84ac9aSAndroid Build Coastguard Worker perror_msg_and_fail("pipe");
183*cf84ac9aSAndroid Build Coastguard Worker
184*cf84ac9aSAndroid Build Coastguard Worker const unsigned int abbrev = (ac > 1) ? atoi(av[1]) : -1;
185*cf84ac9aSAndroid Build Coastguard Worker const struct pollfd pfds0[] = {
186*cf84ac9aSAndroid Build Coastguard Worker { .fd = 0, .events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND },
187*cf84ac9aSAndroid Build Coastguard Worker { .fd = 1, .events = POLLOUT | POLLWRNORM | POLLWRBAND },
188*cf84ac9aSAndroid Build Coastguard Worker { .fd = fds[0], .events = POLLIN | POLLPRI },
189*cf84ac9aSAndroid Build Coastguard Worker { .fd = fds[1], .events = POLLOUT },
190*cf84ac9aSAndroid Build Coastguard Worker { .fd = 2, .events = POLLOUT | POLLWRBAND }
191*cf84ac9aSAndroid Build Coastguard Worker };
192*cf84ac9aSAndroid Build Coastguard Worker struct pollfd *const tail_fds0 = tail_memdup(pfds0, sizeof(pfds0));
193*cf84ac9aSAndroid Build Coastguard Worker const int timeout = 42;
194*cf84ac9aSAndroid Build Coastguard Worker int rc = syscall(__NR_poll, tail_fds0, 0, timeout);
195*cf84ac9aSAndroid Build Coastguard Worker assert(rc == 0);
196*cf84ac9aSAndroid Build Coastguard Worker
197*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
198*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll([], 0, %d) = %d (Timeout)\n", timeout, rc);
199*cf84ac9aSAndroid Build Coastguard Worker # endif
200*cf84ac9aSAndroid Build Coastguard Worker
201*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, tail_fds0, ARRAY_SIZE(pfds0), timeout);
202*cf84ac9aSAndroid Build Coastguard Worker assert(rc == 3);
203*cf84ac9aSAndroid Build Coastguard Worker
204*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
205*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
206*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(tail_fds0, ARRAY_SIZE(pfds0),
207*cf84ac9aSAndroid Build Coastguard Worker ARRAY_SIZE(pfds0), abbrev);
208*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, %d) = %d (",
209*cf84ac9aSAndroid Build Coastguard Worker (unsigned int) ARRAY_SIZE(pfds0), timeout, rc);
210*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_exiting(tail_fds0, ARRAY_SIZE(pfds0), abbrev);
211*cf84ac9aSAndroid Build Coastguard Worker tprintf(")\n");
212*cf84ac9aSAndroid Build Coastguard Worker # endif /* !PATH_TRACING_FD */
213*cf84ac9aSAndroid Build Coastguard Worker
214*cf84ac9aSAndroid Build Coastguard Worker tail_fds0[0].fd = -1;
215*cf84ac9aSAndroid Build Coastguard Worker tail_fds0[2].fd = -3;
216*cf84ac9aSAndroid Build Coastguard Worker tail_fds0[4].events = 0;
217*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, tail_fds0, ARRAY_SIZE(pfds0), timeout);
218*cf84ac9aSAndroid Build Coastguard Worker assert(rc == 2);
219*cf84ac9aSAndroid Build Coastguard Worker
220*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
221*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
222*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(tail_fds0, ARRAY_SIZE(pfds0),
223*cf84ac9aSAndroid Build Coastguard Worker ARRAY_SIZE(pfds0), abbrev);
224*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, %d) = %d (",
225*cf84ac9aSAndroid Build Coastguard Worker (unsigned int) ARRAY_SIZE(pfds0), timeout, rc);
226*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_exiting(tail_fds0, ARRAY_SIZE(pfds0), abbrev);
227*cf84ac9aSAndroid Build Coastguard Worker tprintf(")\n");
228*cf84ac9aSAndroid Build Coastguard Worker # endif /* !PATH_TRACING_FD */
229*cf84ac9aSAndroid Build Coastguard Worker
230*cf84ac9aSAndroid Build Coastguard Worker tail_fds0[1].fd = -2;
231*cf84ac9aSAndroid Build Coastguard Worker tail_fds0[4].fd = -5;
232*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, tail_fds0, ARRAY_SIZE(pfds0), timeout);
233*cf84ac9aSAndroid Build Coastguard Worker assert(rc == 1);
234*cf84ac9aSAndroid Build Coastguard Worker
235*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
236*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
237*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(tail_fds0, ARRAY_SIZE(pfds0),
238*cf84ac9aSAndroid Build Coastguard Worker ARRAY_SIZE(pfds0), abbrev);
239*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, %d) = %d (",
240*cf84ac9aSAndroid Build Coastguard Worker (unsigned int) ARRAY_SIZE(pfds0), timeout, rc);
241*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_exiting(tail_fds0, ARRAY_SIZE(pfds0), abbrev);
242*cf84ac9aSAndroid Build Coastguard Worker tprintf(")\n");
243*cf84ac9aSAndroid Build Coastguard Worker # endif /* !PATH_TRACING_FD */
244*cf84ac9aSAndroid Build Coastguard Worker
245*cf84ac9aSAndroid Build Coastguard Worker struct pollfd pfds1[] = {
246*cf84ac9aSAndroid Build Coastguard Worker { .fd = 1, .events = POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND },
247*cf84ac9aSAndroid Build Coastguard Worker { .fd = 0, .events = POLLOUT | POLLWRNORM | POLLWRBAND }
248*cf84ac9aSAndroid Build Coastguard Worker };
249*cf84ac9aSAndroid Build Coastguard Worker struct pollfd *const tail_fds1 = tail_memdup(pfds1, sizeof(pfds1));
250*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, tail_fds1, ARRAY_SIZE(pfds1), timeout);
251*cf84ac9aSAndroid Build Coastguard Worker assert(rc == 0);
252*cf84ac9aSAndroid Build Coastguard Worker
253*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
254*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
255*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(tail_fds1, ARRAY_SIZE(pfds1),
256*cf84ac9aSAndroid Build Coastguard Worker ARRAY_SIZE(pfds1), abbrev);
257*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, %d) = %d (Timeout)\n",
258*cf84ac9aSAndroid Build Coastguard Worker (unsigned int) ARRAY_SIZE(pfds1), timeout, rc);
259*cf84ac9aSAndroid Build Coastguard Worker # endif /* !PATH_TRACING_FD */
260*cf84ac9aSAndroid Build Coastguard Worker
261*cf84ac9aSAndroid Build Coastguard Worker const void *const efault = tail_fds0 + ARRAY_SIZE(pfds0);
262*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, efault, 1, 0);
263*cf84ac9aSAndroid Build Coastguard Worker assert(rc == -1);
264*cf84ac9aSAndroid Build Coastguard Worker
265*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
266*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(%p, 1, 0) = -1 EFAULT (%m)\n", efault);
267*cf84ac9aSAndroid Build Coastguard Worker # endif
268*cf84ac9aSAndroid Build Coastguard Worker
269*cf84ac9aSAndroid Build Coastguard Worker const unsigned int valid = 1;
270*cf84ac9aSAndroid Build Coastguard Worker const void *const epfds = tail_fds0 + ARRAY_SIZE(pfds0) - valid;
271*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, epfds, valid + 1, 0);
272*cf84ac9aSAndroid Build Coastguard Worker assert(rc == -1);
273*cf84ac9aSAndroid Build Coastguard Worker
274*cf84ac9aSAndroid Build Coastguard Worker # ifndef PATH_TRACING_FD
275*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
276*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(epfds, valid + 1, valid, abbrev);
277*cf84ac9aSAndroid Build Coastguard Worker errno = EFAULT;
278*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, 0) = -1 EFAULT (%m)\n", valid + 1);
279*cf84ac9aSAndroid Build Coastguard Worker # endif /* !PATH_TRACING_FD */
280*cf84ac9aSAndroid Build Coastguard Worker
281*cf84ac9aSAndroid Build Coastguard Worker # ifdef PATH_TRACING_FD
282*cf84ac9aSAndroid Build Coastguard Worker memcpy(tail_fds0, pfds0, sizeof(pfds0));
283*cf84ac9aSAndroid Build Coastguard Worker tail_fds0[4].fd = PATH_TRACING_FD;
284*cf84ac9aSAndroid Build Coastguard Worker
285*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, tail_fds0, ARRAY_SIZE(pfds0), timeout);
286*cf84ac9aSAndroid Build Coastguard Worker assert(rc == 3);
287*cf84ac9aSAndroid Build Coastguard Worker
288*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
289*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(tail_fds0, ARRAY_SIZE(pfds0),
290*cf84ac9aSAndroid Build Coastguard Worker ARRAY_SIZE(pfds0), abbrev);
291*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, %d) = %d (",
292*cf84ac9aSAndroid Build Coastguard Worker (unsigned int) ARRAY_SIZE(pfds0), timeout, rc);
293*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_exiting(tail_fds0, ARRAY_SIZE(pfds0), abbrev);
294*cf84ac9aSAndroid Build Coastguard Worker tprintf(")\n");
295*cf84ac9aSAndroid Build Coastguard Worker
296*cf84ac9aSAndroid Build Coastguard Worker rc = syscall(__NR_poll, epfds, valid + 1, 0);
297*cf84ac9aSAndroid Build Coastguard Worker assert(rc == -1);
298*cf84ac9aSAndroid Build Coastguard Worker
299*cf84ac9aSAndroid Build Coastguard Worker /* the 1st pollfd element is readable and contains PATH_TRACING_FD */
300*cf84ac9aSAndroid Build Coastguard Worker tprintf("poll(");
301*cf84ac9aSAndroid Build Coastguard Worker print_pollfd_array_entering(epfds, valid + 1, valid, abbrev);
302*cf84ac9aSAndroid Build Coastguard Worker errno = EFAULT;
303*cf84ac9aSAndroid Build Coastguard Worker tprintf(", %u, 0) = -1 EFAULT (%m)\n", valid + 1);
304*cf84ac9aSAndroid Build Coastguard Worker # endif /* PATH_TRACING_FD */
305*cf84ac9aSAndroid Build Coastguard Worker
306*cf84ac9aSAndroid Build Coastguard Worker tprintf("+++ exited with 0 +++\n");
307*cf84ac9aSAndroid Build Coastguard Worker return 0;
308*cf84ac9aSAndroid Build Coastguard Worker }
309*cf84ac9aSAndroid Build Coastguard Worker
310*cf84ac9aSAndroid Build Coastguard Worker #else
311*cf84ac9aSAndroid Build Coastguard Worker
312*cf84ac9aSAndroid Build Coastguard Worker SKIP_MAIN_UNDEFINED("__NR_poll")
313*cf84ac9aSAndroid Build Coastguard Worker
314*cf84ac9aSAndroid Build Coastguard Worker #endif
315