Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 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 Akkerman | d856b99 | 2000-10-13 12:47:12 +0000 | [diff] [blame] | 36 | #include <sys/timex.h> |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 37 | #include <linux/ioctl.h> |
| 38 | #include <linux/rtc.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | #endif /* LINUX */ |
| 40 | |
| 41 | void |
| 42 | printtv(tcp, addr) |
| 43 | struct tcb *tcp; |
| 44 | long addr; |
| 45 | { |
| 46 | struct timeval tv; |
| 47 | |
| 48 | if (addr == 0) |
| 49 | tprintf("NULL"); |
| 50 | else if (!verbose(tcp)) |
| 51 | tprintf("%#lx", addr); |
| 52 | else if (umove(tcp, addr, &tv) < 0) |
| 53 | tprintf("{...}"); |
| 54 | else |
| 55 | tprintf("{%lu, %lu}", (long) tv.tv_sec, (long) tv.tv_usec); |
| 56 | } |
| 57 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 58 | #ifdef ALPHA |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 59 | struct timeval32 |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 60 | { |
| 61 | unsigned tv_sec; |
| 62 | unsigned tv_usec; |
| 63 | }; |
| 64 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 65 | void |
| 66 | printtv32(tcp, addr) |
| 67 | struct tcb *tcp; |
| 68 | long addr; |
| 69 | { |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 70 | struct timeval32 tv; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 71 | |
| 72 | if (addr == 0) |
| 73 | tprintf("NULL"); |
| 74 | else if (!verbose(tcp)) |
| 75 | tprintf("%#lx", addr); |
| 76 | else if (umove(tcp, addr, &tv) < 0) |
| 77 | tprintf("{...}"); |
| 78 | else |
| 79 | tprintf("{%u, %u}", tv.tv_sec, tv.tv_usec); |
| 80 | } |
| 81 | #endif |
| 82 | |
| 83 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | int |
| 85 | sys_time(tcp) |
| 86 | struct tcb *tcp; |
| 87 | { |
| 88 | if (exiting(tcp)) { |
| 89 | #ifndef SVR4 |
| 90 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 91 | #endif /* SVR4 */ |
| 92 | } |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | int |
| 97 | sys_stime(tcp) |
| 98 | struct tcb *tcp; |
| 99 | { |
| 100 | if (exiting(tcp)) { |
| 101 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 102 | } |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | int |
| 107 | sys_gettimeofday(tcp) |
| 108 | struct tcb *tcp; |
| 109 | { |
| 110 | if (exiting(tcp)) { |
| 111 | if (syserror(tcp)) { |
| 112 | tprintf("%#lx, %#lx", |
| 113 | tcp->u_arg[0], tcp->u_arg[1]); |
| 114 | return 0; |
| 115 | } |
| 116 | printtv(tcp, tcp->u_arg[0]); |
| 117 | #ifndef SVR4 |
| 118 | tprintf(", "); |
| 119 | printtv(tcp, tcp->u_arg[1]); |
| 120 | #endif /* !SVR4 */ |
| 121 | } |
| 122 | return 0; |
| 123 | } |
| 124 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 125 | |
| 126 | #ifdef ALPHA |
| 127 | int |
| 128 | sys_osf_gettimeofday(tcp) |
| 129 | struct tcb *tcp; |
| 130 | { |
| 131 | if (exiting(tcp)) { |
| 132 | if (syserror(tcp)) { |
| 133 | tprintf("%#lx, %#lx", |
| 134 | tcp->u_arg[0], tcp->u_arg[1]); |
| 135 | return 0; |
| 136 | } |
| 137 | printtv32(tcp, tcp->u_arg[0]); |
| 138 | #ifndef SVR4 |
| 139 | tprintf(", "); |
| 140 | printtv32(tcp, tcp->u_arg[1]); |
| 141 | #endif /* !SVR4 */ |
| 142 | } |
| 143 | return 0; |
| 144 | } |
| 145 | #endif |
| 146 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 147 | int |
| 148 | sys_settimeofday(tcp) |
| 149 | struct tcb *tcp; |
| 150 | { |
| 151 | if (entering(tcp)) { |
| 152 | printtv(tcp, tcp->u_arg[0]); |
| 153 | #ifndef SVR4 |
| 154 | tprintf(", "); |
| 155 | printtv(tcp, tcp->u_arg[1]); |
| 156 | #endif /* !SVR4 */ |
| 157 | } |
| 158 | return 0; |
| 159 | } |
| 160 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 161 | #ifdef ALPHA |
| 162 | int |
| 163 | sys_osf_settimeofday(tcp) |
| 164 | struct tcb *tcp; |
| 165 | { |
| 166 | if (entering(tcp)) { |
| 167 | printtv32(tcp, tcp->u_arg[0]); |
| 168 | #ifndef SVR4 |
| 169 | tprintf(", "); |
| 170 | printtv32(tcp, tcp->u_arg[1]); |
| 171 | #endif /* !SVR4 */ |
| 172 | } |
| 173 | return 0; |
| 174 | } |
| 175 | #endif |
| 176 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 177 | int |
| 178 | sys_adjtime(tcp) |
| 179 | struct tcb *tcp; |
| 180 | { |
| 181 | if (entering(tcp)) { |
| 182 | printtv(tcp, tcp->u_arg[0]); |
| 183 | tprintf(", "); |
| 184 | } else { |
| 185 | if (syserror(tcp)) |
| 186 | tprintf("%#lx", tcp->u_arg[1]); |
| 187 | else |
| 188 | printtv(tcp, tcp->u_arg[1]); |
| 189 | } |
| 190 | return 0; |
| 191 | } |
| 192 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 193 | static const struct xlat which[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | { ITIMER_REAL, "ITIMER_REAL" }, |
| 195 | { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"}, |
| 196 | { ITIMER_PROF, "ITIMER_PROF" }, |
| 197 | { 0, NULL }, |
| 198 | }; |
| 199 | |
| 200 | static void |
| 201 | printitv(tcp, addr) |
| 202 | struct tcb *tcp; |
| 203 | long addr; |
| 204 | { |
| 205 | struct itimerval itv; |
| 206 | |
| 207 | if (addr == 0) |
| 208 | tprintf("NULL"); |
| 209 | else if (!verbose(tcp)) |
| 210 | tprintf("%#lx", addr); |
| 211 | else if (umove(tcp, addr, &itv) < 0) |
| 212 | tprintf("{...}"); |
| 213 | else { |
| 214 | tprintf("{it_interval={%lu, %lu}, it_value={%lu, %lu}}", |
| 215 | (long) itv.it_interval.tv_sec, (long) itv.it_interval.tv_usec, |
| 216 | (long) itv.it_value.tv_sec, (long) itv.it_value.tv_usec); |
| 217 | } |
| 218 | } |
| 219 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 220 | |
| 221 | #ifdef ALPHA |
| 222 | static void |
| 223 | printitv32(tcp, addr) |
| 224 | struct tcb *tcp; |
| 225 | long addr; |
| 226 | { |
| 227 | struct itimerval32 |
| 228 | { |
| 229 | struct timeval32 it_interval; |
| 230 | struct timeval32 it_value; |
| 231 | } itv; |
| 232 | |
| 233 | if (addr == 0) |
| 234 | tprintf("NULL"); |
| 235 | else if (!verbose(tcp)) |
| 236 | tprintf("%#lx", addr); |
| 237 | else if (umove(tcp, addr, &itv) < 0) |
| 238 | tprintf("{...}"); |
| 239 | else { |
| 240 | tprintf("{it_interval={%u, %u}, it_value={%u, %u}}", |
| 241 | itv.it_interval.tv_sec, itv.it_interval.tv_usec, |
| 242 | itv.it_value.tv_sec, itv.it_value.tv_usec); |
| 243 | } |
| 244 | } |
| 245 | #endif |
| 246 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | int |
| 248 | sys_getitimer(tcp) |
| 249 | struct tcb *tcp; |
| 250 | { |
| 251 | if (entering(tcp)) { |
| 252 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 253 | tprintf(", "); |
| 254 | } else { |
| 255 | if (syserror(tcp)) |
| 256 | tprintf("%#lx", tcp->u_arg[1]); |
| 257 | else |
| 258 | printitv(tcp, tcp->u_arg[1]); |
| 259 | } |
| 260 | return 0; |
| 261 | } |
| 262 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 263 | |
| 264 | #ifdef ALPHA |
| 265 | int |
| 266 | sys_osf_getitimer(tcp) |
| 267 | struct tcb *tcp; |
| 268 | { |
| 269 | if (entering(tcp)) { |
| 270 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 271 | tprintf(", "); |
| 272 | } else { |
| 273 | if (syserror(tcp)) |
| 274 | tprintf("%#lx", tcp->u_arg[1]); |
| 275 | else |
| 276 | printitv32(tcp, tcp->u_arg[1]); |
| 277 | } |
| 278 | return 0; |
| 279 | } |
| 280 | #endif |
| 281 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 282 | int |
| 283 | sys_setitimer(tcp) |
| 284 | struct tcb *tcp; |
| 285 | { |
| 286 | if (entering(tcp)) { |
| 287 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 288 | tprintf(", "); |
| 289 | printitv(tcp, tcp->u_arg[1]); |
| 290 | tprintf(", "); |
| 291 | } else { |
| 292 | if (syserror(tcp)) |
| 293 | tprintf("%#lx", tcp->u_arg[2]); |
| 294 | else |
| 295 | printitv(tcp, tcp->u_arg[2]); |
| 296 | } |
| 297 | return 0; |
| 298 | } |
| 299 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 300 | #ifdef ALPHA |
| 301 | int |
| 302 | sys_osf_setitimer(tcp) |
| 303 | struct tcb *tcp; |
| 304 | { |
| 305 | if (entering(tcp)) { |
| 306 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 307 | tprintf(", "); |
| 308 | printitv32(tcp, tcp->u_arg[1]); |
| 309 | tprintf(", "); |
| 310 | } else { |
| 311 | if (syserror(tcp)) |
| 312 | tprintf("%#lx", tcp->u_arg[2]); |
| 313 | else |
| 314 | printitv32(tcp, tcp->u_arg[2]); |
| 315 | } |
| 316 | return 0; |
| 317 | } |
| 318 | #endif |
| 319 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 320 | #ifdef LINUX |
| 321 | |
| 322 | int |
| 323 | sys_adjtimex(tcp) |
| 324 | struct tcb *tcp; |
| 325 | { |
| 326 | struct timex txc; |
| 327 | |
| 328 | if (exiting(tcp)) { |
| 329 | if (tcp->u_arg[0] == 0) |
| 330 | tprintf("NULL"); |
| 331 | else if (syserror(tcp) || !verbose(tcp)) |
| 332 | tprintf("%#lx", tcp->u_arg[0]); |
| 333 | else if (umove(tcp, tcp->u_arg[0], &txc) < 0) |
| 334 | tprintf("{...}"); |
| 335 | else { |
| 336 | #if LINUX_VERSION_CODE < 66332 |
| 337 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 338 | txc.mode, txc.offset, txc.frequency); |
| 339 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 340 | txc.maxerror, txc.esterror, txc.status); |
| 341 | tprintf("time_constant=%ld, precision=%lu, ", |
| 342 | txc.time_constant, txc.precision); |
| 343 | tprintf("tolerance=%ld, time={%lu, %lu}}", |
| 344 | txc.tolerance, (long) txc.time.tv_sec, |
| 345 | (long) txc.time.tv_usec); |
| 346 | #else |
| 347 | tprintf("{modes=%d, offset=%ld, freq=%ld, ", |
| 348 | txc.modes, txc.offset, txc.freq); |
| 349 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 350 | txc.maxerror, txc.esterror, txc.status); |
| 351 | tprintf("constant=%ld, precision=%lu, ", |
| 352 | txc.constant, txc.precision); |
| 353 | tprintf("tolerance=%ld, time={%lu, %lu}}", |
| 354 | txc.tolerance, (long) txc.time.tv_sec, |
| 355 | (long) txc.time.tv_usec); |
| 356 | /* there's a bunch of other stuff, but it's not |
| 357 | * worth the time or the trouble to include */ |
| 358 | #endif |
| 359 | } |
| 360 | } |
| 361 | return 0; |
| 362 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 363 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 364 | static const struct xlat clockflags[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 365 | { TIMER_ABSTIME, "TIMER_ABSTIME" }, |
| 366 | { 0, NULL } |
| 367 | }; |
| 368 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 369 | static const struct xlat clocknames[] = { |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 370 | #ifdef CLOCK_REALTIME |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 371 | { CLOCK_REALTIME, "CLOCK_REALTIME" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 372 | #endif |
| 373 | #ifdef CLOCK_MONOTONIC |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 374 | { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 375 | #endif |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 376 | { 0, NULL } |
| 377 | }; |
| 378 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 379 | int |
| 380 | sys_clock_settime(tcp) |
| 381 | struct tcb *tcp; |
| 382 | { |
| 383 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 384 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 385 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 386 | printtv(tcp, tcp->u_arg[1]); |
| 387 | } |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | int |
| 392 | sys_clock_gettime(tcp) |
| 393 | struct tcb *tcp; |
| 394 | { |
| 395 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 396 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 397 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 398 | } else { |
| 399 | if (syserror(tcp)) |
| 400 | tprintf("%#lx", tcp->u_arg[1]); |
| 401 | else |
| 402 | printtv(tcp, tcp->u_arg[1]); |
| 403 | } |
| 404 | return 0; |
| 405 | } |
| 406 | |
| 407 | int |
| 408 | sys_clock_nanosleep(tcp) |
| 409 | struct tcb *tcp; |
| 410 | { |
| 411 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 412 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 413 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 414 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 415 | tprintf(", "); |
| 416 | printtv(tcp, tcp->u_arg[2]); |
| 417 | tprintf(", "); |
| 418 | } else { |
| 419 | if (syserror(tcp)) |
| 420 | tprintf("%#lx", tcp->u_arg[3]); |
| 421 | else |
| 422 | printtv(tcp, tcp->u_arg[3]); |
| 423 | } |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | #ifndef SIGEV_THREAD_ID |
| 428 | # define SIGEV_THREAD_ID 4 |
| 429 | #endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 430 | static const struct xlat sigev_value[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 431 | { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" }, |
| 432 | { SIGEV_NONE+1, "SIGEV_NONE" }, |
| 433 | { SIGEV_THREAD+1, "SIGEV_THREAD" }, |
| 434 | { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" }, |
| 435 | { 0, NULL } |
| 436 | }; |
| 437 | |
| 438 | void |
| 439 | printsigevent(tcp, arg) |
| 440 | struct tcb *tcp; |
| 441 | long arg; |
| 442 | { |
| 443 | struct sigevent sev; |
| 444 | if (umove (tcp, arg, &sev) < 0) |
| 445 | tprintf("{...}"); |
| 446 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 447 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 448 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 449 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 450 | else |
| 451 | tprintf("%u, ", sev.sigev_signo); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 452 | printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???"); |
| 453 | tprintf(", "); |
| 454 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 455 | /* _pad[0] is the _tid field which might not be |
| 456 | present in the userlevel definition of the |
| 457 | struct. */ |
| 458 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 459 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 460 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 461 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 462 | else |
| 463 | tprintf("{...}"); |
| 464 | tprintf("}"); |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | int |
| 469 | sys_timer_create(tcp) |
| 470 | struct tcb *tcp; |
| 471 | { |
| 472 | if (entering(tcp)) { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 473 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 474 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 475 | printsigevent(tcp, tcp->u_arg[1]); |
| 476 | tprintf(", "); |
| 477 | } else { |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame^] | 478 | void *p; |
| 479 | |
| 480 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &p) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 481 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame^] | 482 | else |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 483 | tprintf("{%p}", p); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 484 | } |
| 485 | return 0; |
| 486 | } |
| 487 | |
| 488 | int |
| 489 | sys_timer_settime(tcp) |
| 490 | struct tcb *tcp; |
| 491 | { |
| 492 | if (entering(tcp)) { |
| 493 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 494 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 495 | tprintf(", "); |
| 496 | printitv(tcp, tcp->u_arg[2]); |
| 497 | tprintf(", "); |
| 498 | } else { |
| 499 | if (syserror(tcp)) |
| 500 | tprintf("%#lx", tcp->u_arg[3]); |
| 501 | else |
| 502 | printitv(tcp, tcp->u_arg[3]); |
| 503 | } |
| 504 | return 0; |
| 505 | } |
| 506 | |
| 507 | int |
| 508 | sys_timer_gettime(tcp) |
| 509 | struct tcb *tcp; |
| 510 | { |
| 511 | if (entering(tcp)) { |
| 512 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 513 | } else { |
| 514 | if (syserror(tcp)) |
| 515 | tprintf("%#lx", tcp->u_arg[1]); |
| 516 | else |
| 517 | printitv(tcp, tcp->u_arg[1]); |
| 518 | } |
| 519 | return 0; |
| 520 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 521 | |
| 522 | static void |
| 523 | print_rtc(tcp, rt) |
| 524 | struct tcb *tcp; |
| 525 | const struct rtc_time *rt; |
| 526 | { |
| 527 | tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " |
| 528 | "tm_mday=%d, tm_mon=%d, tm_year=%d, ", |
| 529 | rt->tm_sec, rt->tm_min, rt->tm_hour, |
| 530 | rt->tm_mday, rt->tm_mon, rt->tm_year); |
| 531 | if (!abbrev(tcp)) |
| 532 | tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", |
| 533 | rt->tm_wday, rt->tm_yday, rt->tm_isdst); |
| 534 | else |
| 535 | tprintf("...}"); |
| 536 | } |
| 537 | |
| 538 | int |
| 539 | rtc_ioctl(tcp, code, arg) |
| 540 | struct tcb *tcp; |
| 541 | long code; |
| 542 | long arg; |
| 543 | { |
| 544 | switch (code) { |
| 545 | case RTC_ALM_SET: |
| 546 | case RTC_SET_TIME: |
| 547 | if (entering(tcp)) { |
| 548 | struct rtc_time rt; |
| 549 | if (umove(tcp, arg, &rt) < 0) |
| 550 | tprintf(", %#lx", arg); |
| 551 | else { |
| 552 | tprintf(", "); |
| 553 | print_rtc(tcp, &rt); |
| 554 | } |
| 555 | } |
| 556 | break; |
| 557 | case RTC_ALM_READ: |
| 558 | case RTC_RD_TIME: |
| 559 | if (exiting(tcp)) { |
| 560 | struct rtc_time rt; |
| 561 | if (syserror(tcp) || umove(tcp, arg, &rt) < 0) |
| 562 | tprintf(", %#lx", arg); |
| 563 | else { |
| 564 | tprintf(", "); |
| 565 | print_rtc(tcp, &rt); |
| 566 | } |
| 567 | } |
| 568 | break; |
| 569 | case RTC_IRQP_SET: |
| 570 | case RTC_EPOCH_SET: |
| 571 | if (entering(tcp)) |
| 572 | tprintf(", %lu", arg); |
| 573 | break; |
| 574 | case RTC_IRQP_READ: |
| 575 | case RTC_EPOCH_READ: |
| 576 | if (exiting(tcp)) |
| 577 | tprintf(", %lu", arg); |
| 578 | break; |
| 579 | case RTC_WKALM_SET: |
| 580 | if (entering(tcp)) { |
| 581 | struct rtc_wkalrm wk; |
| 582 | if (umove(tcp, arg, &wk) < 0) |
| 583 | tprintf(", %#lx", arg); |
| 584 | else { |
| 585 | tprintf(", {enabled=%d, pending=%d, ", |
| 586 | wk.enabled, wk.pending); |
| 587 | print_rtc(tcp, &wk.time); |
| 588 | tprintf("}"); |
| 589 | } |
| 590 | } |
| 591 | break; |
| 592 | case RTC_WKALM_RD: |
| 593 | if (exiting(tcp)) { |
| 594 | struct rtc_wkalrm wk; |
| 595 | if (syserror(tcp) || umove(tcp, arg, &wk) < 0) |
| 596 | tprintf(", %#lx", arg); |
| 597 | else { |
| 598 | tprintf(", {enabled=%d, pending=%d, ", |
| 599 | wk.enabled, wk.pending); |
| 600 | print_rtc(tcp, &wk.time); |
| 601 | tprintf("}"); |
| 602 | } |
| 603 | } |
| 604 | break; |
| 605 | default: |
| 606 | if (entering(tcp)) |
| 607 | tprintf(", %#lx", arg); |
| 608 | break; |
| 609 | } |
| 610 | return 1; |
| 611 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 612 | #endif /* LINUX */ |