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.
33 #include <sys/timex.h>
36 #define UTIME_NOW ((1l << 30) - 1l)
39 #define UTIME_OMIT ((1l << 30) - 2l)
42 #if SUPPORTED_PERSONALITIES > 1
43 # if defined X86_64 || defined X32
44 # define current_time_t_is_compat (current_personality == 1)
46 # define current_time_t_is_compat (current_wordsize == 4)
49 # define current_time_t_is_compat 0
54 u_int32_t tv_sec, tv_usec;
58 printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
60 char buf[TIMEVAL_TEXT_BUFSIZE];
61 sprinttv(buf, tcp, addr, bitness, special);
66 do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec,
72 return stpcpy(buf, "UTIME_NOW");
74 return stpcpy(buf, "UTIME_OMIT");
77 return buf + sprintf(buf, "{%ju, %ju}", sec, usec);
81 sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
84 return stpcpy(buf, "NULL");
86 if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
87 return buf + sprintf(buf, "%#lx", addr);
89 if (bitness == BITNESS_32 || current_time_t_is_compat)
93 if (umove(tcp, addr, &tv) >= 0)
94 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
98 if (umove(tcp, addr, &tv) >= 0)
99 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
102 return buf + sprintf(buf, "%#lx", addr);
106 print_timespec(struct tcb *tcp, long addr)
108 char buf[TIMESPEC_TEXT_BUFSIZE];
109 sprint_timespec(buf, tcp, addr);
114 sprint_timespec(char *buf, struct tcb *tcp, long addr)
118 else if (!verbose(tcp))
119 sprintf(buf, "%#lx", addr);
123 #if SUPPORTED_PERSONALITIES > 1
124 if (current_time_t_is_compat) {
127 rc = umove(tcp, addr, &tv);
129 sprintf(buf, "{%u, %u}",
130 tv.tv_sec, tv.tv_usec);
136 rc = umove(tcp, addr, &ts);
138 sprintf(buf, "{%ju, %ju}",
139 (uintmax_t) ts.tv_sec,
140 (uintmax_t) ts.tv_nsec);
143 strcpy(buf, "{...}");
147 SYS_FUNC(gettimeofday)
150 printtv(tcp, tcp->u_arg[0]);
152 printtv(tcp, tcp->u_arg[1]);
158 SYS_FUNC(osf_gettimeofday)
161 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
163 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
169 SYS_FUNC(settimeofday)
171 printtv(tcp, tcp->u_arg[0]);
173 printtv(tcp, tcp->u_arg[1]);
179 SYS_FUNC(osf_settimeofday)
181 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
183 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
192 print_timespec(tcp, tcp->u_arg[0]);
197 * Second (returned) timespec is only significant if syscall
198 * was interrupted. On success and in case of other errors we
199 * print only its address, since kernel doesn't modify it,
200 * and printing the value may show uninitialized data.
202 if (is_erestart(tcp)) {
203 temporarily_clear_syserror(tcp);
204 print_timespec(tcp, tcp->u_arg[1]);
205 restore_cleared_syserror(tcp);
207 printaddr(tcp->u_arg[1]);
213 #include "xlat/itimer_which.h"
218 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
221 print_itimerval(tcp, tcp->u_arg[1]);
227 SYS_FUNC(osf_getitimer)
230 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
233 print_itimerval32(tcp, tcp->u_arg[1]);
242 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
244 print_itimerval(tcp, tcp->u_arg[1]);
247 print_itimerval(tcp, tcp->u_arg[2]);
253 SYS_FUNC(osf_setitimer)
256 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
258 print_itimerval32(tcp, tcp->u_arg[1]);
261 print_itimerval32(tcp, tcp->u_arg[2]);
267 #include "xlat/adjtimex_state.h"
270 do_adjtimex(struct tcb *tcp, long addr)
272 if (print_timex(tcp, addr))
274 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
283 return do_adjtimex(tcp, tcp->u_arg[0]);
287 #include "xlat/clockflags.h"
288 #include "xlat/clocknames.h"
291 printclockname(int clockid)
294 # include "xlat/cpuclocknames.h"
297 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
298 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
300 if(CPUCLOCK_PERTHREAD(clockid))
301 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
303 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
304 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
310 printxval(clocknames, clockid, "CLOCK_???");
313 SYS_FUNC(clock_settime)
315 printclockname(tcp->u_arg[0]);
317 printtv(tcp, tcp->u_arg[1]);
322 SYS_FUNC(clock_gettime)
325 printclockname(tcp->u_arg[0]);
328 printtv(tcp, tcp->u_arg[1]);
333 SYS_FUNC(clock_nanosleep)
336 printclockname(tcp->u_arg[0]);
338 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
340 printtv(tcp, tcp->u_arg[2]);
344 * Second (returned) timespec is only significant
345 * if syscall was interrupted and flags is not TIMER_ABSTIME.
347 if (!tcp->u_arg[1] && is_erestart(tcp)) {
348 temporarily_clear_syserror(tcp);
349 printtv(tcp, tcp->u_arg[3]);
350 restore_cleared_syserror(tcp);
352 printaddr(tcp->u_arg[3]);
358 SYS_FUNC(clock_adjtime)
361 return do_adjtimex(tcp, tcp->u_arg[1]);
362 printclockname(tcp->u_arg[0]);
367 SYS_FUNC(timer_create)
370 printclockname(tcp->u_arg[0]);
372 print_sigevent(tcp, tcp->u_arg[1]);
375 printnum_int(tcp, tcp->u_arg[2], "%d");
380 SYS_FUNC(timer_settime)
383 tprintf("%d, ", (int) tcp->u_arg[0]);
384 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
386 print_itimerspec(tcp, tcp->u_arg[2]);
389 print_itimerspec(tcp, tcp->u_arg[3]);
394 SYS_FUNC(timer_gettime)
397 tprintf("%d, ", (int) tcp->u_arg[0]);
399 print_itimerspec(tcp, tcp->u_arg[1]);
404 #include "xlat/timerfdflags.h"
408 tprintf("%ld, ", tcp->u_arg[0]);
409 printclockname(tcp->u_arg[0]);
411 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
413 print_itimerspec(tcp, tcp->u_arg[3]);
415 return RVAL_DECODED | RVAL_FD;
418 SYS_FUNC(timerfd_create)
420 printclockname(tcp->u_arg[0]);
422 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
424 return RVAL_DECODED | RVAL_FD;
427 SYS_FUNC(timerfd_settime)
429 printfd(tcp, tcp->u_arg[0]);
431 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
433 print_itimerspec(tcp, tcp->u_arg[2]);
435 print_itimerspec(tcp, tcp->u_arg[3]);
440 SYS_FUNC(timerfd_gettime)
443 printfd(tcp, tcp->u_arg[0]);
446 print_itimerspec(tcp, tcp->u_arg[1]);