blob: a47eca2c2d3185bd9cba768797cad7740c61f27b [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +00003 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000027 */
28
29#include "defs.h"
Dmitry V. Levind64a7e42013-11-06 01:17:05 +000030#if defined HAVE_POLL_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010031# include <poll.h>
Dmitry V. Levind64a7e42013-11-06 01:17:05 +000032#elif defined HAVE_SYS_POLL_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010033# include <sys/poll.h>
Pavel Machek245a6ac2000-02-01 16:12:33 +000034#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000035#ifdef HAVE_SYS_CONF_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010036# include <sys/conf.h>
Wichert Akkerman42080d82001-04-10 10:32:26 +000037#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000038
Denys Vlasenkocc902912013-03-05 16:50:12 +010039/* Who has STREAMS syscalls?
40 * Linux hasn't. Solaris has (had?).
41 * Just in case I miss something, retain in for Sparc...
42 */
43#if defined(SPARC) || defined(SPARC64)
44
45# ifdef HAVE_STROPTS_H
46# include <stropts.h>
47# else
48# define RS_HIPRI 1
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049struct strbuf {
Denys Vlasenkoadedb512008-12-30 18:47:55 +000050 int maxlen; /* no. of bytes in buffer */
51 int len; /* no. of bytes returned */
Dmitry V. Levin30145dd2010-09-06 22:08:24 +000052 const char *buf; /* pointer to data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053};
Denys Vlasenkocc902912013-03-05 16:50:12 +010054# define MORECTL 1
55# define MOREDATA 2
56# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057
Roland McGrathd9f816f2004-09-04 03:39:20 +000058static const struct xlat msgflags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000059 XLAT(RS_HIPRI),
Dmitry V. Levin59452732014-02-05 02:20:51 +000060 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000061};
62
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000063static void
Denys Vlasenko12014262011-05-30 14:00:14 +020064printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000065{
66 if (sbp->maxlen == -1 && getting)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020067 tprints("{maxlen=-1}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000068 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020069 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000070 if (getting)
71 tprintf("maxlen=%d, ", sbp->maxlen);
72 tprintf("len=%d, buf=", sbp->len);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000073 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020074 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000075 }
76}
77
78static void
Denys Vlasenkoe7db4652013-03-05 16:17:46 +010079printstrbufarg(struct tcb *tcp, long arg, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000080{
81 struct strbuf buf;
82
83 if (arg == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020084 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085 else if (umove(tcp, arg, &buf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020086 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000087 else
88 printstrbuf(tcp, &buf, getting);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020089 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000090}
91
92int
Denys Vlasenko12014262011-05-30 14:00:14 +020093sys_putmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000094{
95 int i;
96
97 if (entering(tcp)) {
98 /* fd */
99 tprintf("%ld, ", tcp->u_arg[0]);
100 /* control and data */
101 for (i = 1; i < 3; i++)
102 printstrbufarg(tcp, tcp->u_arg[i], 0);
103 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000104 printflags(msgflags, tcp->u_arg[3], "RS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000105 }
106 return 0;
107}
108
109int
Denys Vlasenko12014262011-05-30 14:00:14 +0200110sys_getmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000111{
112 int i, flags;
113
114 if (entering(tcp)) {
115 /* fd */
116 tprintf("%lu, ", tcp->u_arg[0]);
117 } else {
118 if (syserror(tcp)) {
119 tprintf("%#lx, %#lx, %#lx",
120 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
121 return 0;
122 }
123 /* control and data */
124 for (i = 1; i < 3; i++)
125 printstrbufarg(tcp, tcp->u_arg[i], 1);
126 /* pointer to flags */
127 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200128 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000129 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200130 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000131 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200132 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000133 printflags(msgflags, flags, "RS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200134 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000135 }
136 /* decode return value */
137 switch (tcp->u_rval) {
138 case MORECTL:
139 tcp->auxstr = "MORECTL";
140 break;
141 case MORECTL|MOREDATA:
142 tcp->auxstr = "MORECTL|MOREDATA";
143 break;
144 case MOREDATA:
145 tcp->auxstr = "MORECTL";
146 break;
147 default:
148 tcp->auxstr = NULL;
149 break;
150 }
151 }
152 return RVAL_HEX | RVAL_STR;
153}
154
Denys Vlasenkocc902912013-03-05 16:50:12 +0100155# if defined SYS_putpmsg || defined SYS_getpmsg
Roland McGrathd9f816f2004-09-04 03:39:20 +0000156static const struct xlat pmsgflags[] = {
Denys Vlasenkocc902912013-03-05 16:50:12 +0100157# ifdef MSG_HIPRI
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000158 XLAT(MSG_HIPRI),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100159# endif
160# ifdef MSG_AND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000161 XLAT(MSG_ANY),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100162# endif
163# ifdef MSG_BAND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000164 XLAT(MSG_BAND),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100165# endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000166 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167};
Denys Vlasenkocc902912013-03-05 16:50:12 +0100168# ifdef SYS_putpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000169int
Denys Vlasenko12014262011-05-30 14:00:14 +0200170sys_putpmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000171{
172 int i;
173
174 if (entering(tcp)) {
175 /* fd */
176 tprintf("%ld, ", tcp->u_arg[0]);
177 /* control and data */
178 for (i = 1; i < 3; i++)
179 printstrbufarg(tcp, tcp->u_arg[i], 0);
180 /* band */
181 tprintf("%ld, ", tcp->u_arg[3]);
182 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000183 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000184 }
185 return 0;
186}
Denys Vlasenkocc902912013-03-05 16:50:12 +0100187# endif
188# ifdef SYS_getpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189int
Denys Vlasenko12014262011-05-30 14:00:14 +0200190sys_getpmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000191{
192 int i, flags;
193
194 if (entering(tcp)) {
195 /* fd */
196 tprintf("%lu, ", tcp->u_arg[0]);
197 } else {
198 if (syserror(tcp)) {
199 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
200 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
201 return 0;
202 }
203 /* control and data */
204 for (i = 1; i < 3; i++)
205 printstrbufarg(tcp, tcp->u_arg[i], 1);
206 /* pointer to band */
207 printnum(tcp, tcp->u_arg[3], "%d");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200208 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209 /* pointer to flags */
210 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200211 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000212 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200213 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000214 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200215 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000216 printflags(pmsgflags, flags, "MSG_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200217 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000218 }
219 /* decode return value */
220 switch (tcp->u_rval) {
221 case MORECTL:
222 tcp->auxstr = "MORECTL";
223 break;
224 case MORECTL|MOREDATA:
225 tcp->auxstr = "MORECTL|MOREDATA";
226 break;
227 case MOREDATA:
228 tcp->auxstr = "MORECTL";
229 break;
230 default:
231 tcp->auxstr = NULL;
232 break;
233 }
234 }
235 return RVAL_HEX | RVAL_STR;
236}
Denys Vlasenkocc902912013-03-05 16:50:12 +0100237# endif
238# endif /* getpmsg/putpmsg */
239
240#endif /* STREAMS syscalls support */
241
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000243#ifdef HAVE_SYS_POLL_H
244
Roland McGrathd9f816f2004-09-04 03:39:20 +0000245static const struct xlat pollflags[] = {
Denys Vlasenkocc902912013-03-05 16:50:12 +0100246# ifdef POLLIN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000247 XLAT(POLLIN),
248 XLAT(POLLPRI),
249 XLAT(POLLOUT),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100250# ifdef POLLRDNORM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000251 XLAT(POLLRDNORM),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100252# endif
253# ifdef POLLWRNORM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000254 XLAT(POLLWRNORM),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100255# endif
256# ifdef POLLRDBAND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000257 XLAT(POLLRDBAND),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100258# endif
259# ifdef POLLWRBAND
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000260 XLAT(POLLWRBAND),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100261# endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000262 XLAT(POLLERR),
263 XLAT(POLLHUP),
264 XLAT(POLLNVAL),
Denys Vlasenkocc902912013-03-05 16:50:12 +0100265# endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000266 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000267};
268
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000269static int
Roland McGrathf17106e2007-11-01 21:49:49 +0000270decode_poll(struct tcb *tcp, long pts)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000271{
Roland McGrathaa524c82005-06-01 19:22:06 +0000272 struct pollfd fds;
273 unsigned nfds;
274 unsigned long size, start, cur, end, abbrev_end;
275 int failed = 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000276
Roland McGrathf17106e2007-11-01 21:49:49 +0000277 if (entering(tcp)) {
278 nfds = tcp->u_arg[1];
279 size = sizeof(fds) * nfds;
280 start = tcp->u_arg[0];
281 end = start + size;
282 if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
283 tprintf("%#lx, %d, ",
284 tcp->u_arg[0], nfds);
285 return 0;
286 }
287 if (abbrev(tcp)) {
288 abbrev_end = start + max_strlen * sizeof(fds);
289 if (abbrev_end < start)
290 abbrev_end = end;
291 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000292 abbrev_end = end;
Roland McGrathf17106e2007-11-01 21:49:49 +0000293 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200294 tprints("[");
Roland McGrathf17106e2007-11-01 21:49:49 +0000295 for (cur = start; cur < end; cur += sizeof(fds)) {
296 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200297 tprints(", ");
Roland McGrathf17106e2007-11-01 21:49:49 +0000298 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200299 tprints("...");
Roland McGrathf17106e2007-11-01 21:49:49 +0000300 break;
301 }
302 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200303 tprints("?");
Roland McGrathf17106e2007-11-01 21:49:49 +0000304 failed = 1;
305 break;
306 }
307 if (fds.fd < 0) {
308 tprintf("{fd=%d}", fds.fd);
309 continue;
310 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200311 tprints("{fd=");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300312 printfd(tcp, fds.fd);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200313 tprints(", events=");
Roland McGrathf17106e2007-11-01 21:49:49 +0000314 printflags(pollflags, fds.events, "POLL???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200315 tprints("}");
Roland McGrathf17106e2007-11-01 21:49:49 +0000316 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200317 tprints("]");
Roland McGrathf17106e2007-11-01 21:49:49 +0000318 if (failed)
319 tprintf(" %#lx", start);
320 tprintf(", %d, ", nfds);
321 return 0;
Roland McGrathaa524c82005-06-01 19:22:06 +0000322 } else {
Roland McGrathf17106e2007-11-01 21:49:49 +0000323 static char outstr[1024];
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200324 char *outptr;
325#define end_outstr (outstr + sizeof(outstr))
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000326 const char *flagstr;
Roland McGrathf17106e2007-11-01 21:49:49 +0000327
328 if (syserror(tcp))
329 return 0;
330 if (tcp->u_rval == 0) {
331 tcp->auxstr = "Timeout";
332 return RVAL_STR;
333 }
334
335 nfds = tcp->u_arg[1];
336 size = sizeof(fds) * nfds;
337 start = tcp->u_arg[0];
338 end = start + size;
339 if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
340 return 0;
341 if (abbrev(tcp)) {
342 abbrev_end = start + max_strlen * sizeof(fds);
343 if (abbrev_end < start)
344 abbrev_end = end;
345 } else {
346 abbrev_end = end;
347 }
348
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200349 outptr = outstr;
Roland McGrathf17106e2007-11-01 21:49:49 +0000350
351 for (cur = start; cur < end; cur += sizeof(fds)) {
352 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200353 if (outptr < end_outstr - 2)
354 *outptr++ = '?';
Roland McGrathf17106e2007-11-01 21:49:49 +0000355 failed = 1;
356 break;
357 }
358 if (!fds.revents)
359 continue;
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200360 if (outptr == outstr) {
361 *outptr++ = '[';
Roland McGrathf17106e2007-11-01 21:49:49 +0000362 } else {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200363 if (outptr < end_outstr - 3)
364 outptr = stpcpy(outptr, ", ");
Roland McGrathf17106e2007-11-01 21:49:49 +0000365 }
366 if (cur >= abbrev_end) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200367 if (outptr < end_outstr - 4)
368 outptr = stpcpy(outptr, "...");
Roland McGrathf17106e2007-11-01 21:49:49 +0000369 break;
370 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200371 if (outptr < end_outstr - (sizeof("{fd=%d, revents=") + sizeof(int)*3) + 1)
372 outptr += sprintf(outptr, "{fd=%d, revents=", fds.fd);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200373 flagstr = sprintflags("", pollflags, fds.revents);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200374 if (outptr < end_outstr - (strlen(flagstr) + 2)) {
375 outptr = stpcpy(outptr, flagstr);
376 *outptr++ = '}';
Roland McGrathf17106e2007-11-01 21:49:49 +0000377 }
378 }
379 if (failed)
380 return 0;
381
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200382 if (outptr != outstr /* && outptr < end_outstr - 1 (always true)*/)
383 *outptr++ = ']';
Roland McGrathf17106e2007-11-01 21:49:49 +0000384
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200385 *outptr = '\0';
Roland McGrathf17106e2007-11-01 21:49:49 +0000386 if (pts) {
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100387 if (outptr < end_outstr - (10 + TIMESPEC_TEXT_BUFSIZE)) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200388 outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
389 sprint_timespec(outptr, tcp, pts);
390 }
Roland McGrathf17106e2007-11-01 21:49:49 +0000391 }
392
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200393 if (outptr == outstr)
Roland McGrathf17106e2007-11-01 21:49:49 +0000394 return 0;
395
396 tcp->auxstr = outstr;
397 return RVAL_STR;
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200398#undef end_outstr
Roland McGrathaa524c82005-06-01 19:22:06 +0000399 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400}
401
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000402int
403sys_poll(struct tcb *tcp)
404{
Roland McGrathf17106e2007-11-01 21:49:49 +0000405 int rc = decode_poll(tcp, 0);
406 if (entering(tcp)) {
Denys Vlasenkocc902912013-03-05 16:50:12 +0100407# ifdef INFTIM
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000408 if (tcp->u_arg[2] == INFTIM)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200409 tprints("INFTIM");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000410 else
Denys Vlasenkocc902912013-03-05 16:50:12 +0100411# endif
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000412 tprintf("%ld", tcp->u_arg[2]);
413 }
414 return rc;
415}
416
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000417int
418sys_ppoll(struct tcb *tcp)
419{
Roland McGrathf17106e2007-11-01 21:49:49 +0000420 int rc = decode_poll(tcp, tcp->u_arg[2]);
421 if (entering(tcp)) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000422 print_timespec(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200423 tprints(", ");
Denys Vlasenko5e133aa2013-07-18 17:02:21 +0200424 /* NB: kernel requires arg[4] == NSIG / 8 */
425 print_sigset_addr_len(tcp, tcp->u_arg[3], tcp->u_arg[4]);
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000426 tprintf(", %lu", tcp->u_arg[4]);
427 }
428 return rc;
429}
Roland McGrathaa524c82005-06-01 19:22:06 +0000430
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000431#else /* !HAVE_SYS_POLL_H */
432int
Denys Vlasenko12014262011-05-30 14:00:14 +0200433sys_poll(struct tcb *tcp)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000434{
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000435 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000436}
437#endif