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. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 28 | */ |
| 29 | |
| 30 | #include "defs.h" |
Mike Frysinger | f1639d8 | 2014-12-30 19:08:50 -0500 | [diff] [blame] | 31 | #include <fcntl.h> |
Dmitry V. Levin | 0e946ab | 2015-07-17 23:56:54 +0000 | [diff] [blame] | 32 | #include <signal.h> |
Wichert Akkerman | d856b99 | 2000-10-13 12:47:12 +0000 | [diff] [blame] | 33 | #include <sys/timex.h> |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 34 | |
| 35 | #ifndef UTIME_NOW |
| 36 | #define UTIME_NOW ((1l << 30) - 1l) |
| 37 | #endif |
| 38 | #ifndef UTIME_OMIT |
| 39 | #define UTIME_OMIT ((1l << 30) - 2l) |
| 40 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 41 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 42 | #if SUPPORTED_PERSONALITIES > 1 |
| 43 | # if defined X86_64 || defined X32 |
| 44 | # define current_time_t_is_compat (current_personality == 1) |
| 45 | # else |
| 46 | # define current_time_t_is_compat (current_wordsize == 4) |
| 47 | # endif |
| 48 | #else |
| 49 | # define current_time_t_is_compat 0 |
| 50 | #endif |
| 51 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 52 | struct timeval32 |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 53 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 54 | u_int32_t tv_sec, tv_usec; |
| 55 | }; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 56 | |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 57 | void |
Roland McGrath | 6afc565 | 2007-07-24 01:57:11 +0000 | [diff] [blame] | 58 | 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] | 59 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 60 | char buf[TIMEVAL_TEXT_BUFSIZE]; |
| 61 | sprinttv(buf, tcp, addr, bitness, special); |
| 62 | tprints(buf); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 63 | } |
Wichert Akkerman | 221f54f | 1999-11-18 17:26:45 +0000 | [diff] [blame] | 64 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 65 | static char * |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 66 | do_sprinttv(char *buf, const uintmax_t sec, const uintmax_t usec, |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 67 | const int special) |
| 68 | { |
| 69 | if (special) { |
| 70 | switch (usec) { |
| 71 | case UTIME_NOW: |
| 72 | return stpcpy(buf, "UTIME_NOW"); |
| 73 | case UTIME_OMIT: |
| 74 | return stpcpy(buf, "UTIME_OMIT"); |
| 75 | } |
| 76 | } |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 77 | return buf + sprintf(buf, "{%ju, %ju}", sec, usec); |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 80 | char * |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 81 | sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int special) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 82 | { |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 83 | if (addr == 0) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 84 | return stpcpy(buf, "NULL"); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 85 | |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 86 | if (!verbose(tcp) || (exiting(tcp) && syserror(tcp))) |
Denys Vlasenko | b9c7ae6 | 2011-09-01 11:40:40 +0200 | [diff] [blame] | 87 | return buf + sprintf(buf, "%#lx", addr); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 88 | |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 89 | if (bitness == BITNESS_32 || current_time_t_is_compat) |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 90 | { |
| 91 | struct timeval32 tv; |
| 92 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 93 | if (umove(tcp, addr, &tv) >= 0) |
| 94 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 95 | } else { |
| 96 | struct timeval tv; |
| 97 | |
Dmitry V. Levin | ee21a5b | 2014-12-26 23:55:38 +0000 | [diff] [blame] | 98 | if (umove(tcp, addr, &tv) >= 0) |
| 99 | return do_sprinttv(buf, tv.tv_sec, tv.tv_usec, special); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 100 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 101 | |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 102 | return buf + sprintf(buf, "%#lx", addr); |
Dmitry V. Levin | a7945a3 | 2006-12-13 17:10:11 +0000 | [diff] [blame] | 103 | } |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 104 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 105 | void |
| 106 | print_timespec(struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 107 | { |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 108 | char buf[TIMESPEC_TEXT_BUFSIZE]; |
| 109 | sprint_timespec(buf, tcp, addr); |
| 110 | tprints(buf); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 111 | } |
| 112 | |
Denys Vlasenko | a1d541e | 2012-01-20 11:04:04 +0100 | [diff] [blame] | 113 | void |
| 114 | sprint_timespec(char *buf, struct tcb *tcp, long addr) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 115 | { |
| 116 | if (addr == 0) |
| 117 | strcpy(buf, "NULL"); |
| 118 | else if (!verbose(tcp)) |
| 119 | sprintf(buf, "%#lx", addr); |
| 120 | else { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 121 | int rc; |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 122 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 123 | #if SUPPORTED_PERSONALITIES > 1 |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 124 | if (current_time_t_is_compat) { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 125 | struct timeval32 tv; |
| 126 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 127 | rc = umove(tcp, addr, &tv); |
| 128 | if (rc >= 0) |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 129 | sprintf(buf, "{%u, %u}", |
| 130 | tv.tv_sec, tv.tv_usec); |
| 131 | } else |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 132 | #endif |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 133 | { |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 134 | struct timespec ts; |
| 135 | |
Denys Vlasenko | 5d64581 | 2011-08-20 12:48:18 +0200 | [diff] [blame] | 136 | rc = umove(tcp, addr, &ts); |
| 137 | if (rc >= 0) |
Dmitry V. Levin | e61086f | 2015-02-27 21:46:42 +0000 | [diff] [blame] | 138 | sprintf(buf, "{%ju, %ju}", |
| 139 | (uintmax_t) ts.tv_sec, |
| 140 | (uintmax_t) ts.tv_nsec); |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 141 | } |
Roland McGrath | 6bc09da | 2007-11-01 21:50:54 +0000 | [diff] [blame] | 142 | if (rc < 0) |
| 143 | strcpy(buf, "{...}"); |
| 144 | } |
| 145 | } |
| 146 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 147 | SYS_FUNC(gettimeofday) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 148 | { |
| 149 | if (exiting(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 151 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 152 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 153 | } |
| 154 | return 0; |
| 155 | } |
| 156 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 157 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 158 | SYS_FUNC(osf_gettimeofday) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 159 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 160 | if (exiting(tcp)) { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 161 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 162 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 163 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 164 | } |
| 165 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 166 | } |
| 167 | #endif |
| 168 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 169 | SYS_FUNC(settimeofday) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 170 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 171 | printtv(tcp, tcp->u_arg[0]); |
| 172 | tprints(", "); |
| 173 | printtv(tcp, tcp->u_arg[1]); |
| 174 | |
| 175 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 178 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 179 | SYS_FUNC(osf_settimeofday) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 180 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 181 | printtv_bitness(tcp, tcp->u_arg[0], BITNESS_32, 0); |
| 182 | tprints(", "); |
| 183 | printtv_bitness(tcp, tcp->u_arg[1], BITNESS_32, 0); |
| 184 | |
| 185 | return RVAL_DECODED; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 186 | } |
| 187 | #endif |
| 188 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 189 | SYS_FUNC(adjtime) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 190 | { |
| 191 | if (entering(tcp)) { |
| 192 | printtv(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 193 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | } else { |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 195 | printtv(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 196 | } |
| 197 | return 0; |
| 198 | } |
| 199 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 200 | SYS_FUNC(nanosleep) |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 201 | { |
| 202 | if (entering(tcp)) { |
| 203 | print_timespec(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 204 | tprints(", "); |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 205 | } else { |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 206 | /* Second (returned) timespec is only significant |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 207 | * if syscall was interrupted. On success, we print |
| 208 | * only its address, since kernel doesn't modify it, |
| 209 | * and printing the value may show uninitialized data. |
Denys Vlasenko | 64acaa1 | 2012-01-28 02:29:36 +0100 | [diff] [blame] | 210 | */ |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 211 | switch (tcp->u_error) { |
| 212 | default: |
| 213 | /* Not interrupted (slept entire interval) */ |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 214 | printaddr(tcp->u_arg[1]); |
| 215 | break; |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 216 | case ERESTARTSYS: |
| 217 | case ERESTARTNOINTR: |
| 218 | case ERESTARTNOHAND: |
| 219 | case ERESTART_RESTARTBLOCK: |
| 220 | /* Interrupted */ |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 221 | print_timespec(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 4793221 | 2013-06-30 23:53:49 +0200 | [diff] [blame] | 222 | } |
Dmitry V. Levin | 2e55ff4 | 2008-09-03 01:02:46 +0000 | [diff] [blame] | 223 | } |
| 224 | return 0; |
| 225 | } |
| 226 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 227 | #include "xlat/itimer_which.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 228 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 229 | SYS_FUNC(getitimer) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 230 | { |
| 231 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 232 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 233 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | } else { |
Dmitry V. Levin | 322be80 | 2015-09-17 20:23:31 +0000 | [diff] [blame^] | 235 | print_itimerval(tcp, tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 236 | } |
| 237 | return 0; |
| 238 | } |
| 239 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 240 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 241 | SYS_FUNC(osf_getitimer) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 242 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 243 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 244 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 245 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 246 | } else { |
Dmitry V. Levin | 322be80 | 2015-09-17 20:23:31 +0000 | [diff] [blame^] | 247 | print_itimerval32(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 248 | } |
| 249 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 250 | } |
| 251 | #endif |
| 252 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 253 | SYS_FUNC(setitimer) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 254 | { |
| 255 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 256 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 257 | tprints(", "); |
Dmitry V. Levin | 322be80 | 2015-09-17 20:23:31 +0000 | [diff] [blame^] | 258 | print_itimerval(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 259 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 260 | } else { |
Dmitry V. Levin | 322be80 | 2015-09-17 20:23:31 +0000 | [diff] [blame^] | 261 | print_itimerval(tcp, tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 262 | } |
| 263 | return 0; |
| 264 | } |
| 265 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 266 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 267 | SYS_FUNC(osf_setitimer) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 268 | { |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 269 | if (entering(tcp)) { |
Dmitry V. Levin | 297b594 | 2014-04-25 23:39:20 +0000 | [diff] [blame] | 270 | printxval(itimer_which, tcp->u_arg[0], "ITIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 271 | tprints(", "); |
Dmitry V. Levin | 322be80 | 2015-09-17 20:23:31 +0000 | [diff] [blame^] | 272 | print_itimerval32(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 273 | tprints(", "); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 274 | } else { |
Dmitry V. Levin | 322be80 | 2015-09-17 20:23:31 +0000 | [diff] [blame^] | 275 | print_itimerval32(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 1d63246 | 2009-04-14 12:51:00 +0000 | [diff] [blame] | 276 | } |
| 277 | return 0; |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 278 | } |
| 279 | #endif |
| 280 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 281 | #include "xlat/adjtimex_state.h" |
Dmitry V. Levin | 1a684d6 | 2006-12-13 17:42:32 +0000 | [diff] [blame] | 282 | |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 283 | static int |
| 284 | do_adjtimex(struct tcb *tcp, long addr) |
| 285 | { |
Dmitry V. Levin | dad1eef | 2015-09-16 21:58:36 +0000 | [diff] [blame] | 286 | if (print_timex(tcp, addr)) |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 287 | return 0; |
| 288 | tcp->auxstr = xlookup(adjtimex_state, tcp->u_rval); |
| 289 | if (tcp->auxstr) |
| 290 | return RVAL_STR; |
| 291 | return 0; |
| 292 | } |
| 293 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 294 | SYS_FUNC(adjtimex) |
Dmitry V. Levin | 165b15d | 2006-12-13 17:43:45 +0000 | [diff] [blame] | 295 | { |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 296 | if (exiting(tcp)) |
| 297 | return do_adjtimex(tcp, tcp->u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 298 | return 0; |
| 299 | } |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 300 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 301 | #include "xlat/clockflags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 302 | #include "xlat/clocknames.h" |
Roland McGrath | 54a4edd | 2004-08-31 06:52:45 +0000 | [diff] [blame] | 303 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 304 | static void |
| 305 | printclockname(int clockid) |
| 306 | { |
| 307 | #ifdef CLOCKID_TO_FD |
Dmitry V. Levin | d35bdca | 2014-04-26 18:10:19 +0000 | [diff] [blame] | 308 | # include "xlat/cpuclocknames.h" |
| 309 | |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 310 | if (clockid < 0) { |
| 311 | if ((clockid & CLOCKFD_MASK) == CLOCKFD) |
| 312 | tprintf("FD_TO_CLOCKID(%d)", CLOCKID_TO_FD(clockid)); |
| 313 | else { |
| 314 | if(CPUCLOCK_PERTHREAD(clockid)) |
| 315 | tprintf("MAKE_THREAD_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 316 | else |
| 317 | tprintf("MAKE_PROCESS_CPUCLOCK(%d,", CPUCLOCK_PID(clockid)); |
| 318 | printxval(cpuclocknames, clockid & CLOCKFD_MASK, "CPUCLOCK_???"); |
| 319 | tprints(")"); |
| 320 | } |
| 321 | } |
| 322 | else |
| 323 | #endif |
| 324 | printxval(clocknames, clockid, "CLOCK_???"); |
| 325 | } |
| 326 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 327 | SYS_FUNC(clock_settime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 328 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 329 | printclockname(tcp->u_arg[0]); |
| 330 | tprints(", "); |
| 331 | printtv(tcp, tcp->u_arg[1]); |
| 332 | |
| 333 | return RVAL_DECODED; |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 334 | } |
| 335 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 336 | SYS_FUNC(clock_gettime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 337 | { |
| 338 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 339 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 340 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 341 | } else { |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 342 | printtv(tcp, tcp->u_arg[1]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 343 | } |
| 344 | return 0; |
| 345 | } |
| 346 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 347 | SYS_FUNC(clock_nanosleep) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 348 | { |
| 349 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 350 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 351 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 352 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 353 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 354 | printtv(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 355 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 356 | } else { |
Dmitry V. Levin | 9f70273 | 2015-07-16 16:22:07 +0000 | [diff] [blame] | 357 | printtv(tcp, tcp->u_arg[3]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 358 | } |
| 359 | return 0; |
| 360 | } |
| 361 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 362 | SYS_FUNC(clock_adjtime) |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 363 | { |
| 364 | if (exiting(tcp)) |
| 365 | return do_adjtimex(tcp, tcp->u_arg[1]); |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 366 | printclockname(tcp->u_arg[0]); |
Dmitry V. Levin | 7321547 | 2012-03-11 21:25:51 +0000 | [diff] [blame] | 367 | tprints(", "); |
| 368 | return 0; |
| 369 | } |
| 370 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 371 | SYS_FUNC(timer_create) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 372 | { |
| 373 | if (entering(tcp)) { |
Stefan Sørensen | a5fea90 | 2014-02-03 10:01:27 +0100 | [diff] [blame] | 374 | printclockname(tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 375 | tprints(", "); |
Dmitry V. Levin | 6f950cc | 2015-09-16 16:31:43 +0000 | [diff] [blame] | 376 | print_sigevent(tcp, tcp->u_arg[1]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 377 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 378 | } else { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 379 | printnum_int(tcp, tcp->u_arg[2], "%d"); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 384 | SYS_FUNC(timer_settime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 385 | { |
| 386 | if (entering(tcp)) { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 387 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 388 | printflags(clockflags, tcp->u_arg[1], "TIMER_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 389 | tprints(", "); |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 390 | print_itimerspec(tcp, tcp->u_arg[2]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 391 | tprints(", "); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 392 | } else { |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 393 | print_itimerspec(tcp, tcp->u_arg[3]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 394 | } |
| 395 | return 0; |
| 396 | } |
| 397 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 398 | SYS_FUNC(timer_gettime) |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 399 | { |
| 400 | if (entering(tcp)) { |
Dmitry V. Levin | 7117835 | 2015-07-16 18:18:09 +0000 | [diff] [blame] | 401 | tprintf("%d, ", (int) tcp->u_arg[0]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 402 | } else { |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 403 | print_itimerspec(tcp, tcp->u_arg[1]); |
Roland McGrath | 1e35679 | 2003-03-30 23:52:28 +0000 | [diff] [blame] | 404 | } |
| 405 | return 0; |
| 406 | } |
Roland McGrath | d83c50b | 2004-10-06 22:27:43 +0000 | [diff] [blame] | 407 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 408 | #include "xlat/timerfdflags.h" |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 409 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 410 | SYS_FUNC(timerfd) |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 411 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 412 | tprintf("%ld, ", tcp->u_arg[0]); |
| 413 | printclockname(tcp->u_arg[0]); |
| 414 | tprints(", "); |
| 415 | printflags(timerfdflags, tcp->u_arg[2], "TFD_???"); |
| 416 | tprints(", "); |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 417 | print_itimerspec(tcp, tcp->u_arg[3]); |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 418 | |
Dmitry V. Levin | 07c878a | 2015-08-02 01:37:19 +0000 | [diff] [blame] | 419 | return RVAL_DECODED | RVAL_FD; |
Roland McGrath | e466234 | 2007-08-02 01:25:34 +0000 | [diff] [blame] | 420 | } |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 421 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 422 | SYS_FUNC(timerfd_create) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 423 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 424 | printclockname(tcp->u_arg[0]); |
| 425 | tprints(", "); |
| 426 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 427 | |
Dmitry V. Levin | 07c878a | 2015-08-02 01:37:19 +0000 | [diff] [blame] | 428 | return RVAL_DECODED | RVAL_FD; |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 429 | } |
| 430 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 431 | SYS_FUNC(timerfd_settime) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 432 | { |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 433 | printfd(tcp, tcp->u_arg[0]); |
| 434 | tprints(", "); |
| 435 | printflags(timerfdflags, tcp->u_arg[1], "TFD_???"); |
| 436 | tprints(", "); |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 437 | print_itimerspec(tcp, tcp->u_arg[2]); |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 438 | tprints(", "); |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 439 | print_itimerspec(tcp, tcp->u_arg[3]); |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 440 | |
| 441 | return RVAL_DECODED; |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 444 | SYS_FUNC(timerfd_gettime) |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 445 | { |
| 446 | if (entering(tcp)) { |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 447 | printfd(tcp, tcp->u_arg[0]); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 448 | tprints(", "); |
Dmitry V. Levin | 76c8f66 | 2015-07-16 21:07:06 +0000 | [diff] [blame] | 449 | } else { |
Dmitry V. Levin | 2206085 | 2015-09-17 16:47:03 +0000 | [diff] [blame] | 450 | print_itimerspec(tcp, tcp->u_arg[1]); |
Roland McGrath | de328e6 | 2008-05-20 04:56:13 +0000 | [diff] [blame] | 451 | } |
| 452 | return 0; |
| 453 | } |