blob: 8c908382ccca4d4cd2821213a7ca06cd57d45c76 [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"
Wichert Akkerman42080d82001-04-10 10:32:26 +000030#ifdef HAVE_POLL_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010031# include <poll.h>
Wichert Akkerman42080d82001-04-10 10:32:26 +000032#endif
Pavel Machek245a6ac2000-02-01 16:12:33 +000033#ifdef HAVE_SYS_POLL_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010034# include <sys/poll.h>
Pavel Machek245a6ac2000-02-01 16:12:33 +000035#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000036#ifdef HAVE_SYS_CONF_H
Denys Vlasenkoa6d91de2012-03-16 12:02:22 +010037# include <sys/conf.h>
Wichert Akkerman42080d82001-04-10 10:32:26 +000038#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000039
Denys Vlasenkocc902912013-03-05 16:50:12 +010040/* Who has STREAMS syscalls?
41 * Linux hasn't. Solaris has (had?).
42 * Just in case I miss something, retain in for Sparc...
43 */
44#if defined(SPARC) || defined(SPARC64)
45
46# ifdef HAVE_STROPTS_H
47# include <stropts.h>
48# else
49# define RS_HIPRI 1
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050struct strbuf {
Denys Vlasenkoadedb512008-12-30 18:47:55 +000051 int maxlen; /* no. of bytes in buffer */
52 int len; /* no. of bytes returned */
Dmitry V. Levin30145dd2010-09-06 22:08:24 +000053 const char *buf; /* pointer to data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054};
Denys Vlasenkocc902912013-03-05 16:50:12 +010055# define MORECTL 1
56# define MOREDATA 2
57# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058
Roland McGrathd9f816f2004-09-04 03:39:20 +000059static const struct xlat msgflags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000060 { RS_HIPRI, "RS_HIPRI" },
61 { 0, NULL },
62};
63
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000064static void
Denys Vlasenko12014262011-05-30 14:00:14 +020065printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000066{
67 if (sbp->maxlen == -1 && getting)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020068 tprints("{maxlen=-1}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000069 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020070 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000071 if (getting)
72 tprintf("maxlen=%d, ", sbp->maxlen);
73 tprintf("len=%d, buf=", sbp->len);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000074 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020075 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000076 }
77}
78
79static void
Denys Vlasenkoe7db4652013-03-05 16:17:46 +010080printstrbufarg(struct tcb *tcp, long arg, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000081{
82 struct strbuf buf;
83
84 if (arg == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020085 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000086 else if (umove(tcp, arg, &buf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020087 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000088 else
89 printstrbuf(tcp, &buf, getting);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020090 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000091}
92
93int
Denys Vlasenko12014262011-05-30 14:00:14 +020094sys_putmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000095{
96 int i;
97
98 if (entering(tcp)) {
99 /* fd */
100 tprintf("%ld, ", tcp->u_arg[0]);
101 /* control and data */
102 for (i = 1; i < 3; i++)
103 printstrbufarg(tcp, tcp->u_arg[i], 0);
104 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000105 printflags(msgflags, tcp->u_arg[3], "RS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000106 }
107 return 0;
108}
109
110int
Denys Vlasenko12014262011-05-30 14:00:14 +0200111sys_getmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000112{
113 int i, flags;
114
115 if (entering(tcp)) {
116 /* fd */
117 tprintf("%lu, ", tcp->u_arg[0]);
118 } else {
119 if (syserror(tcp)) {
120 tprintf("%#lx, %#lx, %#lx",
121 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
122 return 0;
123 }
124 /* control and data */
125 for (i = 1; i < 3; i++)
126 printstrbufarg(tcp, tcp->u_arg[i], 1);
127 /* pointer to flags */
128 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200129 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000130 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200131 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000132 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200133 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000134 printflags(msgflags, flags, "RS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200135 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000136 }
137 /* decode return value */
138 switch (tcp->u_rval) {
139 case MORECTL:
140 tcp->auxstr = "MORECTL";
141 break;
142 case MORECTL|MOREDATA:
143 tcp->auxstr = "MORECTL|MOREDATA";
144 break;
145 case MOREDATA:
146 tcp->auxstr = "MORECTL";
147 break;
148 default:
149 tcp->auxstr = NULL;
150 break;
151 }
152 }
153 return RVAL_HEX | RVAL_STR;
154}
155
Denys Vlasenkocc902912013-03-05 16:50:12 +0100156# if defined SYS_putpmsg || defined SYS_getpmsg
Roland McGrathd9f816f2004-09-04 03:39:20 +0000157static const struct xlat pmsgflags[] = {
Denys Vlasenkocc902912013-03-05 16:50:12 +0100158# ifdef MSG_HIPRI
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000159 { MSG_HIPRI, "MSG_HIPRI" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100160# endif
161# ifdef MSG_AND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000162 { MSG_ANY, "MSG_ANY" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100163# endif
164# ifdef MSG_BAND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165 { MSG_BAND, "MSG_BAND" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100166# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167 { 0, NULL },
168};
Denys Vlasenkocc902912013-03-05 16:50:12 +0100169# ifdef SYS_putpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000170int
Denys Vlasenko12014262011-05-30 14:00:14 +0200171sys_putpmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000172{
173 int i;
174
175 if (entering(tcp)) {
176 /* fd */
177 tprintf("%ld, ", tcp->u_arg[0]);
178 /* control and data */
179 for (i = 1; i < 3; i++)
180 printstrbufarg(tcp, tcp->u_arg[i], 0);
181 /* band */
182 tprintf("%ld, ", tcp->u_arg[3]);
183 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000184 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000185 }
186 return 0;
187}
Denys Vlasenkocc902912013-03-05 16:50:12 +0100188# endif
189# ifdef SYS_getpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190int
Denys Vlasenko12014262011-05-30 14:00:14 +0200191sys_getpmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000192{
193 int i, flags;
194
195 if (entering(tcp)) {
196 /* fd */
197 tprintf("%lu, ", tcp->u_arg[0]);
198 } else {
199 if (syserror(tcp)) {
200 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
201 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
202 return 0;
203 }
204 /* control and data */
205 for (i = 1; i < 3; i++)
206 printstrbufarg(tcp, tcp->u_arg[i], 1);
207 /* pointer to band */
208 printnum(tcp, tcp->u_arg[3], "%d");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200209 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000210 /* pointer to flags */
211 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200212 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000213 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200214 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000215 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200216 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000217 printflags(pmsgflags, flags, "MSG_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200218 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219 }
220 /* decode return value */
221 switch (tcp->u_rval) {
222 case MORECTL:
223 tcp->auxstr = "MORECTL";
224 break;
225 case MORECTL|MOREDATA:
226 tcp->auxstr = "MORECTL|MOREDATA";
227 break;
228 case MOREDATA:
229 tcp->auxstr = "MORECTL";
230 break;
231 default:
232 tcp->auxstr = NULL;
233 break;
234 }
235 }
236 return RVAL_HEX | RVAL_STR;
237}
Denys Vlasenkocc902912013-03-05 16:50:12 +0100238# endif
239# endif /* getpmsg/putpmsg */
240
241#endif /* STREAMS syscalls support */
242
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000243
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000244#ifdef HAVE_SYS_POLL_H
245
Roland McGrathd9f816f2004-09-04 03:39:20 +0000246static const struct xlat pollflags[] = {
Denys Vlasenkocc902912013-03-05 16:50:12 +0100247# ifdef POLLIN
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248 { POLLIN, "POLLIN" },
249 { POLLPRI, "POLLPRI" },
250 { POLLOUT, "POLLOUT" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100251# ifdef POLLRDNORM
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000252 { POLLRDNORM, "POLLRDNORM" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100253# endif
254# ifdef POLLWRNORM
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000255 { POLLWRNORM, "POLLWRNORM" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100256# endif
257# ifdef POLLRDBAND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000258 { POLLRDBAND, "POLLRDBAND" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100259# endif
260# ifdef POLLWRBAND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000261 { POLLWRBAND, "POLLWRBAND" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100262# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000263 { POLLERR, "POLLERR" },
264 { POLLHUP, "POLLHUP" },
265 { POLLNVAL, "POLLNVAL" },
Denys Vlasenkocc902912013-03-05 16:50:12 +0100266# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000267 { 0, NULL },
268};
269
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000270static int
Roland McGrathf17106e2007-11-01 21:49:49 +0000271decode_poll(struct tcb *tcp, long pts)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000272{
Roland McGrathaa524c82005-06-01 19:22:06 +0000273 struct pollfd fds;
274 unsigned nfds;
275 unsigned long size, start, cur, end, abbrev_end;
276 int failed = 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000277
Roland McGrathf17106e2007-11-01 21:49:49 +0000278 if (entering(tcp)) {
279 nfds = tcp->u_arg[1];
280 size = sizeof(fds) * nfds;
281 start = tcp->u_arg[0];
282 end = start + size;
283 if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
284 tprintf("%#lx, %d, ",
285 tcp->u_arg[0], nfds);
286 return 0;
287 }
288 if (abbrev(tcp)) {
289 abbrev_end = start + max_strlen * sizeof(fds);
290 if (abbrev_end < start)
291 abbrev_end = end;
292 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000293 abbrev_end = end;
Roland McGrathf17106e2007-11-01 21:49:49 +0000294 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200295 tprints("[");
Roland McGrathf17106e2007-11-01 21:49:49 +0000296 for (cur = start; cur < end; cur += sizeof(fds)) {
297 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200298 tprints(", ");
Roland McGrathf17106e2007-11-01 21:49:49 +0000299 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200300 tprints("...");
Roland McGrathf17106e2007-11-01 21:49:49 +0000301 break;
302 }
303 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200304 tprints("?");
Roland McGrathf17106e2007-11-01 21:49:49 +0000305 failed = 1;
306 break;
307 }
308 if (fds.fd < 0) {
309 tprintf("{fd=%d}", fds.fd);
310 continue;
311 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200312 tprints("{fd=");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300313 printfd(tcp, fds.fd);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200314 tprints(", events=");
Roland McGrathf17106e2007-11-01 21:49:49 +0000315 printflags(pollflags, fds.events, "POLL???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200316 tprints("}");
Roland McGrathf17106e2007-11-01 21:49:49 +0000317 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200318 tprints("]");
Roland McGrathf17106e2007-11-01 21:49:49 +0000319 if (failed)
320 tprintf(" %#lx", start);
321 tprintf(", %d, ", nfds);
322 return 0;
Roland McGrathaa524c82005-06-01 19:22:06 +0000323 } else {
Roland McGrathf17106e2007-11-01 21:49:49 +0000324 static char outstr[1024];
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200325 char *outptr;
326#define end_outstr (outstr + sizeof(outstr))
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000327 const char *flagstr;
Roland McGrathf17106e2007-11-01 21:49:49 +0000328
329 if (syserror(tcp))
330 return 0;
331 if (tcp->u_rval == 0) {
332 tcp->auxstr = "Timeout";
333 return RVAL_STR;
334 }
335
336 nfds = tcp->u_arg[1];
337 size = sizeof(fds) * nfds;
338 start = tcp->u_arg[0];
339 end = start + size;
340 if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
341 return 0;
342 if (abbrev(tcp)) {
343 abbrev_end = start + max_strlen * sizeof(fds);
344 if (abbrev_end < start)
345 abbrev_end = end;
346 } else {
347 abbrev_end = end;
348 }
349
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200350 outptr = outstr;
Roland McGrathf17106e2007-11-01 21:49:49 +0000351
352 for (cur = start; cur < end; cur += sizeof(fds)) {
353 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200354 if (outptr < end_outstr - 2)
355 *outptr++ = '?';
Roland McGrathf17106e2007-11-01 21:49:49 +0000356 failed = 1;
357 break;
358 }
359 if (!fds.revents)
360 continue;
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200361 if (outptr == outstr) {
362 *outptr++ = '[';
Roland McGrathf17106e2007-11-01 21:49:49 +0000363 } else {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200364 if (outptr < end_outstr - 3)
365 outptr = stpcpy(outptr, ", ");
Roland McGrathf17106e2007-11-01 21:49:49 +0000366 }
367 if (cur >= abbrev_end) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200368 if (outptr < end_outstr - 4)
369 outptr = stpcpy(outptr, "...");
Roland McGrathf17106e2007-11-01 21:49:49 +0000370 break;
371 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200372 if (outptr < end_outstr - (sizeof("{fd=%d, revents=") + sizeof(int)*3) + 1)
373 outptr += sprintf(outptr, "{fd=%d, revents=", fds.fd);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200374 flagstr = sprintflags("", pollflags, fds.revents);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200375 if (outptr < end_outstr - (strlen(flagstr) + 2)) {
376 outptr = stpcpy(outptr, flagstr);
377 *outptr++ = '}';
Roland McGrathf17106e2007-11-01 21:49:49 +0000378 }
379 }
380 if (failed)
381 return 0;
382
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200383 if (outptr != outstr /* && outptr < end_outstr - 1 (always true)*/)
384 *outptr++ = ']';
Roland McGrathf17106e2007-11-01 21:49:49 +0000385
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200386 *outptr = '\0';
Roland McGrathf17106e2007-11-01 21:49:49 +0000387 if (pts) {
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100388 if (outptr < end_outstr - (10 + TIMESPEC_TEXT_BUFSIZE)) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200389 outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
390 sprint_timespec(outptr, tcp, pts);
391 }
Roland McGrathf17106e2007-11-01 21:49:49 +0000392 }
393
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200394 if (outptr == outstr)
Roland McGrathf17106e2007-11-01 21:49:49 +0000395 return 0;
396
397 tcp->auxstr = outstr;
398 return RVAL_STR;
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200399#undef end_outstr
Roland McGrathaa524c82005-06-01 19:22:06 +0000400 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401}
402
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000403int
404sys_poll(struct tcb *tcp)
405{
Roland McGrathf17106e2007-11-01 21:49:49 +0000406 int rc = decode_poll(tcp, 0);
407 if (entering(tcp)) {
Denys Vlasenkocc902912013-03-05 16:50:12 +0100408# ifdef INFTIM
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000409 if (tcp->u_arg[2] == INFTIM)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200410 tprints("INFTIM");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000411 else
Denys Vlasenkocc902912013-03-05 16:50:12 +0100412# endif
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000413 tprintf("%ld", tcp->u_arg[2]);
414 }
415 return rc;
416}
417
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000418int
419sys_ppoll(struct tcb *tcp)
420{
Roland McGrathf17106e2007-11-01 21:49:49 +0000421 int rc = decode_poll(tcp, tcp->u_arg[2]);
422 if (entering(tcp)) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000423 print_timespec(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200424 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000425 print_sigset(tcp, tcp->u_arg[3], 0);
426 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