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