blob: 139af0f4b4d567634b6a7dfcdf1bc84b5dbf326e [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
2 * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3 * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4 * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * $Id$
30 */
31
32#include "defs.h"
33
34#ifdef LINUX
35#include <linux/version.h>
Wichert Akkermand856b992000-10-13 12:47:12 +000036#include <sys/timex.h>
Roland McGrathd83c50b2004-10-06 22:27:43 +000037#include <linux/ioctl.h>
38#include <linux/rtc.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039#endif /* LINUX */
40
Dmitry V. Levina7945a32006-12-13 17:10:11 +000041struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000042{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000043 u_int32_t tv_sec, tv_usec;
44};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000046static void
47tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
48{
49 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
50}
51
52static void
53tprint_timeval(struct tcb *tcp, const struct timeval *tv)
54{
55 tprintf("{%lu, %lu}",
56 (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec);
57}
58
Dmitry V. Levina7945a32006-12-13 17:10:11 +000059void
60printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
61{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000062 if (addr == 0)
63 tprintf("NULL");
64 else if (!verbose(tcp))
65 tprintf("%#lx", addr);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000066 else
Dmitry V. Levina7945a32006-12-13 17:10:11 +000067 {
68 int rc;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000069
Dmitry V. Levina7945a32006-12-13 17:10:11 +000070 if (bitness == BITNESS_32
71#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
72 || personality_wordsize[current_personality] == 4
73#endif
74 )
75 {
76 struct timeval32 tv;
77
78 if ((rc = umove(tcp, addr, &tv)) >= 0)
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000079 tprint_timeval32(tcp, &tv);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000080 } else
81 {
82 struct timeval tv;
83
84 if ((rc = umove(tcp, addr, &tv)) >= 0)
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000085 tprint_timeval(tcp, &tv);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000086 }
87
88 if (rc < 0)
89 tprintf("{...}");
90 }
91}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000092
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000093void
Dmitry V. Levina7945a32006-12-13 17:10:11 +000094sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000095{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000096 if (addr == 0)
97 strcpy(buf, "NULL");
98 else if (!verbose(tcp))
99 sprintf(buf, "%#lx", addr);
100 else
101 {
102 int rc;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000103
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000104 if (bitness == BITNESS_32
105#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
106 || personality_wordsize[current_personality] == 4
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000107#endif
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000108 )
109 {
110 struct timeval32 tv;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000111
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000112 if ((rc = umove(tcp, addr, &tv)) >= 0)
113 sprintf(buf, "{%u, %u}",
114 tv.tv_sec, tv.tv_usec);
115 } else
116 {
117 struct timeval tv;
118
119 if ((rc = umove(tcp, addr, &tv)) >= 0)
120 sprintf(buf, "{%lu, %lu}",
121 (unsigned long) tv.tv_sec,
122 (unsigned long) tv.tv_usec);
123 }
124
125 if (rc < 0)
126 strcpy(buf, "{...}");
127 }
128}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000129
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000130int
131sys_time(tcp)
132struct tcb *tcp;
133{
134 if (exiting(tcp)) {
135#ifndef SVR4
136 printnum(tcp, tcp->u_arg[0], "%ld");
137#endif /* SVR4 */
138 }
139 return 0;
140}
141
142int
143sys_stime(tcp)
144struct tcb *tcp;
145{
146 if (exiting(tcp)) {
147 printnum(tcp, tcp->u_arg[0], "%ld");
148 }
149 return 0;
150}
151
152int
153sys_gettimeofday(tcp)
154struct tcb *tcp;
155{
156 if (exiting(tcp)) {
157 if (syserror(tcp)) {
158 tprintf("%#lx, %#lx",
159 tcp->u_arg[0], tcp->u_arg[1]);
160 return 0;
161 }
162 printtv(tcp, tcp->u_arg[0]);
163#ifndef SVR4
164 tprintf(", ");
165 printtv(tcp, tcp->u_arg[1]);
166#endif /* !SVR4 */
167 }
168 return 0;
169}
170
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000171
172#ifdef ALPHA
173int
174sys_osf_gettimeofday(tcp)
175struct tcb *tcp;
176{
177 if (exiting(tcp)) {
178 if (syserror(tcp)) {
179 tprintf("%#lx, %#lx",
180 tcp->u_arg[0], tcp->u_arg[1]);
181 return 0;
182 }
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000183 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000184#ifndef SVR4
185 tprintf(", ");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000186 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000187#endif /* !SVR4 */
188 }
189 return 0;
190}
191#endif
192
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000193int
194sys_settimeofday(tcp)
195struct tcb *tcp;
196{
197 if (entering(tcp)) {
198 printtv(tcp, tcp->u_arg[0]);
199#ifndef SVR4
200 tprintf(", ");
201 printtv(tcp, tcp->u_arg[1]);
202#endif /* !SVR4 */
203 }
204 return 0;
205}
206
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000207#ifdef ALPHA
208int
209sys_osf_settimeofday(tcp)
210struct tcb *tcp;
211{
212 if (entering(tcp)) {
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000213 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000214#ifndef SVR4
215 tprintf(", ");
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000216 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000217#endif /* !SVR4 */
218 }
219 return 0;
220}
221#endif
222
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000223int
224sys_adjtime(tcp)
225struct tcb *tcp;
226{
227 if (entering(tcp)) {
228 printtv(tcp, tcp->u_arg[0]);
229 tprintf(", ");
230 } else {
231 if (syserror(tcp))
232 tprintf("%#lx", tcp->u_arg[1]);
233 else
234 printtv(tcp, tcp->u_arg[1]);
235 }
236 return 0;
237}
238
Roland McGrathd9f816f2004-09-04 03:39:20 +0000239static const struct xlat which[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000240 { ITIMER_REAL, "ITIMER_REAL" },
241 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
242 { ITIMER_PROF, "ITIMER_PROF" },
243 { 0, NULL },
244};
245
246static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000247printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000249 if (addr == 0)
250 tprintf("NULL");
251 else if (!verbose(tcp))
252 tprintf("%#lx", addr);
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000253 else
254 {
255 int rc;
256
257 if (bitness == BITNESS_32
258#if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
259 || personality_wordsize[current_personality] == 4
260#endif
261 )
262 {
263 struct
264 {
265 struct timeval32 it_interval, it_value;
266 } itv;
267
268 if ((rc = umove(tcp, addr, &itv)) >= 0)
269 tprintf("{it_interval=");
270 tprint_timeval32(tcp, &itv.it_interval);
271 tprintf(", it_value=");
272 tprint_timeval32(tcp, &itv.it_value);
273 tprintf("}");
274 } else
275 {
276 struct itimerval itv;
277
278 if ((rc = umove(tcp, addr, &itv)) >= 0)
279 tprintf("{it_interval=");
280 tprint_timeval(tcp, &itv.it_interval);
281 tprintf(", it_value=");
282 tprint_timeval(tcp, &itv.it_value);
283 tprintf("}");
284 }
285
286 if (rc < 0)
287 tprintf("{...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000288 }
289}
290
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000291#define printitv(tcp, addr) \
292 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000293
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294int
295sys_getitimer(tcp)
296struct tcb *tcp;
297{
298 if (entering(tcp)) {
299 printxval(which, tcp->u_arg[0], "ITIMER_???");
300 tprintf(", ");
301 } else {
302 if (syserror(tcp))
303 tprintf("%#lx", tcp->u_arg[1]);
304 else
305 printitv(tcp, tcp->u_arg[1]);
306 }
307 return 0;
308}
309
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000310
311#ifdef ALPHA
312int
313sys_osf_getitimer(tcp)
314struct tcb *tcp;
315{
316 if (entering(tcp)) {
317 printxval(which, tcp->u_arg[0], "ITIMER_???");
318 tprintf(", ");
319 } else {
320 if (syserror(tcp))
321 tprintf("%#lx", tcp->u_arg[1]);
322 else
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000323 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000324 }
325 return 0;
326}
327#endif
328
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000329int
330sys_setitimer(tcp)
331struct tcb *tcp;
332{
333 if (entering(tcp)) {
334 printxval(which, tcp->u_arg[0], "ITIMER_???");
335 tprintf(", ");
336 printitv(tcp, tcp->u_arg[1]);
337 tprintf(", ");
338 } else {
339 if (syserror(tcp))
340 tprintf("%#lx", tcp->u_arg[2]);
341 else
342 printitv(tcp, tcp->u_arg[2]);
343 }
344 return 0;
345}
346
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000347#ifdef ALPHA
348int
349sys_osf_setitimer(tcp)
350struct tcb *tcp;
351{
352 if (entering(tcp)) {
353 printxval(which, tcp->u_arg[0], "ITIMER_???");
354 tprintf(", ");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000355 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000356 tprintf(", ");
357 } else {
358 if (syserror(tcp))
359 tprintf("%#lx", tcp->u_arg[2]);
360 else
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000361 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000362 }
363 return 0;
364}
365#endif
366
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000367#ifdef LINUX
368
369int
370sys_adjtimex(tcp)
371struct tcb *tcp;
372{
373 struct timex txc;
374
375 if (exiting(tcp)) {
376 if (tcp->u_arg[0] == 0)
377 tprintf("NULL");
378 else if (syserror(tcp) || !verbose(tcp))
379 tprintf("%#lx", tcp->u_arg[0]);
380 else if (umove(tcp, tcp->u_arg[0], &txc) < 0)
381 tprintf("{...}");
382 else {
383#if LINUX_VERSION_CODE < 66332
384 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
385 txc.mode, txc.offset, txc.frequency);
386 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
387 txc.maxerror, txc.esterror, txc.status);
388 tprintf("time_constant=%ld, precision=%lu, ",
389 txc.time_constant, txc.precision);
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000390 tprintf("tolerance=%ld, time=", txc.tolerance);
391 tprint_timeval(tcp, &txc.time);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392#else
393 tprintf("{modes=%d, offset=%ld, freq=%ld, ",
394 txc.modes, txc.offset, txc.freq);
395 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
396 txc.maxerror, txc.esterror, txc.status);
397 tprintf("constant=%ld, precision=%lu, ",
398 txc.constant, txc.precision);
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000399 tprintf("tolerance=%ld, time=", txc.tolerance);
400 tprint_timeval(tcp, &txc.time);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000401 /* there's a bunch of other stuff, but it's not
402 * worth the time or the trouble to include */
403#endif
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000404 tprintf("}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000405 }
406 }
407 return 0;
408}
Roland McGrath1e356792003-03-30 23:52:28 +0000409
Roland McGrathd9f816f2004-09-04 03:39:20 +0000410static const struct xlat clockflags[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000411 { TIMER_ABSTIME, "TIMER_ABSTIME" },
412 { 0, NULL }
413};
414
Roland McGrathd9f816f2004-09-04 03:39:20 +0000415static const struct xlat clocknames[] = {
Roland McGrath55a00f82004-08-31 08:26:39 +0000416#ifdef CLOCK_REALTIME
Roland McGrath54a4edd2004-08-31 06:52:45 +0000417 { CLOCK_REALTIME, "CLOCK_REALTIME" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000418#endif
419#ifdef CLOCK_MONOTONIC
Roland McGrath54a4edd2004-08-31 06:52:45 +0000420 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
Roland McGrath55a00f82004-08-31 08:26:39 +0000421#endif
Roland McGrath54a4edd2004-08-31 06:52:45 +0000422 { 0, NULL }
423};
424
Roland McGrath1e356792003-03-30 23:52:28 +0000425int
426sys_clock_settime(tcp)
427struct tcb *tcp;
428{
429 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000430 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
431 tprintf(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000432 printtv(tcp, tcp->u_arg[1]);
433 }
434 return 0;
435}
436
437int
438sys_clock_gettime(tcp)
439struct tcb *tcp;
440{
441 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000442 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
443 tprintf(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000444 } else {
445 if (syserror(tcp))
446 tprintf("%#lx", tcp->u_arg[1]);
447 else
448 printtv(tcp, tcp->u_arg[1]);
449 }
450 return 0;
451}
452
453int
454sys_clock_nanosleep(tcp)
455struct tcb *tcp;
456{
457 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000458 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
459 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000460 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Roland McGrath1e356792003-03-30 23:52:28 +0000461 tprintf(", ");
462 printtv(tcp, tcp->u_arg[2]);
463 tprintf(", ");
464 } else {
465 if (syserror(tcp))
466 tprintf("%#lx", tcp->u_arg[3]);
467 else
468 printtv(tcp, tcp->u_arg[3]);
469 }
470 return 0;
471}
472
473#ifndef SIGEV_THREAD_ID
474# define SIGEV_THREAD_ID 4
475#endif
Roland McGrathd9f816f2004-09-04 03:39:20 +0000476static const struct xlat sigev_value[] = {
Roland McGrath1e356792003-03-30 23:52:28 +0000477 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
478 { SIGEV_NONE+1, "SIGEV_NONE" },
479 { SIGEV_THREAD+1, "SIGEV_THREAD" },
480 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
481 { 0, NULL }
482};
483
484void
485printsigevent(tcp, arg)
486struct tcb *tcp;
487long arg;
488{
489 struct sigevent sev;
490 if (umove (tcp, arg, &sev) < 0)
491 tprintf("{...}");
492 else {
Roland McGrath675d4a62004-09-11 08:12:45 +0000493 tprintf("{%p, ", sev.sigev_value.sival_ptr);
494 if (sev.sigev_notify == SIGEV_SIGNAL)
495 tprintf("%s, ", signame(sev.sigev_signo));
496 else
497 tprintf("%u, ", sev.sigev_signo);
Roland McGrath1e356792003-03-30 23:52:28 +0000498 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
499 tprintf(", ");
500 if (sev.sigev_notify == SIGEV_THREAD_ID)
501 /* _pad[0] is the _tid field which might not be
502 present in the userlevel definition of the
503 struct. */
504 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000505 else if (sev.sigev_notify == SIGEV_THREAD)
506 tprintf("{%p, %p}", sev.sigev_notify_function,
507 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000508 else
509 tprintf("{...}");
510 tprintf("}");
511 }
512}
513
514int
515sys_timer_create(tcp)
516struct tcb *tcp;
517{
518 if (entering(tcp)) {
Roland McGrath675d4a62004-09-11 08:12:45 +0000519 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
520 tprintf(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000521 printsigevent(tcp, tcp->u_arg[1]);
522 tprintf(", ");
523 } else {
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000524 void *p;
525
526 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &p) < 0)
Roland McGrath1e356792003-03-30 23:52:28 +0000527 tprintf("%#lx", tcp->u_arg[2]);
Dmitry V. Levinac518d12006-12-13 17:03:02 +0000528 else
Roland McGrath1e356792003-03-30 23:52:28 +0000529 tprintf("{%p}", p);
Roland McGrath1e356792003-03-30 23:52:28 +0000530 }
531 return 0;
532}
533
534int
535sys_timer_settime(tcp)
536struct tcb *tcp;
537{
538 if (entering(tcp)) {
539 tprintf("%#lx, ", tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000540 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Roland McGrath1e356792003-03-30 23:52:28 +0000541 tprintf(", ");
542 printitv(tcp, tcp->u_arg[2]);
543 tprintf(", ");
544 } else {
545 if (syserror(tcp))
546 tprintf("%#lx", tcp->u_arg[3]);
547 else
548 printitv(tcp, tcp->u_arg[3]);
549 }
550 return 0;
551}
552
553int
554sys_timer_gettime(tcp)
555struct tcb *tcp;
556{
557 if (entering(tcp)) {
558 tprintf("%#lx, ", tcp->u_arg[0]);
559 } else {
560 if (syserror(tcp))
561 tprintf("%#lx", tcp->u_arg[1]);
562 else
563 printitv(tcp, tcp->u_arg[1]);
564 }
565 return 0;
566}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000567
568static void
569print_rtc(tcp, rt)
570struct tcb *tcp;
571const struct rtc_time *rt;
572{
573 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
574 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
575 rt->tm_sec, rt->tm_min, rt->tm_hour,
576 rt->tm_mday, rt->tm_mon, rt->tm_year);
577 if (!abbrev(tcp))
578 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
579 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
580 else
581 tprintf("...}");
582}
583
584int
585rtc_ioctl(tcp, code, arg)
586struct tcb *tcp;
587long code;
588long arg;
589{
590 switch (code) {
591 case RTC_ALM_SET:
592 case RTC_SET_TIME:
593 if (entering(tcp)) {
594 struct rtc_time rt;
595 if (umove(tcp, arg, &rt) < 0)
596 tprintf(", %#lx", arg);
597 else {
598 tprintf(", ");
599 print_rtc(tcp, &rt);
600 }
601 }
602 break;
603 case RTC_ALM_READ:
604 case RTC_RD_TIME:
605 if (exiting(tcp)) {
606 struct rtc_time rt;
607 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
608 tprintf(", %#lx", arg);
609 else {
610 tprintf(", ");
611 print_rtc(tcp, &rt);
612 }
613 }
614 break;
615 case RTC_IRQP_SET:
616 case RTC_EPOCH_SET:
617 if (entering(tcp))
618 tprintf(", %lu", arg);
619 break;
620 case RTC_IRQP_READ:
621 case RTC_EPOCH_READ:
622 if (exiting(tcp))
623 tprintf(", %lu", arg);
624 break;
625 case RTC_WKALM_SET:
626 if (entering(tcp)) {
627 struct rtc_wkalrm wk;
628 if (umove(tcp, arg, &wk) < 0)
629 tprintf(", %#lx", arg);
630 else {
631 tprintf(", {enabled=%d, pending=%d, ",
632 wk.enabled, wk.pending);
633 print_rtc(tcp, &wk.time);
634 tprintf("}");
635 }
636 }
637 break;
638 case RTC_WKALM_RD:
639 if (exiting(tcp)) {
640 struct rtc_wkalrm wk;
641 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
642 tprintf(", %#lx", arg);
643 else {
644 tprintf(", {enabled=%d, pending=%d, ",
645 wk.enabled, wk.pending);
646 print_rtc(tcp, &wk.time);
647 tprintf("}");
648 }
649 }
650 break;
651 default:
652 if (entering(tcp))
653 tprintf(", %#lx", arg);
654 break;
655 }
656 return 1;
657}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000658#endif /* LINUX */