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