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> |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 39 | |
| 40 | #ifndef UTIME_NOW |
| 41 | #define UTIME_NOW ((1l << 30) - 1l) |
| 42 | #endif |
| 43 | #ifndef UTIME_OMIT |
| 44 | #define UTIME_OMIT ((1l << 30) - 2l) |
| 45 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 46 | #endif /* LINUX */ |
| 47 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 48 | struct timeval32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 50 | u_int32_t tv_sec, tv_usec; |
| 51 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 53 | static void |
| 54 | tprint_timeval32(struct tcb *tcp, const struct timeval32 *tv) |
| 55 | { |
| 56 | tprintf("{%u, %u}", tv->tv_sec, tv->tv_usec); |
| 57 | } |
| 58 | |
| 59 | static void |
| 60 | tprint_timeval(struct tcb *tcp, const struct timeval *tv) |
| 61 | { |
| 62 | tprintf("{%lu, %lu}", |
| 63 | (unsigned long) tv->tv_sec, (unsigned long) tv->tv_usec); |
| 64 | } |
| 65 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 66 | void |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 67 | printtv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness, int special) |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 68 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 69 | if (addr == 0) |
| 70 | tprintf("NULL"); |
| 71 | else if (!verbose(tcp)) |
| 72 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 73 | else { |
| 74 | int rc; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 75 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 76 | if (bitness == BITNESS_32 |
| 77 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 78 | || personality_wordsize[current_personality] == 4 |
| 79 | #endif |
| 80 | ) |
| 81 | { |
| 82 | struct timeval32 tv; |
| 83 | |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 84 | if ((rc = umove(tcp, addr, &tv)) >= 0) { |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 85 | if (special && tv.tv_sec == 0 && |
| 86 | tv.tv_usec == UTIME_NOW) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 87 | tprintf("UTIME_NOW"); |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 88 | else if (special && tv.tv_sec == 0 && |
| 89 | tv.tv_usec == UTIME_OMIT) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 90 | tprintf("UTIME_OMIT"); |
| 91 | else |
| 92 | tprint_timeval32(tcp, &tv); |
| 93 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 94 | } else { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 95 | struct timeval tv; |
| 96 | |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 97 | if ((rc = umove(tcp, addr, &tv)) >= 0) { |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 98 | if (special && tv.tv_sec == 0 && |
| 99 | tv.tv_usec == UTIME_NOW) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 100 | tprintf("UTIME_NOW"); |
Roland McGrath | 4138339 | 2007-07-24 01:58:52 +0000 | [diff] [blame] | 101 | else if (special && tv.tv_sec == 0 && |
| 102 | tv.tv_usec == UTIME_OMIT) |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 103 | tprintf("UTIME_OMIT"); |
| 104 | else |
| 105 | tprint_timeval(tcp, &tv); |
| 106 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 107 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 108 | if (rc < 0) |
| 109 | tprintf("{...}"); |
| 110 | } |
| 111 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 112 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 113 | void |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 114 | sprinttv(struct tcb *tcp, long addr, enum bitness_t bitness, char *buf) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 115 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 116 | if (addr == 0) |
| 117 | strcpy(buf, "NULL"); |
| 118 | else if (!verbose(tcp)) |
| 119 | sprintf(buf, "%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 120 | else { |
| 121 | int rc; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 122 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 123 | if (bitness == BITNESS_32 |
| 124 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 125 | || personality_wordsize[current_personality] == 4 |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 126 | #endif |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 127 | ) |
| 128 | { |
| 129 | struct timeval32 tv; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 130 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 131 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 132 | sprintf(buf, "{%u, %u}", |
| 133 | tv.tv_sec, tv.tv_usec); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 134 | } else { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 135 | struct timeval tv; |
| 136 | |
| 137 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 138 | sprintf(buf, "{%lu, %lu}", |
| 139 | (unsigned long) tv.tv_sec, |
| 140 | (unsigned long) tv.tv_usec); |
| 141 | } |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 142 | if (rc < 0) |
| 143 | strcpy(buf, "{...}"); |
| 144 | } |
| 145 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 146 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 147 | void print_timespec(struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 148 | { |
| 149 | if (addr == 0) |
| 150 | tprintf("NULL"); |
| 151 | else if (!verbose(tcp)) |
| 152 | tprintf("%#lx", addr); |
| 153 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 154 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 155 | |
| 156 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 157 | if (personality_wordsize[current_personality] == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 158 | struct timeval32 tv; |
| 159 | |
| 160 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 161 | tprintf("{%u, %u}", |
| 162 | tv.tv_sec, tv.tv_usec); |
| 163 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 164 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 165 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 166 | struct timespec ts; |
| 167 | |
| 168 | if ((rc = umove(tcp, addr, &ts)) >= 0) |
| 169 | tprintf("{%lu, %lu}", |
| 170 | (unsigned long) ts.tv_sec, |
| 171 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 172 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 173 | if (rc < 0) |
| 174 | tprintf("{...}"); |
| 175 | } |
| 176 | } |
| 177 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 178 | void sprint_timespec(char *buf, struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 179 | { |
| 180 | if (addr == 0) |
| 181 | strcpy(buf, "NULL"); |
| 182 | else if (!verbose(tcp)) |
| 183 | sprintf(buf, "%#lx", addr); |
| 184 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 185 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 186 | |
| 187 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 188 | if (personality_wordsize[current_personality] == 4) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 189 | struct timeval32 tv; |
| 190 | |
| 191 | if ((rc = umove(tcp, addr, &tv)) >= 0) |
| 192 | sprintf(buf, "{%u, %u}", |
| 193 | tv.tv_sec, tv.tv_usec); |
| 194 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 195 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 196 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 197 | struct timespec ts; |
| 198 | |
| 199 | if ((rc = umove(tcp, addr, &ts)) >= 0) |
| 200 | sprintf(buf, "{%lu, %lu}", |
| 201 | (unsigned long) ts.tv_sec, |
| 202 | (unsigned long) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 203 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 204 | if (rc < 0) |
| 205 | strcpy(buf, "{...}"); |
| 206 | } |
| 207 | } |
| 208 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 209 | int |
| 210 | sys_time(tcp) |
| 211 | struct tcb *tcp; |
| 212 | { |
| 213 | if (exiting(tcp)) { |
| 214 | #ifndef SVR4 |
| 215 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 216 | #endif /* SVR4 */ |
| 217 | } |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | int |
| 222 | sys_stime(tcp) |
| 223 | struct tcb *tcp; |
| 224 | { |
| 225 | if (exiting(tcp)) { |
| 226 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 227 | } |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | int |
| 232 | sys_gettimeofday(tcp) |
| 233 | struct tcb *tcp; |
| 234 | { |
| 235 | if (exiting(tcp)) { |
| 236 | if (syserror(tcp)) { |
| 237 | tprintf("%#lx, %#lx", |
| 238 | tcp->u_arg[0], tcp->u_arg[1]); |
| 239 | return 0; |
| 240 | } |
| 241 | printtv(tcp, tcp->u_arg[0]); |
| 242 | #ifndef SVR4 |
| 243 | tprintf(", "); |
| 244 | printtv(tcp, tcp->u_arg[1]); |
| 245 | #endif /* !SVR4 */ |
| 246 | } |
| 247 | return 0; |
| 248 | } |
| 249 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 250 | |
| 251 | #ifdef ALPHA |
| 252 | int |
| 253 | sys_osf_gettimeofday(tcp) |
| 254 | struct tcb *tcp; |
| 255 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 256 | if (exiting(tcp)) { |
| 257 | if (syserror(tcp)) { |
| 258 | tprintf("%#lx, %#lx", tcp->u_arg[0], tcp->u_arg[1]); |
| 259 | return 0; |
| 260 | } |
| 261 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 262 | #ifndef SVR4 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 263 | tprintf(", "); |
| 264 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 265 | #endif /* !SVR4 */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 266 | } |
| 267 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 268 | } |
| 269 | #endif |
| 270 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 271 | int |
| 272 | sys_settimeofday(tcp) |
| 273 | struct tcb *tcp; |
| 274 | { |
| 275 | if (entering(tcp)) { |
| 276 | printtv(tcp, tcp->u_arg[0]); |
| 277 | #ifndef SVR4 |
| 278 | tprintf(", "); |
| 279 | printtv(tcp, tcp->u_arg[1]); |
| 280 | #endif /* !SVR4 */ |
| 281 | } |
| 282 | return 0; |
| 283 | } |
| 284 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 285 | #ifdef ALPHA |
| 286 | int |
| 287 | sys_osf_settimeofday(tcp) |
| 288 | struct tcb *tcp; |
| 289 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 290 | if (entering(tcp)) { |
| 291 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 292 | #ifndef SVR4 |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 293 | tprintf(", "); |
| 294 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 295 | #endif /* !SVR4 */ |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 296 | } |
| 297 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 298 | } |
| 299 | #endif |
| 300 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 301 | int |
| 302 | sys_adjtime(tcp) |
| 303 | struct tcb *tcp; |
| 304 | { |
| 305 | if (entering(tcp)) { |
| 306 | printtv(tcp, tcp->u_arg[0]); |
| 307 | tprintf(", "); |
| 308 | } else { |
| 309 | if (syserror(tcp)) |
| 310 | tprintf("%#lx", tcp->u_arg[1]); |
| 311 | else |
| 312 | printtv(tcp, tcp->u_arg[1]); |
| 313 | } |
| 314 | return 0; |
| 315 | } |
| 316 | |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 317 | int |
| 318 | sys_nanosleep(struct tcb *tcp) |
| 319 | { |
| 320 | if (entering(tcp)) { |
| 321 | print_timespec(tcp, tcp->u_arg[0]); |
| 322 | tprintf(", "); |
| 323 | } else { |
| 324 | if (!tcp->u_arg[1] || is_restart_error(tcp)) |
| 325 | print_timespec(tcp, tcp->u_arg[1]); |
| 326 | else |
| 327 | tprintf("%#lx", tcp->u_arg[1]); |
| 328 | } |
| 329 | return 0; |
| 330 | } |
| 331 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 332 | static const struct xlat which[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 333 | { ITIMER_REAL, "ITIMER_REAL" }, |
| 334 | { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"}, |
| 335 | { ITIMER_PROF, "ITIMER_PROF" }, |
| 336 | { 0, NULL }, |
| 337 | }; |
| 338 | |
| 339 | static void |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 340 | printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 341 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 342 | if (addr == 0) |
| 343 | tprintf("NULL"); |
| 344 | else if (!verbose(tcp)) |
| 345 | tprintf("%#lx", addr); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 346 | else { |
| 347 | int rc; |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 348 | |
| 349 | if (bitness == BITNESS_32 |
| 350 | #if defined(LINUX) && SUPPORTED_PERSONALITIES > 1 |
| 351 | || personality_wordsize[current_personality] == 4 |
| 352 | #endif |
| 353 | ) |
| 354 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 355 | struct { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 356 | struct timeval32 it_interval, it_value; |
| 357 | } itv; |
| 358 | |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 359 | if ((rc = umove(tcp, addr, &itv)) >= 0) { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 360 | tprintf("{it_interval="); |
| 361 | tprint_timeval32(tcp, &itv.it_interval); |
| 362 | tprintf(", it_value="); |
| 363 | tprint_timeval32(tcp, &itv.it_value); |
| 364 | tprintf("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 365 | } |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 366 | } else { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 367 | struct itimerval itv; |
| 368 | |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 369 | if ((rc = umove(tcp, addr, &itv)) >= 0) { |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 370 | tprintf("{it_interval="); |
| 371 | tprint_timeval(tcp, &itv.it_interval); |
| 372 | tprintf(", it_value="); |
| 373 | tprint_timeval(tcp, &itv.it_value); |
| 374 | tprintf("}"); |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 375 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 376 | } |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 377 | if (rc < 0) |
| 378 | tprintf("{...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 379 | } |
| 380 | } |
| 381 | |
Dmitry V. Levin | 1cad25d | 2006-12-13 17:14:36 +0000 | [diff] [blame] | 382 | #define printitv(tcp, addr) \ |
| 383 | printitv_bitness((tcp), (addr), BITNESS_CURRENT) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 384 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 385 | int |
| 386 | sys_getitimer(tcp) |
| 387 | struct tcb *tcp; |
| 388 | { |
| 389 | if (entering(tcp)) { |
| 390 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 391 | tprintf(", "); |
| 392 | } else { |
| 393 | if (syserror(tcp)) |
| 394 | tprintf("%#lx", tcp->u_arg[1]); |
| 395 | else |
| 396 | printitv(tcp, tcp->u_arg[1]); |
| 397 | } |
| 398 | return 0; |
| 399 | } |
| 400 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 401 | |
| 402 | #ifdef ALPHA |
| 403 | int |
| 404 | sys_osf_getitimer(tcp) |
| 405 | struct tcb *tcp; |
| 406 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 407 | if (entering(tcp)) { |
| 408 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 409 | tprintf(", "); |
| 410 | } else { |
| 411 | if (syserror(tcp)) |
| 412 | tprintf("%#lx", tcp->u_arg[1]); |
| 413 | else |
| 414 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
| 415 | } |
| 416 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 417 | } |
| 418 | #endif |
| 419 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 420 | int |
| 421 | sys_setitimer(tcp) |
| 422 | struct tcb *tcp; |
| 423 | { |
| 424 | if (entering(tcp)) { |
| 425 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 426 | tprintf(", "); |
| 427 | printitv(tcp, tcp->u_arg[1]); |
| 428 | tprintf(", "); |
| 429 | } else { |
| 430 | if (syserror(tcp)) |
| 431 | tprintf("%#lx", tcp->u_arg[2]); |
| 432 | else |
| 433 | printitv(tcp, tcp->u_arg[2]); |
| 434 | } |
| 435 | return 0; |
| 436 | } |
| 437 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 438 | #ifdef ALPHA |
| 439 | int |
| 440 | sys_osf_setitimer(tcp) |
| 441 | struct tcb *tcp; |
| 442 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 443 | if (entering(tcp)) { |
| 444 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 445 | tprintf(", "); |
| 446 | printitv_bitness(tcp, tcp->u_arg[1], BITNESS_32); |
| 447 | tprintf(", "); |
| 448 | } else { |
| 449 | if (syserror(tcp)) |
| 450 | tprintf("%#lx", tcp->u_arg[2]); |
| 451 | else |
| 452 | printitv_bitness(tcp, tcp->u_arg[2], BITNESS_32); |
| 453 | } |
| 454 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 455 | } |
| 456 | #endif |
| 457 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 458 | #ifdef LINUX |
| 459 | |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 460 | static const struct xlat adjtimex_modes[] = { |
| 461 | { 0, "0" }, |
| 462 | #ifdef ADJ_OFFSET |
| 463 | { ADJ_OFFSET, "ADJ_OFFSET" }, |
| 464 | #endif |
| 465 | #ifdef ADJ_FREQUENCY |
| 466 | { ADJ_FREQUENCY, "ADJ_FREQUENCY" }, |
| 467 | #endif |
| 468 | #ifdef ADJ_MAXERROR |
| 469 | { ADJ_MAXERROR, "ADJ_MAXERROR" }, |
| 470 | #endif |
| 471 | #ifdef ADJ_ESTERROR |
| 472 | { ADJ_ESTERROR, "ADJ_ESTERROR" }, |
| 473 | #endif |
| 474 | #ifdef ADJ_STATUS |
| 475 | { ADJ_STATUS, "ADJ_STATUS" }, |
| 476 | #endif |
| 477 | #ifdef ADJ_TIMECONST |
| 478 | { ADJ_TIMECONST, "ADJ_TIMECONST" }, |
| 479 | #endif |
| 480 | #ifdef ADJ_TICK |
| 481 | { ADJ_TICK, "ADJ_TICK" }, |
| 482 | #endif |
| 483 | #ifdef ADJ_OFFSET_SINGLESHOT |
| 484 | { ADJ_OFFSET_SINGLESHOT, "ADJ_OFFSET_SINGLESHOT" }, |
| 485 | #endif |
| 486 | { 0, NULL } |
| 487 | }; |
| 488 | |
| 489 | static const struct xlat adjtimex_status[] = { |
| 490 | #ifdef STA_PLL |
| 491 | { STA_PLL, "STA_PLL" }, |
| 492 | #endif |
| 493 | #ifdef STA_PPSFREQ |
| 494 | { STA_PPSFREQ, "STA_PPSFREQ" }, |
| 495 | #endif |
| 496 | #ifdef STA_PPSTIME |
| 497 | { STA_PPSTIME, "STA_PPSTIME" }, |
| 498 | #endif |
| 499 | #ifdef STA_FLL |
| 500 | { STA_FLL, "STA_FLL" }, |
| 501 | #endif |
| 502 | #ifdef STA_INS |
| 503 | { STA_INS, "STA_INS" }, |
| 504 | #endif |
| 505 | #ifdef STA_DEL |
| 506 | { STA_DEL, "STA_DEL" }, |
| 507 | #endif |
| 508 | #ifdef STA_UNSYNC |
| 509 | { STA_UNSYNC, "STA_UNSYNC" }, |
| 510 | #endif |
| 511 | #ifdef STA_FREQHOLD |
| 512 | { STA_FREQHOLD, "STA_FREQHOLD" }, |
| 513 | #endif |
| 514 | #ifdef STA_PPSSIGNAL |
| 515 | { STA_PPSSIGNAL, "STA_PPSSIGNAL" }, |
| 516 | #endif |
| 517 | #ifdef STA_PPSJITTER |
| 518 | { STA_PPSJITTER, "STA_PPSJITTER" }, |
| 519 | #endif |
| 520 | #ifdef STA_PPSWANDER |
| 521 | { STA_PPSWANDER, "STA_PPSWANDER" }, |
| 522 | #endif |
| 523 | #ifdef STA_PPSERROR |
| 524 | { STA_PPSERROR, "STA_PPSERROR" }, |
| 525 | #endif |
| 526 | #ifdef STA_CLOCKERR |
| 527 | { STA_CLOCKERR, "STA_CLOCKERR" }, |
| 528 | #endif |
| 529 | { 0, NULL } |
| 530 | }; |
| 531 | |
| 532 | static const struct xlat adjtimex_state[] = { |
| 533 | #ifdef TIME_OK |
| 534 | { TIME_OK, "TIME_OK" }, |
| 535 | #endif |
| 536 | #ifdef TIME_INS |
| 537 | { TIME_INS, "TIME_INS" }, |
| 538 | #endif |
| 539 | #ifdef TIME_DEL |
| 540 | { TIME_DEL, "TIME_DEL" }, |
| 541 | #endif |
| 542 | #ifdef TIME_OOP |
| 543 | { TIME_OOP, "TIME_OOP" }, |
| 544 | #endif |
| 545 | #ifdef TIME_WAIT |
| 546 | { TIME_WAIT, "TIME_WAIT" }, |
| 547 | #endif |
| 548 | #ifdef TIME_ERROR |
| 549 | { TIME_ERROR, "TIME_ERROR" }, |
| 550 | #endif |
| 551 | { 0, NULL } |
| 552 | }; |
| 553 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 554 | #if SUPPORTED_PERSONALITIES > 1 |
| 555 | static int |
| 556 | tprint_timex32(struct tcb *tcp, long addr) |
| 557 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 558 | struct { |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 559 | unsigned int modes; |
| 560 | int offset; |
| 561 | int freq; |
| 562 | int maxerror; |
| 563 | int esterror; |
| 564 | int status; |
| 565 | int constant; |
| 566 | int precision; |
| 567 | int tolerance; |
| 568 | struct timeval32 time; |
| 569 | int tick; |
| 570 | int ppsfreq; |
| 571 | int jitter; |
| 572 | int shift; |
| 573 | int stabil; |
| 574 | int jitcnt; |
| 575 | int calcnt; |
| 576 | int errcnt; |
| 577 | int stbcnt; |
| 578 | } tx; |
| 579 | |
| 580 | if (umove(tcp, addr, &tx) < 0) |
| 581 | return -1; |
| 582 | |
| 583 | tprintf("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 584 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 585 | tprintf(", offset=%d, freq=%d, maxerror=%d, ", |
| 586 | tx.offset, tx.freq, tx.maxerror); |
| 587 | tprintf("esterror=%u, status=", tx.esterror); |
| 588 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 589 | tprintf(", constant=%d, precision=%u, ", |
| 590 | tx.constant, tx.precision); |
| 591 | tprintf("tolerance=%d, time=", tx.tolerance); |
| 592 | tprint_timeval32(tcp, &tx.time); |
| 593 | tprintf(", tick=%d, ppsfreq=%d, jitter=%d", |
| 594 | tx.tick, tx.ppsfreq, tx.jitter); |
| 595 | tprintf(", shift=%d, stabil=%d, jitcnt=%d", |
| 596 | tx.shift, tx.stabil, tx.jitcnt); |
| 597 | tprintf(", calcnt=%d, errcnt=%d, stbcnt=%d", |
| 598 | tx.calcnt, tx.errcnt, tx.stbcnt); |
| 599 | tprintf("}"); |
| 600 | return 0; |
| 601 | } |
| 602 | #endif /* SUPPORTED_PERSONALITIES > 1 */ |
| 603 | |
| 604 | static int |
| 605 | tprint_timex(struct tcb *tcp, long addr) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 606 | { |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 607 | struct timex tx; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 608 | |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 609 | #if SUPPORTED_PERSONALITIES > 1 |
| 610 | if (personality_wordsize[current_personality] == 4) |
| 611 | return tprint_timex32(tcp, addr); |
| 612 | #endif |
| 613 | if (umove(tcp, addr, &tx) < 0) |
| 614 | return -1; |
| 615 | |
| 616 | #if LINUX_VERSION_CODE < 66332 |
| 617 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 618 | tx.mode, tx.offset, tx.frequency); |
| 619 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 620 | tx.maxerror, tx.esterror, tx.status); |
| 621 | tprintf("time_constant=%ld, precision=%lu, ", |
| 622 | tx.time_constant, tx.precision); |
| 623 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 624 | tprint_timeval(tcp, &tx.time); |
| 625 | #else |
| 626 | tprintf("{modes="); |
Dmitry V. Levin | 71d7089 | 2007-01-13 11:17:38 +0000 | [diff] [blame] | 627 | printflags(adjtimex_modes, tx.modes, "ADJ_???"); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 628 | tprintf(", offset=%ld, freq=%ld, maxerror=%ld, ", |
| 629 | tx.offset, tx.freq, tx.maxerror); |
| 630 | tprintf("esterror=%lu, status=", tx.esterror); |
| 631 | printflags(adjtimex_status, tx.status, "STA_???"); |
| 632 | tprintf(", constant=%ld, precision=%lu, ", |
| 633 | tx.constant, tx.precision); |
| 634 | tprintf("tolerance=%ld, time=", tx.tolerance); |
| 635 | tprint_timeval(tcp, &tx.time); |
| 636 | tprintf(", tick=%ld, ppsfreq=%ld, jitter=%ld", |
| 637 | tx.tick, tx.ppsfreq, tx.jitter); |
| 638 | tprintf(", shift=%d, stabil=%ld, jitcnt=%ld", |
| 639 | tx.shift, tx.stabil, tx.jitcnt); |
| 640 | tprintf(", calcnt=%ld, errcnt=%ld, stbcnt=%ld", |
| 641 | tx.calcnt, tx.errcnt, tx.stbcnt); |
| 642 | #endif |
| 643 | tprintf("}"); |
| 644 | return 0; |
| 645 | } |
| 646 | |
| 647 | int |
| 648 | sys_adjtimex(struct tcb *tcp) |
| 649 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 650 | if (exiting(tcp)) { |
| 651 | if (tcp->u_arg[0] == 0) |
| 652 | tprintf("NULL"); |
| 653 | else if (syserror(tcp) || !verbose(tcp)) |
| 654 | tprintf("%#lx", tcp->u_arg[0]); |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 655 | else if (tprint_timex(tcp, tcp->u_arg[0]) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 656 | tprintf("{...}"); |
Dmitry V. Levin | 21a7534 | 2008-09-03 01:22:18 +0000 | [diff] [blame] | 657 | if (syserror(tcp)) |
| 658 | return 0; |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 659 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 660 | if (tcp->auxstr) |
| 661 | return RVAL_STR; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 662 | } |
| 663 | return 0; |
| 664 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 665 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 666 | static const struct xlat clockflags[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 667 | { TIMER_ABSTIME, "TIMER_ABSTIME" }, |
| 668 | { 0, NULL } |
| 669 | }; |
| 670 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 671 | static const struct xlat clocknames[] = { |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 672 | #ifdef CLOCK_REALTIME |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 673 | { CLOCK_REALTIME, "CLOCK_REALTIME" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 674 | #endif |
| 675 | #ifdef CLOCK_MONOTONIC |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 676 | { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, |
Roland McGrath | 55a00f8 | 2004-08-31 08:26:39 +0000 | [diff] [blame] | 677 | #endif |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 678 | { 0, NULL } |
| 679 | }; |
| 680 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 681 | int |
| 682 | sys_clock_settime(tcp) |
| 683 | struct tcb *tcp; |
| 684 | { |
| 685 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 686 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 687 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 688 | printtv(tcp, tcp->u_arg[1]); |
| 689 | } |
| 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | int |
| 694 | sys_clock_gettime(tcp) |
| 695 | struct tcb *tcp; |
| 696 | { |
| 697 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 698 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 699 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 700 | } else { |
| 701 | if (syserror(tcp)) |
| 702 | tprintf("%#lx", tcp->u_arg[1]); |
| 703 | else |
| 704 | printtv(tcp, tcp->u_arg[1]); |
| 705 | } |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | int |
| 710 | sys_clock_nanosleep(tcp) |
| 711 | struct tcb *tcp; |
| 712 | { |
| 713 | if (entering(tcp)) { |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 714 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 715 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 716 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 717 | tprintf(", "); |
| 718 | printtv(tcp, tcp->u_arg[2]); |
| 719 | tprintf(", "); |
| 720 | } else { |
| 721 | if (syserror(tcp)) |
| 722 | tprintf("%#lx", tcp->u_arg[3]); |
| 723 | else |
| 724 | printtv(tcp, tcp->u_arg[3]); |
| 725 | } |
| 726 | return 0; |
| 727 | } |
| 728 | |
| 729 | #ifndef SIGEV_THREAD_ID |
| 730 | # define SIGEV_THREAD_ID 4 |
| 731 | #endif |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 732 | static const struct xlat sigev_value[] = { |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 733 | { SIGEV_SIGNAL+1, "SIGEV_SIGNAL" }, |
| 734 | { SIGEV_NONE+1, "SIGEV_NONE" }, |
| 735 | { SIGEV_THREAD+1, "SIGEV_THREAD" }, |
| 736 | { SIGEV_THREAD_ID+1, "SIGEV_THREAD_ID" }, |
| 737 | { 0, NULL } |
| 738 | }; |
| 739 | |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 740 | #if SUPPORTED_PERSONALITIES > 1 |
| 741 | static void |
| 742 | printsigevent32(struct tcb *tcp, long arg) |
| 743 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 744 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 745 | int sigev_value; |
| 746 | int sigev_signo; |
| 747 | int sigev_notify; |
| 748 | |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 749 | union { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 750 | int tid; |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 751 | struct { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 752 | int function, attribute; |
| 753 | } thread; |
| 754 | } un; |
| 755 | } sev; |
| 756 | |
| 757 | if (umove(tcp, arg, &sev) < 0) |
| 758 | tprintf("{...}"); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 759 | else { |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 760 | tprintf("{%#x, ", sev.sigev_value); |
| 761 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 762 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 763 | else |
| 764 | tprintf("%u, ", sev.sigev_signo); |
| 765 | printxval(sigev_value, sev.sigev_notify + 1, "SIGEV_???"); |
| 766 | tprintf(", "); |
| 767 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 768 | tprintf("{%d}", sev.un.tid); |
| 769 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 770 | tprintf("{%#x, %#x}", |
| 771 | sev.un.thread.function, |
| 772 | sev.un.thread.attribute); |
| 773 | else |
| 774 | tprintf("{...}"); |
| 775 | tprintf("}"); |
| 776 | } |
| 777 | } |
| 778 | #endif |
| 779 | |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 780 | void |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 781 | printsigevent(struct tcb *tcp, long arg) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 782 | { |
| 783 | struct sigevent sev; |
Dmitry V. Levin | d3cb392 | 2006-12-13 17:45:02 +0000 | [diff] [blame] | 784 | |
| 785 | #if SUPPORTED_PERSONALITIES > 1 |
| 786 | if (personality_wordsize[current_personality] == 4) |
| 787 | { |
| 788 | printsigevent32(tcp, arg); |
| 789 | return; |
| 790 | } |
| 791 | #endif |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 792 | if (umove (tcp, arg, &sev) < 0) |
| 793 | tprintf("{...}"); |
| 794 | else { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 795 | tprintf("{%p, ", sev.sigev_value.sival_ptr); |
| 796 | if (sev.sigev_notify == SIGEV_SIGNAL) |
| 797 | tprintf("%s, ", signame(sev.sigev_signo)); |
| 798 | else |
| 799 | tprintf("%u, ", sev.sigev_signo); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 800 | printxval(sigev_value, sev.sigev_notify+1, "SIGEV_???"); |
| 801 | tprintf(", "); |
| 802 | if (sev.sigev_notify == SIGEV_THREAD_ID) |
| 803 | /* _pad[0] is the _tid field which might not be |
| 804 | present in the userlevel definition of the |
| 805 | struct. */ |
| 806 | tprintf("{%d}", sev._sigev_un._pad[0]); |
Roland McGrath | d4c85eb | 2004-04-16 21:48:44 +0000 | [diff] [blame] | 807 | else if (sev.sigev_notify == SIGEV_THREAD) |
| 808 | tprintf("{%p, %p}", sev.sigev_notify_function, |
| 809 | sev.sigev_notify_attributes); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 810 | else |
| 811 | tprintf("{...}"); |
| 812 | tprintf("}"); |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | int |
| 817 | sys_timer_create(tcp) |
| 818 | struct tcb *tcp; |
| 819 | { |
| 820 | if (entering(tcp)) { |
Roland McGrath | 675d4a6 | 2004-09-11 08:12:45 +0000 | [diff] [blame] | 821 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 822 | tprintf(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 823 | printsigevent(tcp, tcp->u_arg[1]); |
| 824 | tprintf(", "); |
| 825 | } else { |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 826 | void *p; |
| 827 | |
| 828 | if (syserror(tcp) || umove(tcp, tcp->u_arg[2], &p) < 0) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 829 | tprintf("%#lx", tcp->u_arg[2]); |
Dmitry V. Levin | ac518d1 | 2006-12-13 17:03:02 +0000 | [diff] [blame] | 830 | else |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 831 | tprintf("{%p}", p); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 832 | } |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 836 | int |
| 837 | sys_timer_settime(tcp) |
| 838 | struct tcb *tcp; |
| 839 | { |
| 840 | if (entering(tcp)) { |
| 841 | tprintf("%#lx, ", tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 842 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 843 | tprintf(", "); |
| 844 | printitv(tcp, tcp->u_arg[2]); |
| 845 | tprintf(", "); |
| 846 | } else { |
| 847 | if (syserror(tcp)) |
| 848 | tprintf("%#lx", tcp->u_arg[3]); |
| 849 | else |
| 850 | printitv(tcp, tcp->u_arg[3]); |
| 851 | } |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | int |
| 856 | sys_timer_gettime(tcp) |
| 857 | struct tcb *tcp; |
| 858 | { |
| 859 | if (entering(tcp)) { |
| 860 | tprintf("%#lx, ", tcp->u_arg[0]); |
| 861 | } else { |
| 862 | if (syserror(tcp)) |
| 863 | tprintf("%#lx", tcp->u_arg[1]); |
| 864 | else |
| 865 | printitv(tcp, tcp->u_arg[1]); |
| 866 | } |
| 867 | return 0; |
| 868 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 869 | |
| 870 | static void |
| 871 | print_rtc(tcp, rt) |
| 872 | struct tcb *tcp; |
| 873 | const struct rtc_time *rt; |
| 874 | { |
| 875 | tprintf("{tm_sec=%d, tm_min=%d, tm_hour=%d, " |
| 876 | "tm_mday=%d, tm_mon=%d, tm_year=%d, ", |
| 877 | rt->tm_sec, rt->tm_min, rt->tm_hour, |
| 878 | rt->tm_mday, rt->tm_mon, rt->tm_year); |
| 879 | if (!abbrev(tcp)) |
| 880 | tprintf("tm_wday=%d, tm_yday=%d, tm_isdst=%d}", |
| 881 | rt->tm_wday, rt->tm_yday, rt->tm_isdst); |
| 882 | else |
| 883 | tprintf("...}"); |
| 884 | } |
| 885 | |
| 886 | int |
| 887 | rtc_ioctl(tcp, code, arg) |
| 888 | struct tcb *tcp; |
| 889 | long code; |
| 890 | long arg; |
| 891 | { |
| 892 | switch (code) { |
| 893 | case RTC_ALM_SET: |
| 894 | case RTC_SET_TIME: |
| 895 | if (entering(tcp)) { |
| 896 | struct rtc_time rt; |
| 897 | if (umove(tcp, arg, &rt) < 0) |
| 898 | tprintf(", %#lx", arg); |
| 899 | else { |
| 900 | tprintf(", "); |
| 901 | print_rtc(tcp, &rt); |
| 902 | } |
| 903 | } |
| 904 | break; |
| 905 | case RTC_ALM_READ: |
| 906 | case RTC_RD_TIME: |
| 907 | if (exiting(tcp)) { |
| 908 | struct rtc_time rt; |
| 909 | if (syserror(tcp) || umove(tcp, arg, &rt) < 0) |
| 910 | tprintf(", %#lx", arg); |
| 911 | else { |
| 912 | tprintf(", "); |
| 913 | print_rtc(tcp, &rt); |
| 914 | } |
| 915 | } |
| 916 | break; |
| 917 | case RTC_IRQP_SET: |
| 918 | case RTC_EPOCH_SET: |
| 919 | if (entering(tcp)) |
| 920 | tprintf(", %lu", arg); |
| 921 | break; |
| 922 | case RTC_IRQP_READ: |
| 923 | case RTC_EPOCH_READ: |
| 924 | if (exiting(tcp)) |
| 925 | tprintf(", %lu", arg); |
| 926 | break; |
| 927 | case RTC_WKALM_SET: |
| 928 | if (entering(tcp)) { |
| 929 | struct rtc_wkalrm wk; |
| 930 | if (umove(tcp, arg, &wk) < 0) |
| 931 | tprintf(", %#lx", arg); |
| 932 | else { |
| 933 | tprintf(", {enabled=%d, pending=%d, ", |
| 934 | wk.enabled, wk.pending); |
| 935 | print_rtc(tcp, &wk.time); |
| 936 | tprintf("}"); |
| 937 | } |
| 938 | } |
| 939 | break; |
| 940 | case RTC_WKALM_RD: |
| 941 | if (exiting(tcp)) { |
| 942 | struct rtc_wkalrm wk; |
| 943 | if (syserror(tcp) || umove(tcp, arg, &wk) < 0) |
| 944 | tprintf(", %#lx", arg); |
| 945 | else { |
| 946 | tprintf(", {enabled=%d, pending=%d, ", |
| 947 | wk.enabled, wk.pending); |
| 948 | print_rtc(tcp, &wk.time); |
| 949 | tprintf("}"); |
| 950 | } |
| 951 | } |
| 952 | break; |
| 953 | default: |
| 954 | if (entering(tcp)) |
| 955 | tprintf(", %#lx", arg); |
| 956 | break; |
| 957 | } |
| 958 | return 1; |
| 959 | } |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 960 | |
| 961 | #ifndef TFD_TIMER_ABSTIME |
| 962 | #define TFD_TIMER_ABSTIME (1 << 0) |
| 963 | #endif |
| 964 | |
| 965 | static const struct xlat timerfdflags[] = { |
| 966 | { TFD_TIMER_ABSTIME, "TFD_TIMER_ABSTIME" }, |
| 967 | { 0, NULL } |
| 968 | }; |
| 969 | |
| 970 | int |
| 971 | sys_timerfd(tcp) |
| 972 | struct tcb *tcp; |
| 973 | { |
| 974 | if (entering(tcp)) { |
| 975 | /* It does not matter that the kernel uses itimerspec. */ |
| 976 | tprintf("%ld, ", tcp->u_arg[0]); |
| 977 | printxval(clocknames, tcp->u_arg[1], "CLOCK_???"); |
| 978 | tprintf(", "); |
| 979 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
| 980 | tprintf(", "); |
| 981 | printitv(tcp, tcp->u_arg[3]); |
| 982 | } |
| 983 | return 0; |
| 984 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 985 | |
| 986 | int |
| 987 | sys_timerfd_create(struct tcb *tcp) |
| 988 | { |
| 989 | if (entering(tcp)) { |
| 990 | printxval(clocknames, tcp->u_arg[0], "CLOCK_???"); |
| 991 | tprintf(", "); |
| 992 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 993 | } |
| 994 | return 0; |
| 995 | } |
| 996 | |
| 997 | int |
| 998 | sys_timerfd_settime(struct tcb *tcp) |
| 999 | { |
| 1000 | if (entering(tcp)) { |
| 1001 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1002 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 1003 | tprintf(", "); |
| 1004 | printitv(tcp, tcp->u_arg[2]); |
| 1005 | tprintf(", "); |
| 1006 | printitv(tcp, tcp->u_arg[3]); |
| 1007 | } |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
| 1011 | int |
| 1012 | sys_timerfd_gettime(struct tcb *tcp) |
| 1013 | { |
| 1014 | if (entering(tcp)) { |
| 1015 | tprintf("%ld, ", tcp->u_arg[0]); |
| 1016 | tprintf(", "); |
| 1017 | printitv(tcp, tcp->u_arg[1]); |
| 1018 | } |
| 1019 | return 0; |
| 1020 | } |
| 1021 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1022 | #endif /* LINUX */ |