blob: 3eb7dde5a7f1bca847aa91bf653b5af27e453f74 [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.
27 *
28 * $Id$
29 */
30
31#include "defs.h"
Roland McGrath34e014a2002-12-16 20:40:59 +000032#include <sys/syscall.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000033
Wichert Akkerman42080d82001-04-10 10:32:26 +000034#ifdef HAVE_POLL_H
35#include <poll.h>
36#endif
Pavel Machek245a6ac2000-02-01 16:12:33 +000037#ifdef HAVE_SYS_POLL_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000038#include <sys/poll.h>
Pavel Machek245a6ac2000-02-01 16:12:33 +000039#endif
Wichert Akkerman42080d82001-04-10 10:32:26 +000040#ifdef HAVE_STROPTS_H
41#include <stropts.h>
42#endif
43#ifdef HAVE_SYS_CONF_H
44#include <sys/conf.h>
45#endif
46#ifdef HAVE_SYS_STREAM_H
47#include <sys/stream.h>
48#endif
49#ifdef HAVE_SYS_TIHDR_H
50#include <sys/tihdr.h>
51#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052
Wichert Akkerman42080d82001-04-10 10:32:26 +000053
54#ifndef HAVE_STROPTS_H
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000055#define RS_HIPRI 1
56struct strbuf {
Denys Vlasenkoadedb512008-12-30 18:47:55 +000057 int maxlen; /* no. of bytes in buffer */
58 int len; /* no. of bytes returned */
Dmitry V. Levin30145dd2010-09-06 22:08:24 +000059 const char *buf; /* pointer to data */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000060};
61#define MORECTL 1
62#define MOREDATA 2
Wichert Akkerman42080d82001-04-10 10:32:26 +000063#endif /* !HAVE_STROPTS_H */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000064
65#ifdef HAVE_SYS_TIUSER_H
66#include <sys/tiuser.h>
67#include <sys/sockmod.h>
68#include <sys/timod.h>
69#endif /* HAVE_SYS_TIUSER_H */
70
Roland McGrathd9f816f2004-09-04 03:39:20 +000071static const struct xlat msgflags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072 { RS_HIPRI, "RS_HIPRI" },
73 { 0, NULL },
74};
75
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000076
77static void
Denys Vlasenko12014262011-05-30 14:00:14 +020078printstrbuf(struct tcb *tcp, struct strbuf *sbp, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000079{
80 if (sbp->maxlen == -1 && getting)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020081 tprints("{maxlen=-1}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020083 tprints("{");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000084 if (getting)
85 tprintf("maxlen=%d, ", sbp->maxlen);
86 tprintf("len=%d, buf=", sbp->len);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000087 printstr(tcp, (unsigned long) sbp->buf, sbp->len);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020088 tprints("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000089 }
90}
91
92static void
Denys Vlasenko12014262011-05-30 14:00:14 +020093printstrbufarg(struct tcb *tcp, int arg, int getting)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000094{
95 struct strbuf buf;
96
97 if (arg == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020098 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000099 else if (umove(tcp, arg, &buf) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200100 tprints("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000101 else
102 printstrbuf(tcp, &buf, getting);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200103 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104}
105
106int
Denys Vlasenko12014262011-05-30 14:00:14 +0200107sys_putmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000108{
109 int i;
110
111 if (entering(tcp)) {
112 /* fd */
113 tprintf("%ld, ", tcp->u_arg[0]);
114 /* control and data */
115 for (i = 1; i < 3; i++)
116 printstrbufarg(tcp, tcp->u_arg[i], 0);
117 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000118 printflags(msgflags, tcp->u_arg[3], "RS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000119 }
120 return 0;
121}
122
Denys Vlasenko84703742012-02-25 02:38:52 +0100123#if defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000124int
Denys Vlasenko12014262011-05-30 14:00:14 +0200125sys_getmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000126{
127 int i, flags;
128
129 if (entering(tcp)) {
130 /* fd */
131 tprintf("%lu, ", tcp->u_arg[0]);
132 } else {
133 if (syserror(tcp)) {
134 tprintf("%#lx, %#lx, %#lx",
135 tcp->u_arg[1], tcp->u_arg[2], tcp->u_arg[3]);
136 return 0;
137 }
138 /* control and data */
139 for (i = 1; i < 3; i++)
140 printstrbufarg(tcp, tcp->u_arg[i], 1);
141 /* pointer to flags */
142 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200143 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000144 else if (umove(tcp, tcp->u_arg[3], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200145 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000146 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200147 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000148 printflags(msgflags, flags, "RS_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200149 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150 }
151 /* decode return value */
152 switch (tcp->u_rval) {
153 case MORECTL:
154 tcp->auxstr = "MORECTL";
155 break;
156 case MORECTL|MOREDATA:
157 tcp->auxstr = "MORECTL|MOREDATA";
158 break;
159 case MOREDATA:
160 tcp->auxstr = "MORECTL";
161 break;
162 default:
163 tcp->auxstr = NULL;
164 break;
165 }
166 }
167 return RVAL_HEX | RVAL_STR;
168}
Denys Vlasenko84703742012-02-25 02:38:52 +0100169#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000170
Roland McGrath34e014a2002-12-16 20:40:59 +0000171#if defined SYS_putpmsg || defined SYS_getpmsg
Roland McGrathd9f816f2004-09-04 03:39:20 +0000172static const struct xlat pmsgflags[] = {
Wichert Akkermand856b992000-10-13 12:47:12 +0000173#ifdef MSG_HIPRI
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000174 { MSG_HIPRI, "MSG_HIPRI" },
Wichert Akkermand856b992000-10-13 12:47:12 +0000175#endif
176#ifdef MSG_AND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000177 { MSG_ANY, "MSG_ANY" },
Wichert Akkermand856b992000-10-13 12:47:12 +0000178#endif
179#ifdef MSG_BAND
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180 { MSG_BAND, "MSG_BAND" },
Wichert Akkermand856b992000-10-13 12:47:12 +0000181#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182 { 0, NULL },
183};
Roland McGrath34e014a2002-12-16 20:40:59 +0000184#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000185
Roland McGrath34e014a2002-12-16 20:40:59 +0000186#ifdef SYS_putpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187int
Denys Vlasenko12014262011-05-30 14:00:14 +0200188sys_putpmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189{
190 int i;
191
192 if (entering(tcp)) {
193 /* fd */
194 tprintf("%ld, ", tcp->u_arg[0]);
195 /* control and data */
196 for (i = 1; i < 3; i++)
197 printstrbufarg(tcp, tcp->u_arg[i], 0);
198 /* band */
199 tprintf("%ld, ", tcp->u_arg[3]);
200 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000201 printflags(pmsgflags, tcp->u_arg[4], "MSG_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202 }
203 return 0;
204}
Roland McGrath34e014a2002-12-16 20:40:59 +0000205#endif /* SYS_putpmsg */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206
Roland McGrath34e014a2002-12-16 20:40:59 +0000207#ifdef SYS_getpmsg
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000208int
Denys Vlasenko12014262011-05-30 14:00:14 +0200209sys_getpmsg(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000210{
211 int i, flags;
212
213 if (entering(tcp)) {
214 /* fd */
215 tprintf("%lu, ", tcp->u_arg[0]);
216 } else {
217 if (syserror(tcp)) {
218 tprintf("%#lx, %#lx, %#lx, %#lx", tcp->u_arg[1],
219 tcp->u_arg[2], tcp->u_arg[3], tcp->u_arg[4]);
220 return 0;
221 }
222 /* control and data */
223 for (i = 1; i < 3; i++)
224 printstrbufarg(tcp, tcp->u_arg[i], 1);
225 /* pointer to band */
226 printnum(tcp, tcp->u_arg[3], "%d");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200227 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228 /* pointer to flags */
229 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200230 tprints("NULL");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231 else if (umove(tcp, tcp->u_arg[4], &flags) < 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200232 tprints("[?]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000233 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200234 tprints("[");
Roland McGrathb2dee132005-06-01 19:02:36 +0000235 printflags(pmsgflags, flags, "MSG_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200236 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000237 }
238 /* decode return value */
239 switch (tcp->u_rval) {
240 case MORECTL:
241 tcp->auxstr = "MORECTL";
242 break;
243 case MORECTL|MOREDATA:
244 tcp->auxstr = "MORECTL|MOREDATA";
245 break;
246 case MOREDATA:
247 tcp->auxstr = "MORECTL";
248 break;
249 default:
250 tcp->auxstr = NULL;
251 break;
252 }
253 }
254 return RVAL_HEX | RVAL_STR;
255}
Roland McGrath34e014a2002-12-16 20:40:59 +0000256#endif /* SYS_getpmsg */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000257
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000258
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000260#ifdef HAVE_SYS_POLL_H
261
Roland McGrathd9f816f2004-09-04 03:39:20 +0000262static const struct xlat pollflags[] = {
Pavel Machek245a6ac2000-02-01 16:12:33 +0000263#ifdef POLLIN
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000264 { POLLIN, "POLLIN" },
265 { POLLPRI, "POLLPRI" },
266 { POLLOUT, "POLLOUT" },
267#ifdef POLLRDNORM
268 { POLLRDNORM, "POLLRDNORM" },
269#endif
270#ifdef POLLWRNORM
271 { POLLWRNORM, "POLLWRNORM" },
272#endif
273#ifdef POLLRDBAND
274 { POLLRDBAND, "POLLRDBAND" },
275#endif
276#ifdef POLLWRBAND
277 { POLLWRBAND, "POLLWRBAND" },
278#endif
279 { POLLERR, "POLLERR" },
280 { POLLHUP, "POLLHUP" },
281 { POLLNVAL, "POLLNVAL" },
Pavel Machek245a6ac2000-02-01 16:12:33 +0000282#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000283 { 0, NULL },
284};
285
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000286static int
Roland McGrathf17106e2007-11-01 21:49:49 +0000287decode_poll(struct tcb *tcp, long pts)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000288{
Roland McGrathaa524c82005-06-01 19:22:06 +0000289 struct pollfd fds;
290 unsigned nfds;
291 unsigned long size, start, cur, end, abbrev_end;
292 int failed = 0;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000293
Roland McGrathf17106e2007-11-01 21:49:49 +0000294 if (entering(tcp)) {
295 nfds = tcp->u_arg[1];
296 size = sizeof(fds) * nfds;
297 start = tcp->u_arg[0];
298 end = start + size;
299 if (nfds == 0 || size / sizeof(fds) != nfds || end < start) {
300 tprintf("%#lx, %d, ",
301 tcp->u_arg[0], nfds);
302 return 0;
303 }
304 if (abbrev(tcp)) {
305 abbrev_end = start + max_strlen * sizeof(fds);
306 if (abbrev_end < start)
307 abbrev_end = end;
308 } else {
Roland McGrathaa524c82005-06-01 19:22:06 +0000309 abbrev_end = end;
Roland McGrathf17106e2007-11-01 21:49:49 +0000310 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200311 tprints("[");
Roland McGrathf17106e2007-11-01 21:49:49 +0000312 for (cur = start; cur < end; cur += sizeof(fds)) {
313 if (cur > start)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200314 tprints(", ");
Roland McGrathf17106e2007-11-01 21:49:49 +0000315 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200316 tprints("...");
Roland McGrathf17106e2007-11-01 21:49:49 +0000317 break;
318 }
319 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200320 tprints("?");
Roland McGrathf17106e2007-11-01 21:49:49 +0000321 failed = 1;
322 break;
323 }
324 if (fds.fd < 0) {
325 tprintf("{fd=%d}", fds.fd);
326 continue;
327 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200328 tprints("{fd=");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300329 printfd(tcp, fds.fd);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200330 tprints(", events=");
Roland McGrathf17106e2007-11-01 21:49:49 +0000331 printflags(pollflags, fds.events, "POLL???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200332 tprints("}");
Roland McGrathf17106e2007-11-01 21:49:49 +0000333 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200334 tprints("]");
Roland McGrathf17106e2007-11-01 21:49:49 +0000335 if (failed)
336 tprintf(" %#lx", start);
337 tprintf(", %d, ", nfds);
338 return 0;
Roland McGrathaa524c82005-06-01 19:22:06 +0000339 } else {
Roland McGrathf17106e2007-11-01 21:49:49 +0000340 static char outstr[1024];
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200341 char *outptr;
342#define end_outstr (outstr + sizeof(outstr))
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000343 const char *flagstr;
Roland McGrathf17106e2007-11-01 21:49:49 +0000344
345 if (syserror(tcp))
346 return 0;
347 if (tcp->u_rval == 0) {
348 tcp->auxstr = "Timeout";
349 return RVAL_STR;
350 }
351
352 nfds = tcp->u_arg[1];
353 size = sizeof(fds) * nfds;
354 start = tcp->u_arg[0];
355 end = start + size;
356 if (nfds == 0 || size / sizeof(fds) != nfds || end < start)
357 return 0;
358 if (abbrev(tcp)) {
359 abbrev_end = start + max_strlen * sizeof(fds);
360 if (abbrev_end < start)
361 abbrev_end = end;
362 } else {
363 abbrev_end = end;
364 }
365
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200366 outptr = outstr;
Roland McGrathf17106e2007-11-01 21:49:49 +0000367
368 for (cur = start; cur < end; cur += sizeof(fds)) {
369 if (umoven(tcp, cur, sizeof fds, (char *) &fds) < 0) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200370 if (outptr < end_outstr - 2)
371 *outptr++ = '?';
Roland McGrathf17106e2007-11-01 21:49:49 +0000372 failed = 1;
373 break;
374 }
375 if (!fds.revents)
376 continue;
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200377 if (outptr == outstr) {
378 *outptr++ = '[';
Roland McGrathf17106e2007-11-01 21:49:49 +0000379 } else {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200380 if (outptr < end_outstr - 3)
381 outptr = stpcpy(outptr, ", ");
Roland McGrathf17106e2007-11-01 21:49:49 +0000382 }
383 if (cur >= abbrev_end) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200384 if (outptr < end_outstr - 4)
385 outptr = stpcpy(outptr, "...");
Roland McGrathf17106e2007-11-01 21:49:49 +0000386 break;
387 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200388 if (outptr < end_outstr - (sizeof("{fd=%d, revents=") + sizeof(int)*3) + 1)
389 outptr += sprintf(outptr, "{fd=%d, revents=", fds.fd);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200390 flagstr = sprintflags("", pollflags, fds.revents);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200391 if (outptr < end_outstr - (strlen(flagstr) + 2)) {
392 outptr = stpcpy(outptr, flagstr);
393 *outptr++ = '}';
Roland McGrathf17106e2007-11-01 21:49:49 +0000394 }
395 }
396 if (failed)
397 return 0;
398
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200399 if (outptr != outstr /* && outptr < end_outstr - 1 (always true)*/)
400 *outptr++ = ']';
Roland McGrathf17106e2007-11-01 21:49:49 +0000401
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200402 *outptr = '\0';
Roland McGrathf17106e2007-11-01 21:49:49 +0000403 if (pts) {
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100404 if (outptr < end_outstr - (10 + TIMESPEC_TEXT_BUFSIZE)) {
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200405 outptr = stpcpy(outptr, outptr == outstr ? "left " : ", left ");
406 sprint_timespec(outptr, tcp, pts);
407 }
Roland McGrathf17106e2007-11-01 21:49:49 +0000408 }
409
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200410 if (outptr == outstr)
Roland McGrathf17106e2007-11-01 21:49:49 +0000411 return 0;
412
413 tcp->auxstr = outstr;
414 return RVAL_STR;
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200415#undef end_outstr
Roland McGrathaa524c82005-06-01 19:22:06 +0000416 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000417}
418
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000419int
420sys_poll(struct tcb *tcp)
421{
Roland McGrathf17106e2007-11-01 21:49:49 +0000422 int rc = decode_poll(tcp, 0);
423 if (entering(tcp)) {
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000424#ifdef INFTIM
425 if (tcp->u_arg[2] == INFTIM)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200426 tprints("INFTIM");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000427 else
428#endif
429 tprintf("%ld", tcp->u_arg[2]);
430 }
431 return rc;
432}
433
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000434int
435sys_ppoll(struct tcb *tcp)
436{
Roland McGrathf17106e2007-11-01 21:49:49 +0000437 int rc = decode_poll(tcp, tcp->u_arg[2]);
438 if (entering(tcp)) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000439 print_timespec(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200440 tprints(", ");
Dmitry V. Levin95ebf5a2006-10-13 20:25:12 +0000441 print_sigset(tcp, tcp->u_arg[3], 0);
442 tprintf(", %lu", tcp->u_arg[4]);
443 }
444 return rc;
445}
Roland McGrathaa524c82005-06-01 19:22:06 +0000446
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000447#else /* !HAVE_SYS_POLL_H */
448int
Denys Vlasenko12014262011-05-30 14:00:14 +0200449sys_poll(struct tcb *tcp)
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000450{
Denys Vlasenko5ae2b7c2009-02-27 20:32:52 +0000451 return 0;
Wichert Akkermanfaf72222000-02-19 23:59:03 +0000452}
453#endif
454
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000455