blob: 28c05bd28243fd652d57e185b6a33dece53fc441 [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}
Roland McGrath1e356792003-03-30 23:52:28 +0000361
362static struct xlat clockflags[] = {
363 { TIMER_ABSTIME, "TIMER_ABSTIME" },
364 { 0, NULL }
365};
366
Roland McGrath54a4edd2004-08-31 06:52:45 +0000367static struct xlat clocknames[] = {
368 { CLOCK_REALTIME, "CLOCK_REALTIME" },
369 { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" },
370 { 0, NULL }
371};
372
Roland McGrath1e356792003-03-30 23:52:28 +0000373int
374sys_clock_settime(tcp)
375struct tcb *tcp;
376{
377 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000378 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
379 tprintf(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000380 printtv(tcp, tcp->u_arg[1]);
381 }
382 return 0;
383}
384
385int
386sys_clock_gettime(tcp)
387struct tcb *tcp;
388{
389 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000390 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
391 tprintf(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000392 } else {
393 if (syserror(tcp))
394 tprintf("%#lx", tcp->u_arg[1]);
395 else
396 printtv(tcp, tcp->u_arg[1]);
397 }
398 return 0;
399}
400
401int
402sys_clock_nanosleep(tcp)
403struct tcb *tcp;
404{
405 if (entering(tcp)) {
Roland McGrath54a4edd2004-08-31 06:52:45 +0000406 printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
407 tprintf(", ");
Roland McGrath1e356792003-03-30 23:52:28 +0000408 printflags(clockflags, tcp->u_arg[1]);
409 tprintf(", ");
410 printtv(tcp, tcp->u_arg[2]);
411 tprintf(", ");
412 } else {
413 if (syserror(tcp))
414 tprintf("%#lx", tcp->u_arg[3]);
415 else
416 printtv(tcp, tcp->u_arg[3]);
417 }
418 return 0;
419}
420
421#ifndef SIGEV_THREAD_ID
422# define SIGEV_THREAD_ID 4
423#endif
424static struct xlat sigev_value[] = {
425 { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" },
426 { SIGEV_NONE+1, "SIGEV_NONE" },
427 { SIGEV_THREAD+1, "SIGEV_THREAD" },
428 { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" },
429 { 0, NULL }
430};
431
432void
433printsigevent(tcp, arg)
434struct tcb *tcp;
435long arg;
436{
437 struct sigevent sev;
438 if (umove (tcp, arg, &sev) < 0)
439 tprintf("{...}");
440 else {
441 tprintf("{%p, %u, ", sev.sigev_value.sival_ptr,
442 sev.sigev_signo);
443 printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???");
444 tprintf(", ");
445 if (sev.sigev_notify == SIGEV_THREAD_ID)
446 /* _pad[0] is the _tid field which might not be
447 present in the userlevel definition of the
448 struct. */
449 tprintf("{%d}", sev._sigev_un._pad[0]);
Roland McGrathd4c85eb2004-04-16 21:48:44 +0000450 else if (sev.sigev_notify == SIGEV_THREAD)
451 tprintf("{%p, %p}", sev.sigev_notify_function,
452 sev.sigev_notify_attributes);
Roland McGrath1e356792003-03-30 23:52:28 +0000453 else
454 tprintf("{...}");
455 tprintf("}");
456 }
457}
458
459int
460sys_timer_create(tcp)
461struct tcb *tcp;
462{
463 if (entering(tcp)) {
464 tprintf("%#lx, ", tcp->u_arg[0]);
465 printsigevent(tcp, tcp->u_arg[1]);
466 tprintf(", ");
467 } else {
468 if (syserror(tcp))
469 tprintf("%#lx", tcp->u_arg[2]);
470 else {
471 void *p;
472 umove(tcp, tcp->u_arg[2], &p);
473 tprintf("{%p}", p);
474 }
475 }
476 return 0;
477}
478
479int
480sys_timer_settime(tcp)
481struct tcb *tcp;
482{
483 if (entering(tcp)) {
484 tprintf("%#lx, ", tcp->u_arg[0]);
485 printflags(clockflags, tcp->u_arg[1]);
486 tprintf(", ");
487 printitv(tcp, tcp->u_arg[2]);
488 tprintf(", ");
489 } else {
490 if (syserror(tcp))
491 tprintf("%#lx", tcp->u_arg[3]);
492 else
493 printitv(tcp, tcp->u_arg[3]);
494 }
495 return 0;
496}
497
498int
499sys_timer_gettime(tcp)
500struct tcb *tcp;
501{
502 if (entering(tcp)) {
503 tprintf("%#lx, ", tcp->u_arg[0]);
504 } else {
505 if (syserror(tcp))
506 tprintf("%#lx", tcp->u_arg[1]);
507 else
508 printitv(tcp, tcp->u_arg[1]);
509 }
510 return 0;
511}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512#endif /* LINUX */
513