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>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
35 #include <linux/version.h>
36 #include <sys/timex.h>
37 #include <linux/ioctl.h>
38 #include <linux/rtc.h>
43 u_int32_t tv_sec, tv_usec;
47 printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
51 else if (!verbose(tcp))
52 tprintf("%#lx", addr);
57 if (bitness == BITNESS_32
58 #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
59 || personality_wordsize[current_personality] == 4
65 if ((rc = umove(tcp, addr, &tv)) >= 0)
67 tv.tv_sec, tv.tv_usec);
72 if ((rc = umove(tcp, addr, &tv)) >= 0)
74 (unsigned long) tv.tv_sec,
75 (unsigned long) tv.tv_usec);
84 sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf)
88 else if (!verbose(tcp))
89 sprintf(buf, "%#lx", addr);
94 if (bitness == BITNESS_32
95 #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1
96 || personality_wordsize[current_personality] == 4
102 if ((rc = umove(tcp, addr, &tv)) >= 0)
103 sprintf(buf, "{%u, %u}",
104 tv.tv_sec, tv.tv_usec);
109 if ((rc = umove(tcp, addr, &tv)) >= 0)
110 sprintf(buf, "{%lu, %lu}",
111 (unsigned long) tv.tv_sec,
112 (unsigned long) tv.tv_usec);
116 strcpy(buf, "{...}");
126 printnum(tcp, tcp->u_arg[0], "%ld");
137 printnum(tcp, tcp->u_arg[0], "%ld");
143 sys_gettimeofday(tcp)
148 tprintf("%#lx, %#lx",
149 tcp->u_arg[0], tcp->u_arg[1]);
152 printtv(tcp, tcp->u_arg[0]);
155 printtv(tcp, tcp->u_arg[1]);
164 sys_osf_gettimeofday(tcp)
169 tprintf("%#lx, %#lx",
170 tcp->u_arg[0], tcp->u_arg[1]);
173 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
176 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
184 sys_settimeofday(tcp)
188 printtv(tcp, tcp->u_arg[0]);
191 printtv(tcp, tcp->u_arg[1]);
199 sys_osf_settimeofday(tcp)
203 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32);
206 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
218 printtv(tcp, tcp->u_arg[0]);
222 tprintf("%#lx", tcp->u_arg[1]);
224 printtv(tcp, tcp->u_arg[1]);
229 static const struct xlat which[] = {
230 { ITIMER_REAL, "ITIMER_REAL" },
231 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
232 { ITIMER_PROF, "ITIMER_PROF" },
241 struct itimerval itv;
245 else if (!verbose(tcp))
246 tprintf("%#lx", addr);
247 else if (umove(tcp, addr, &itv) < 0)
250 tprintf("{it_interval={%lu, %lu}, it_value={%lu, %lu}}",
251 (long) itv.it_interval.tv_sec, (long) itv.it_interval.tv_usec,
252 (long) itv.it_value.tv_sec, (long) itv.it_value.tv_usec);
259 printitv32(tcp, addr)
265 struct timeval32 it_interval;
266 struct timeval32 it_value;
271 else if (!verbose(tcp))
272 tprintf("%#lx", addr);
273 else if (umove(tcp, addr, &itv) < 0)
276 tprintf("{it_interval={%u, %u}, it_value={%u, %u}}",
277 itv.it_interval.tv_sec, itv.it_interval.tv_usec,
278 itv.it_value.tv_sec, itv.it_value.tv_usec);
288 printxval(which, tcp->u_arg[0], "ITIMER_???");
292 tprintf("%#lx", tcp->u_arg[1]);
294 printitv(tcp, tcp->u_arg[1]);
302 sys_osf_getitimer(tcp)
306 printxval(which, tcp->u_arg[0], "ITIMER_???");
310 tprintf("%#lx", tcp->u_arg[1]);
312 printitv32(tcp, tcp->u_arg[1]);
323 printxval(which, tcp->u_arg[0], "ITIMER_???");
325 printitv(tcp, tcp->u_arg[1]);
329 tprintf("%#lx", tcp->u_arg[2]);
331 printitv(tcp, tcp->u_arg[2]);
338 sys_osf_setitimer(tcp)
342 printxval(which, tcp->u_arg[0], "ITIMER_???");
344 printitv32(tcp, tcp->u_arg[1]);
348 tprintf("%#lx", tcp->u_arg[2]);
350 printitv32(tcp, tcp->u_arg[2]);
365 if (tcp->u_arg[0] == 0)
367 else if (syserror(tcp) || !verbose(tcp))
368 tprintf("%#lx", tcp->u_arg[0]);
369 else if (umove(tcp, tcp->u_arg[0], &txc) < 0)
372 #if LINUX_VERSION_CODE < 66332
373 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
374 txc.mode, txc.offset, txc.frequency);
375 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
376 txc.maxerror, txc.esterror, txc.status);
377 tprintf("time_constant=%ld, precision=%lu, ",
378 txc.time_constant, txc.precision);
379 tprintf("tolerance=%ld, time={%lu, %lu}}",
380 txc.tolerance, (long) txc.time.tv_sec,
381 (long) txc.time.tv_usec);
383 tprintf("{modes=%d, offset=%ld, freq=%ld, ",
384 txc.modes, txc.offset, txc.freq);
385 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
386 txc.maxerror, txc.esterror, txc.status);
387 tprintf("constant=%ld, precision=%lu, ",
388 txc.constant, txc.precision);
389 tprintf("tolerance=%ld, time={%lu, %lu}}",
390 txc.tolerance, (long) txc.time.tv_sec,
391 (long) txc.time.tv_usec);
392 /* there's a bunch of other stuff, but it's not
393 * worth the time or the trouble to include */
400 static const struct xlat clockflags[] = {
401 { TIMER_ABSTIME, "TIMER_ABSTIME" },
405 static const struct xlat clocknames[] = {
406 #ifdef CLOCK_REALTIME
407 { CLOCK_REALTIME, "CLOCK_REALTIME" },
409 #ifdef CLOCK_MONOTONIC
410 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
416 sys_clock_settime(tcp)
420 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
422 printtv(tcp, tcp->u_arg[1]);
428 sys_clock_gettime(tcp)
432 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
436 tprintf("%#lx", tcp->u_arg[1]);
438 printtv(tcp, tcp->u_arg[1]);
444 sys_clock_nanosleep(tcp)
448 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
450 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
452 printtv(tcp, tcp->u_arg[2]);
456 tprintf("%#lx", tcp->u_arg[3]);
458 printtv(tcp, tcp->u_arg[3]);
463 #ifndef SIGEV_THREAD_ID
464 # define SIGEV_THREAD_ID 4
466 static const struct xlat sigev_value[] = {
467 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
468 { SIGEV_NONE+1, "SIGEV_NONE" },
469 { SIGEV_THREAD+1, "SIGEV_THREAD" },
470 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
475 printsigevent(tcp, arg)
480 if (umove (tcp, arg, &sev) < 0)
483 tprintf("{%p, ", sev.sigev_value.sival_ptr);
484 if (sev.sigev_notify == SIGEV_SIGNAL)
485 tprintf("%s, ", signame(sev.sigev_signo));
487 tprintf("%u, ", sev.sigev_signo);
488 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
490 if (sev.sigev_notify == SIGEV_THREAD_ID)
491 /* _pad[0] is the _tid field which might not be
492 present in the userlevel definition of the
494 tprintf("{%d}", sev._sigev_un._pad[0]);
495 else if (sev.sigev_notify == SIGEV_THREAD)
496 tprintf("{%p, %p}", sev.sigev_notify_function,
497 sev.sigev_notify_attributes);
505 sys_timer_create(tcp)
509 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
511 printsigevent(tcp, tcp->u_arg[1]);
516 if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &p) < 0)
517 tprintf("%#lx", tcp->u_arg[2]);
525 sys_timer_settime(tcp)
529 tprintf("%#lx, ", tcp->u_arg[0]);
530 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
532 printitv(tcp, tcp->u_arg[2]);
536 tprintf("%#lx", tcp->u_arg[3]);
538 printitv(tcp, tcp->u_arg[3]);
544 sys_timer_gettime(tcp)
548 tprintf("%#lx, ", tcp->u_arg[0]);
551 tprintf("%#lx", tcp->u_arg[1]);
553 printitv(tcp, tcp->u_arg[1]);
561 const struct rtc_time *rt;
563 tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, "
564 "tm_mday=%d, tm_mon=%d, tm_year=%d, ",
565 rt->tm_sec, rt->tm_min, rt->tm_hour,
566 rt->tm_mday, rt->tm_mon, rt->tm_year);
568 tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}",
569 rt->tm_wday, rt->tm_yday, rt->tm_isdst);
575 rtc_ioctl(tcp, code, arg)
585 if (umove(tcp, arg, &rt) < 0)
586 tprintf(", %#lx", arg);
597 if (syserror(tcp) || umove(tcp, arg, &rt) < 0)
598 tprintf(", %#lx", arg);
608 tprintf(", %lu", arg);
613 tprintf(", %lu", arg);
617 struct rtc_wkalrm wk;
618 if (umove(tcp, arg, &wk) < 0)
619 tprintf(", %#lx", arg);
621 tprintf(", {enabled=%d, pending=%d, ",
622 wk.enabled, wk.pending);
623 print_rtc(tcp, &wk.time);
630 struct rtc_wkalrm wk;
631 if (syserror(tcp) || umove(tcp, arg, &wk) < 0)
632 tprintf(", %#lx", arg);
634 tprintf(", {enabled=%d, pending=%d, ",
635 wk.enabled, wk.pending);
636 print_rtc(tcp, &wk.time);
643 tprintf(", %#lx", arg);