blob: c9cbc8ee3cdfee356cb30114f45b5c0b51a995cc [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>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000037#endif /* LINUX */
38
39void
40printtv(tcp, addr)
41struct tcb *tcp;
42long addr;
43{
44 struct timeval tv;
45
46 if (addr == 0)
47 tprintf("NULL");
48 else if (!verbose(tcp))
49 tprintf("%#lx", addr);
50 else if (umove(tcp, addr, &tv) < 0)
51 tprintf("{...}");
52 else
53 tprintf("{%lu, %lu}", (long) tv.tv_sec, (long) tv.tv_usec);
54}
55
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000056#ifdef ALPHA
Wichert Akkerman221f54f1999-11-18 17:26:45 +000057struct timeval32
58{
59 unsigned tv_sec;
60 unsigned tv_usec;
61};
62
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000063void
64printtv32(tcp, addr)
65struct tcb *tcp;
66long addr;
67{
Wichert Akkerman221f54f1999-11-18 17:26:45 +000068 struct timeval32 tv;
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +000069
70 if (addr == 0)
71 tprintf("NULL");
72 else if (!verbose(tcp))
73 tprintf("%#lx", addr);
74 else if (umove(tcp, addr, &tv) < 0)
75 tprintf("{...}");
76 else
77 tprintf("{%u, %u}", tv.tv_sec, tv.tv_usec);
78}
79#endif
80
81
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082int
83sys_time(tcp)
84struct tcb *tcp;
85{
86 if (exiting(tcp)) {
87#ifndef SVR4
88 printnum(tcp, tcp->u_arg[0], "%ld");
89#endif /* SVR4 */
90 }
91 return 0;
92}
93
94int
95sys_stime(tcp)
96struct tcb *tcp;
97{
98 if (exiting(tcp)) {
99 printnum(tcp, tcp->u_arg[0], "%ld");
100 }
101 return 0;
102}
103
104int
105sys_gettimeofday(tcp)
106struct tcb *tcp;
107{
108 if (exiting(tcp)) {
109 if (syserror(tcp)) {
110 tprintf("%#lx, %#lx",
111 tcp->u_arg[0], tcp->u_arg[1]);
112 return 0;
113 }
114 printtv(tcp, tcp->u_arg[0]);
115#ifndef SVR4
116 tprintf(", ");
117 printtv(tcp, tcp->u_arg[1]);
118#endif /* !SVR4 */
119 }
120 return 0;
121}
122
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000123
124#ifdef ALPHA
125int
126sys_osf_gettimeofday(tcp)
127struct tcb *tcp;
128{
129 if (exiting(tcp)) {
130 if (syserror(tcp)) {
131 tprintf("%#lx, %#lx",
132 tcp->u_arg[0], tcp->u_arg[1]);
133 return 0;
134 }
135 printtv32(tcp, tcp->u_arg[0]);
136#ifndef SVR4
137 tprintf(", ");
138 printtv32(tcp, tcp->u_arg[1]);
139#endif /* !SVR4 */
140 }
141 return 0;
142}
143#endif
144
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000145int
146sys_settimeofday(tcp)
147struct tcb *tcp;
148{
149 if (entering(tcp)) {
150 printtv(tcp, tcp->u_arg[0]);
151#ifndef SVR4
152 tprintf(", ");
153 printtv(tcp, tcp->u_arg[1]);
154#endif /* !SVR4 */
155 }
156 return 0;
157}
158
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000159#ifdef ALPHA
160int
161sys_osf_settimeofday(tcp)
162struct tcb *tcp;
163{
164 if (entering(tcp)) {
165 printtv32(tcp, tcp->u_arg[0]);
166#ifndef SVR4
167 tprintf(", ");
168 printtv32(tcp, tcp->u_arg[1]);
169#endif /* !SVR4 */
170 }
171 return 0;
172}
173#endif
174
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175int
176sys_adjtime(tcp)
177struct tcb *tcp;
178{
179 if (entering(tcp)) {
180 printtv(tcp, tcp->u_arg[0]);
181 tprintf(", ");
182 } else {
183 if (syserror(tcp))
184 tprintf("%#lx", tcp->u_arg[1]);
185 else
186 printtv(tcp, tcp->u_arg[1]);
187 }
188 return 0;
189}
190
191static struct xlat which[] = {
192 { ITIMER_REAL, "ITIMER_REAL" },
193 { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},
194 { ITIMER_PROF, "ITIMER_PROF" },
195 { 0, NULL },
196};
197
198static void
199printitv(tcp, addr)
200struct tcb *tcp;
201long addr;
202{
203 struct itimerval itv;
204
205 if (addr == 0)
206 tprintf("NULL");
207 else if (!verbose(tcp))
208 tprintf("%#lx", addr);
209 else if (umove(tcp, addr, &itv) < 0)
210 tprintf("{...}");
211 else {
212 tprintf("{it_interval={%lu, %lu}, it_value={%lu, %lu}}",
213 (long) itv.it_interval.tv_sec, (long) itv.it_interval.tv_usec,
214 (long) itv.it_value.tv_sec, (long) itv.it_value.tv_usec);
215 }
216}
217
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000218
219#ifdef ALPHA
220static void
221printitv32(tcp, addr)
222struct tcb *tcp;
223long addr;
224{
225 struct itimerval32
226 {
227 struct timeval32 it_interval;
228 struct timeval32 it_value;
229 } itv;
230
231 if (addr == 0)
232 tprintf("NULL");
233 else if (!verbose(tcp))
234 tprintf("%#lx", addr);
235 else if (umove(tcp, addr, &itv) < 0)
236 tprintf("{...}");
237 else {
238 tprintf("{it_interval={%u, %u}, it_value={%u, %u}}",
239 itv.it_interval.tv_sec, itv.it_interval.tv_usec,
240 itv.it_value.tv_sec, itv.it_value.tv_usec);
241 }
242}
243#endif
244
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000245int
246sys_getitimer(tcp)
247struct tcb *tcp;
248{
249 if (entering(tcp)) {
250 printxval(which, tcp->u_arg[0], "ITIMER_???");
251 tprintf(", ");
252 } else {
253 if (syserror(tcp))
254 tprintf("%#lx", tcp->u_arg[1]);
255 else
256 printitv(tcp, tcp->u_arg[1]);
257 }
258 return 0;
259}
260
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000261
262#ifdef ALPHA
263int
264sys_osf_getitimer(tcp)
265struct tcb *tcp;
266{
267 if (entering(tcp)) {
268 printxval(which, tcp->u_arg[0], "ITIMER_???");
269 tprintf(", ");
270 } else {
271 if (syserror(tcp))
272 tprintf("%#lx", tcp->u_arg[1]);
273 else
274 printitv32(tcp, tcp->u_arg[1]);
275 }
276 return 0;
277}
278#endif
279
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000280int
281sys_setitimer(tcp)
282struct tcb *tcp;
283{
284 if (entering(tcp)) {
285 printxval(which, tcp->u_arg[0], "ITIMER_???");
286 tprintf(", ");
287 printitv(tcp, tcp->u_arg[1]);
288 tprintf(", ");
289 } else {
290 if (syserror(tcp))
291 tprintf("%#lx", tcp->u_arg[2]);
292 else
293 printitv(tcp, tcp->u_arg[2]);
294 }
295 return 0;
296}
297
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000298#ifdef ALPHA
299int
300sys_osf_setitimer(tcp)
301struct tcb *tcp;
302{
303 if (entering(tcp)) {
304 printxval(which, tcp->u_arg[0], "ITIMER_???");
305 tprintf(", ");
306 printitv32(tcp, tcp->u_arg[1]);
307 tprintf(", ");
308 } else {
309 if (syserror(tcp))
310 tprintf("%#lx", tcp->u_arg[2]);
311 else
312 printitv32(tcp, tcp->u_arg[2]);
313 }
314 return 0;
315}
316#endif
317
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000318#ifdef LINUX
319
320int
321sys_adjtimex(tcp)
322struct tcb *tcp;
323{
324 struct timex txc;
325
326 if (exiting(tcp)) {
327 if (tcp->u_arg[0] == 0)
328 tprintf("NULL");
329 else if (syserror(tcp) || !verbose(tcp))
330 tprintf("%#lx", tcp->u_arg[0]);
331 else if (umove(tcp, tcp->u_arg[0], &txc) < 0)
332 tprintf("{...}");
333 else {
334#if LINUX_VERSION_CODE < 66332
335 tprintf("{mode=%d, offset=%ld, frequency=%ld, ",
336 txc.mode, txc.offset, txc.frequency);
337 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
338 txc.maxerror, txc.esterror, txc.status);
339 tprintf("time_constant=%ld, precision=%lu, ",
340 txc.time_constant, txc.precision);
341 tprintf("tolerance=%ld, time={%lu, %lu}}",
342 txc.tolerance, (long) txc.time.tv_sec,
343 (long) txc.time.tv_usec);
344#else
345 tprintf("{modes=%d, offset=%ld, freq=%ld, ",
346 txc.modes, txc.offset, txc.freq);
347 tprintf("maxerror=%ld, esterror=%lu, status=%u, ",
348 txc.maxerror, txc.esterror, txc.status);
349 tprintf("constant=%ld, precision=%lu, ",
350 txc.constant, txc.precision);
351 tprintf("tolerance=%ld, time={%lu, %lu}}",
352 txc.tolerance, (long) txc.time.tv_sec,
353 (long) txc.time.tv_usec);
354 /* there's a bunch of other stuff, but it's not
355 * worth the time or the trouble to include */
356#endif
357 }
358 }
359 return 0;
360}
361#endif /* LINUX */
362