blob: ce355e95887057738e0135dfcb554b8ab956e525 [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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000028 */
29
30#include "defs.h"
Mike Frysingerf1639d82014-12-30 19:08:50 -050031#include <fcntl.h>
Dmitry V. Levin0e946ab2015-07-17 23:56:54 +000032#include <signal.h>
Wichert Akkermand856b992000-10-13 12:47:12 +000033#include <sys/timex.h>
Roland McGrath6afc5652007-07-24 01:57:11 +000034
35#ifndef UTIME_NOW
36#define UTIME_NOW ((1l << 30) - 1l)
37#endif
38#ifndef UTIME_OMIT
39#define UTIME_OMIT ((1l << 30) - 2l)
40#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041
Dmitry V. Levine61086f2015-02-27 21:46:42 +000042#if SUPPORTED_PERSONALITIES > 1
43# if defined X86_64 || defined X32
44# define current_time_t_is_compat (current_personality == 1)
45# else
46# define current_time_t_is_compat (current_wordsize == 4)
47# endif
48#else
49# define current_time_t_is_compat 0
50#endif
51
Dmitry V. Levina7945a32006-12-13 17:10:11 +000052struct timeval32
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000054 u_int32_t tv_sec, tv_usec;
55};
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000056
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000057static void
58tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv)
59{
60 tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec);
61}
62
63static void
64tprint_timeval(struct tcb *tcp, const struct timeval *tv)
65{
Dmitry V. Levine61086f2015-02-27 21:46:42 +000066 tprintf("{%ju, %ju}", (uintmax_t) tv->tv_sec, (uintmax_t) tv->tv_usec);
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +000067}
68
Dmitry V. Levina7945a32006-12-13 17:10:11 +000069void
Roland McGrath6afc5652007-07-24 01:57:11 +000070printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Dmitry V. Levina7945a32006-12-13 17:10:11 +000071{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010072 char buf[TIMEVAL_TEXT_BUFSIZE];
73 sprinttv(buf, tcp, addr, bitness, special);
74 tprints(buf);
Dmitry V. Levina7945a32006-12-13 17:10:11 +000075}
Wichert Akkerman221f54f1999-11-18 17:26:45 +000076
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000077static char *
Dmitry V. Levine61086f2015-02-27 21:46:42 +000078do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec,
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000079 const int special)
80{
81 if (special) {
82 switch (usec) {
83 case UTIME_NOW:
84 return stpcpy(buf, "UTIME_NOW");
85 case UTIME_OMIT:
86 return stpcpy(buf, "UTIME_OMIT");
87 }
88 }
Dmitry V. Levine61086f2015-02-27 21:46:42 +000089 return buf + sprintf(buf, "{%ju, %ju}", sec, usec);
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +000090}
91
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020092char *
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +010093sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000094{
Dmitry V. Levina7945a32006-12-13 17:10:11 +000095 if (addr == 0)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +020096 return stpcpy(buf, "NULL");
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000097
Dmitry V. Levin9f702732015-07-16 16:22:07 +000098 if (!verbose(tcp) || (exiting(tcp) && syserror(tcp)))
Denys Vlasenkob9c7ae62011-09-01 11:40:40 +020099 return buf + sprintf(buf, "%#lx", addr);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200100
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000101 if (bitness == BITNESS_32 || current_time_t_is_compat)
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200102 {
103 struct timeval32 tv;
104
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000105 if (umove(tcp, addr, &tv) >= 0)
106 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200107 } else {
108 struct timeval tv;
109
Dmitry V. Levinee21a5b2014-12-26 23:55:38 +0000110 if (umove(tcp, addr, &tv) >= 0)
111 return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special);
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200112 }
Denys Vlasenko2fb4db32011-08-31 12:26:03 +0200113
Dmitry V. Levin9f702732015-07-16 16:22:07 +0000114 return buf + sprintf(buf, "%#lx", addr);
Dmitry V. Levina7945a32006-12-13 17:10:11 +0000115}
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000116
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100117void
118print_timespec(struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000119{
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100120 char buf[TIMESPEC_TEXT_BUFSIZE];
121 sprint_timespec(buf, tcp, addr);
122 tprints(buf);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000123}
124
Denys Vlasenkoa1d541e2012-01-20 11:04:04 +0100125void
126sprint_timespec(char *buf, struct tcb *tcp, long addr)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000127{
128 if (addr == 0)
129 strcpy(buf, "NULL");
130 else if (!verbose(tcp))
131 sprintf(buf, "%#lx", addr);
132 else {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000133 int rc;
Roland McGrath6bc09da2007-11-01 21:50:54 +0000134
Denys Vlasenko84703742012-02-25 02:38:52 +0100135#if SUPPORTED_PERSONALITIES > 1
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000136 if (current_time_t_is_compat) {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000137 struct timeval32 tv;
138
Denys Vlasenko5d645812011-08-20 12:48:18 +0200139 rc = umove(tcp, addr, &tv);
140 if (rc >= 0)
Roland McGrath6bc09da2007-11-01 21:50:54 +0000141 sprintf(buf, "{%u, %u}",
142 tv.tv_sec, tv.tv_usec);
143 } else
Roland McGrath6bc09da2007-11-01 21:50:54 +0000144#endif
Denys Vlasenko1d632462009-04-14 12:51:00 +0000145 {
Roland McGrath6bc09da2007-11-01 21:50:54 +0000146 struct timespec ts;
147
Denys Vlasenko5d645812011-08-20 12:48:18 +0200148 rc = umove(tcp, addr, &ts);
149 if (rc >= 0)
Dmitry V. Levine61086f2015-02-27 21:46:42 +0000150 sprintf(buf, "{%ju, %ju}",
151 (uintmax_t) ts.tv_sec,
152 (uintmax_t) ts.tv_nsec);
Roland McGrath6bc09da2007-11-01 21:50:54 +0000153 }
Roland McGrath6bc09da2007-11-01 21:50:54 +0000154 if (rc < 0)
155 strcpy(buf, "{...}");
156 }
157}
158
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000159SYS_FUNC(gettimeofday)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000160{
161 if (exiting(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000162 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200163 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000164 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000165 }
166 return 0;
167}
168
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000169#ifdef ALPHA
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000170SYS_FUNC(osf_gettimeofday)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000171{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000172 if (exiting(tcp)) {
Denys Vlasenko1d632462009-04-14 12:51:00 +0000173 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200174 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000175 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000176 }
177 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000178}
179#endif
180
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000181SYS_FUNC(settimeofday)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000182{
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000183 printtv(tcp, tcp->u_arg[0]);
184 tprints(", ");
185 printtv(tcp, tcp->u_arg[1]);
186
187 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000188}
189
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000190#ifdef ALPHA
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000191SYS_FUNC(osf_settimeofday)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000192{
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000193 printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0);
194 tprints(", ");
195 printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0);
196
197 return RVAL_DECODED;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000198}
199#endif
200
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000201SYS_FUNC(adjtime)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202{
203 if (entering(tcp)) {
204 printtv(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200205 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000206 } else {
Dmitry V. Levin9f702732015-07-16 16:22:07 +0000207 printtv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000208 }
209 return 0;
210}
211
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000212SYS_FUNC(nanosleep)
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000213{
214 if (entering(tcp)) {
215 print_timespec(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200216 tprints(", ");
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000217 } else {
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100218 /* Second (returned) timespec is only significant
Denys Vlasenko47932212013-06-30 23:53:49 +0200219 * if syscall was interrupted. On success, we print
220 * only its address, since kernel doesn't modify it,
221 * and printing the value may show uninitialized data.
Denys Vlasenko64acaa12012-01-28 02:29:36 +0100222 */
Denys Vlasenko47932212013-06-30 23:53:49 +0200223 switch (tcp->u_error) {
224 default:
225 /* Not interrupted (slept entire interval) */
Dmitry V. Levin71178352015-07-16 18:18:09 +0000226 printaddr(tcp->u_arg[1]);
227 break;
Denys Vlasenko47932212013-06-30 23:53:49 +0200228 case ERESTARTSYS:
229 case ERESTARTNOINTR:
230 case ERESTARTNOHAND:
231 case ERESTART_RESTARTBLOCK:
232 /* Interrupted */
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000233 print_timespec(tcp, tcp->u_arg[1]);
Denys Vlasenko47932212013-06-30 23:53:49 +0200234 }
Dmitry V. Levin2e55ff42008-09-03 01:02:46 +0000235 }
236 return 0;
237}
238
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000239#include "xlat/itimer_which.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000240
241static void
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000242printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000243{
Dmitry V. Levin71178352015-07-16 18:18:09 +0000244 if (bitness == BITNESS_32 || current_time_t_is_compat) {
245 struct {
246 struct timeval32 it_interval, it_value;
247 } itv;
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000248
Dmitry V. Levin71178352015-07-16 18:18:09 +0000249 if (!umove_or_printaddr(tcp, addr, &itv)) {
250 tprints("{it_interval=");
251 tprint_timeval32(tcp, &itv.it_interval);
252 tprints(", it_value=");
253 tprint_timeval32(tcp, &itv.it_value);
254 tprints("}");
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000255 }
Dmitry V. Levin71178352015-07-16 18:18:09 +0000256 } else {
257 struct itimerval itv;
258
259 if (!umove_or_printaddr(tcp, addr, &itv)) {
260 tprints("{it_interval=");
261 tprint_timeval(tcp, &itv.it_interval);
262 tprints(", it_value=");
263 tprint_timeval(tcp, &itv.it_value);
264 tprints("}");
265 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266 }
267}
268
Dmitry V. Levin1cad25d2006-12-13 17:14:36 +0000269#define printitv(tcp, addr) \
270 printitv_bitness((tcp), (addr), BITNESS_CURRENT)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000271
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000272SYS_FUNC(getitimer)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000273{
274 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000275 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200276 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000277 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000278 printitv(tcp, tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000279 }
280 return 0;
281}
282
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000283#ifdef ALPHA
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000284SYS_FUNC(osf_getitimer)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000285{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000286 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000287 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200288 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000289 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000290 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000291 }
292 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000293}
294#endif
295
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000296SYS_FUNC(setitimer)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000297{
298 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000299 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200300 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000301 printitv(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200302 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000304 printitv(tcp, tcp->u_arg[2]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000305 }
306 return 0;
307}
308
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000309#ifdef ALPHA
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000310SYS_FUNC(osf_setitimer)
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000311{
Denys Vlasenko1d632462009-04-14 12:51:00 +0000312 if (entering(tcp)) {
Dmitry V. Levin297b5942014-04-25 23:39:20 +0000313 printxval(itimer_which, tcp->u_arg[0], "ITIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200314 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000315 printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200316 tprints(", ");
Denys Vlasenko1d632462009-04-14 12:51:00 +0000317 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000318 printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32);
Denys Vlasenko1d632462009-04-14 12:51:00 +0000319 }
320 return 0;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000321}
322#endif
323
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000324#include "xlat/adjtimex_state.h"
Dmitry V. Levin1a684d62006-12-13 17:42:32 +0000325
Dmitry V. Levin73215472012-03-11 21:25:51 +0000326static int
327do_adjtimex(struct tcb *tcp, long addr)
328{
Dmitry V. Levindad1eef2015-09-16 21:58:36 +0000329 if (print_timex(tcp, addr))
Dmitry V. Levin73215472012-03-11 21:25:51 +0000330 return 0;
331 tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval);
332 if (tcp->auxstr)
333 return RVAL_STR;
334 return 0;
335}
336
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000337SYS_FUNC(adjtimex)
Dmitry V. Levin165b15d2006-12-13 17:43:45 +0000338{
Dmitry V. Levin73215472012-03-11 21:25:51 +0000339 if (exiting(tcp))
340 return do_adjtimex(tcp, tcp->u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000341 return 0;
342}
Roland McGrath1e356792003-03-30 23:52:28 +0000343
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000344#include "xlat/clockflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000345#include "xlat/clocknames.h"
Roland McGrath54a4edd2004-08-31 06:52:45 +0000346
Stefan Sørensena5fea902014-02-03 10:01:27 +0100347static void
348printclockname(int clockid)
349{
350#ifdef CLOCKID_TO_FD
Dmitry V. Levind35bdca2014-04-26 18:10:19 +0000351# include "xlat/cpuclocknames.h"
352
Stefan Sørensena5fea902014-02-03 10:01:27 +0100353 if (clockid < 0) {
354 if ((clockid & CLOCKFD_MASK) == CLOCKFD)
355 tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid));
356 else {
357 if(CPUCLOCK_PERTHREAD(clockid))
358 tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
359 else
360 tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid));
361 printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???");
362 tprints(")");
363 }
364 }
365 else
366#endif
367 printxval(clocknames, clockid, "CLOCK_???");
368}
369
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000370SYS_FUNC(clock_settime)
Roland McGrath1e356792003-03-30 23:52:28 +0000371{
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000372 printclockname(tcp->u_arg[0]);
373 tprints(", ");
374 printtv(tcp, tcp->u_arg[1]);
375
376 return RVAL_DECODED;
Roland McGrath1e356792003-03-30 23:52:28 +0000377}
378
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000379SYS_FUNC(clock_gettime)
Roland McGrath1e356792003-03-30 23:52:28 +0000380{
381 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100382 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200383 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000384 } else {
Dmitry V. Levin9f702732015-07-16 16:22:07 +0000385 printtv(tcp, tcp->u_arg[1]);
Roland McGrath1e356792003-03-30 23:52:28 +0000386 }
387 return 0;
388}
389
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000390SYS_FUNC(clock_nanosleep)
Roland McGrath1e356792003-03-30 23:52:28 +0000391{
392 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100393 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200394 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000395 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200396 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000397 printtv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200398 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000399 } else {
Dmitry V. Levin9f702732015-07-16 16:22:07 +0000400 printtv(tcp, tcp->u_arg[3]);
Roland McGrath1e356792003-03-30 23:52:28 +0000401 }
402 return 0;
403}
404
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000405SYS_FUNC(clock_adjtime)
Dmitry V. Levin73215472012-03-11 21:25:51 +0000406{
407 if (exiting(tcp))
408 return do_adjtimex(tcp, tcp->u_arg[1]);
Stefan Sørensena5fea902014-02-03 10:01:27 +0100409 printclockname(tcp->u_arg[0]);
Dmitry V. Levin73215472012-03-11 21:25:51 +0000410 tprints(", ");
411 return 0;
412}
413
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000414SYS_FUNC(timer_create)
Roland McGrath1e356792003-03-30 23:52:28 +0000415{
416 if (entering(tcp)) {
Stefan Sørensena5fea902014-02-03 10:01:27 +0100417 printclockname(tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200418 tprints(", ");
Dmitry V. Levin6f950cc2015-09-16 16:31:43 +0000419 print_sigevent(tcp, tcp->u_arg[1]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200420 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000421 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000422 printnum_int(tcp, tcp->u_arg[2], "%d");
Roland McGrath1e356792003-03-30 23:52:28 +0000423 }
424 return 0;
425}
426
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000427SYS_FUNC(timer_settime)
Roland McGrath1e356792003-03-30 23:52:28 +0000428{
429 if (entering(tcp)) {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000430 tprintf("%d, ", (int) tcp->u_arg[0]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000431 printflags(clockflags, tcp->u_arg[1], "TIMER_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200432 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000433 printitv(tcp, tcp->u_arg[2]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200434 tprints(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000435 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000436 printitv(tcp, tcp->u_arg[3]);
Roland McGrath1e356792003-03-30 23:52:28 +0000437 }
438 return 0;
439}
440
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000441SYS_FUNC(timer_gettime)
Roland McGrath1e356792003-03-30 23:52:28 +0000442{
443 if (entering(tcp)) {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000444 tprintf("%d, ", (int) tcp->u_arg[0]);
Roland McGrath1e356792003-03-30 23:52:28 +0000445 } else {
Dmitry V. Levin71178352015-07-16 18:18:09 +0000446 printitv(tcp, tcp->u_arg[1]);
Roland McGrath1e356792003-03-30 23:52:28 +0000447 }
448 return 0;
449}
Roland McGrathd83c50b2004-10-06 22:27:43 +0000450
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000451#include "xlat/timerfdflags.h"
Roland McGrathe4662342007-08-02 01:25:34 +0000452
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000453SYS_FUNC(timerfd)
Roland McGrathe4662342007-08-02 01:25:34 +0000454{
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000455 /* It does not matter that the kernel uses itimerspec. */
456 tprintf("%ld, ", tcp->u_arg[0]);
457 printclockname(tcp->u_arg[0]);
458 tprints(", ");
459 printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
460 tprints(", ");
461 printitv(tcp, tcp->u_arg[3]);
462
Dmitry V. Levin07c878a2015-08-02 01:37:19 +0000463 return RVAL_DECODED | RVAL_FD;
Roland McGrathe4662342007-08-02 01:25:34 +0000464}
Roland McGrathde328e62008-05-20 04:56:13 +0000465
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000466SYS_FUNC(timerfd_create)
Roland McGrathde328e62008-05-20 04:56:13 +0000467{
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000468 printclockname(tcp->u_arg[0]);
469 tprints(", ");
470 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
471
Dmitry V. Levin07c878a2015-08-02 01:37:19 +0000472 return RVAL_DECODED | RVAL_FD;
Roland McGrathde328e62008-05-20 04:56:13 +0000473}
474
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000475SYS_FUNC(timerfd_settime)
Roland McGrathde328e62008-05-20 04:56:13 +0000476{
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000477 printfd(tcp, tcp->u_arg[0]);
478 tprints(", ");
479 printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
480 tprints(", ");
481 printitv(tcp, tcp->u_arg[2]);
482 tprints(", ");
483 printitv(tcp, tcp->u_arg[3]);
484
485 return RVAL_DECODED;
Roland McGrathde328e62008-05-20 04:56:13 +0000486}
487
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000488SYS_FUNC(timerfd_gettime)
Roland McGrathde328e62008-05-20 04:56:13 +0000489{
490 if (entering(tcp)) {
Dmitry V. Levin31382132011-03-04 05:08:02 +0300491 printfd(tcp, tcp->u_arg[0]);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200492 tprints(", ");
Dmitry V. Levin76c8f662015-07-16 21:07:06 +0000493 } else {
Roland McGrathde328e62008-05-20 04:56:13 +0000494 printitv(tcp, tcp->u_arg[1]);
495 }
496 return 0;
497}