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> |
| 36 | #include <linux/timex.h> |
| 37 | #endif /* LINUX */ |
| 38 | |
| 39 | void |
| 40 | printtv(tcp, addr) |
| 41 | struct tcb *tcp; |
| 42 | long addr; |
| 43 | { |
| 44 | struct timeval tv; |
| 45 | |
| 46 | if (addr == 0) |
| 47 | tprintf("NULL"); |
| 48 | else if (!verbose(tcp)) |
| 49 | tprintf("%#lx", addr); |
| 50 | else if (umove(tcp, addr, &tv) < 0) |
| 51 | tprintf("{...}"); |
| 52 | else |
| 53 | tprintf("{%lu, %lu}", (long) tv.tv_sec, (long) tv.tv_usec); |
| 54 | } |
| 55 | |
| 56 | int |
| 57 | sys_time(tcp) |
| 58 | struct tcb *tcp; |
| 59 | { |
| 60 | if (exiting(tcp)) { |
| 61 | #ifndef SVR4 |
| 62 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 63 | #endif /* SVR4 */ |
| 64 | } |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | int |
| 69 | sys_stime(tcp) |
| 70 | struct tcb *tcp; |
| 71 | { |
| 72 | if (exiting(tcp)) { |
| 73 | printnum(tcp, tcp->u_arg[0], "%ld"); |
| 74 | } |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | int |
| 79 | sys_gettimeofday(tcp) |
| 80 | struct tcb *tcp; |
| 81 | { |
| 82 | if (exiting(tcp)) { |
| 83 | if (syserror(tcp)) { |
| 84 | tprintf("%#lx, %#lx", |
| 85 | tcp->u_arg[0], tcp->u_arg[1]); |
| 86 | return 0; |
| 87 | } |
| 88 | printtv(tcp, tcp->u_arg[0]); |
| 89 | #ifndef SVR4 |
| 90 | tprintf(", "); |
| 91 | printtv(tcp, tcp->u_arg[1]); |
| 92 | #endif /* !SVR4 */ |
| 93 | } |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | int |
| 98 | sys_settimeofday(tcp) |
| 99 | struct tcb *tcp; |
| 100 | { |
| 101 | if (entering(tcp)) { |
| 102 | printtv(tcp, tcp->u_arg[0]); |
| 103 | #ifndef SVR4 |
| 104 | tprintf(", "); |
| 105 | printtv(tcp, tcp->u_arg[1]); |
| 106 | #endif /* !SVR4 */ |
| 107 | } |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | int |
| 112 | sys_adjtime(tcp) |
| 113 | struct tcb *tcp; |
| 114 | { |
| 115 | if (entering(tcp)) { |
| 116 | printtv(tcp, tcp->u_arg[0]); |
| 117 | tprintf(", "); |
| 118 | } else { |
| 119 | if (syserror(tcp)) |
| 120 | tprintf("%#lx", tcp->u_arg[1]); |
| 121 | else |
| 122 | printtv(tcp, tcp->u_arg[1]); |
| 123 | } |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | static struct xlat which[] = { |
| 128 | { ITIMER_REAL, "ITIMER_REAL" }, |
| 129 | { ITIMER_VIRTUAL,"ITIMER_VIRTUAL"}, |
| 130 | { ITIMER_PROF, "ITIMER_PROF" }, |
| 131 | { 0, NULL }, |
| 132 | }; |
| 133 | |
| 134 | static void |
| 135 | printitv(tcp, addr) |
| 136 | struct tcb *tcp; |
| 137 | long addr; |
| 138 | { |
| 139 | struct itimerval itv; |
| 140 | |
| 141 | if (addr == 0) |
| 142 | tprintf("NULL"); |
| 143 | else if (!verbose(tcp)) |
| 144 | tprintf("%#lx", addr); |
| 145 | else if (umove(tcp, addr, &itv) < 0) |
| 146 | tprintf("{...}"); |
| 147 | else { |
| 148 | tprintf("{it_interval={%lu, %lu}, it_value={%lu, %lu}}", |
| 149 | (long) itv.it_interval.tv_sec, (long) itv.it_interval.tv_usec, |
| 150 | (long) itv.it_value.tv_sec, (long) itv.it_value.tv_usec); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | int |
| 155 | sys_getitimer(tcp) |
| 156 | struct tcb *tcp; |
| 157 | { |
| 158 | if (entering(tcp)) { |
| 159 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 160 | tprintf(", "); |
| 161 | } else { |
| 162 | if (syserror(tcp)) |
| 163 | tprintf("%#lx", tcp->u_arg[1]); |
| 164 | else |
| 165 | printitv(tcp, tcp->u_arg[1]); |
| 166 | } |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | int |
| 171 | sys_setitimer(tcp) |
| 172 | struct tcb *tcp; |
| 173 | { |
| 174 | if (entering(tcp)) { |
| 175 | printxval(which, tcp->u_arg[0], "ITIMER_???"); |
| 176 | tprintf(", "); |
| 177 | printitv(tcp, tcp->u_arg[1]); |
| 178 | tprintf(", "); |
| 179 | } else { |
| 180 | if (syserror(tcp)) |
| 181 | tprintf("%#lx", tcp->u_arg[2]); |
| 182 | else |
| 183 | printitv(tcp, tcp->u_arg[2]); |
| 184 | } |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | #ifdef LINUX |
| 189 | |
| 190 | int |
| 191 | sys_adjtimex(tcp) |
| 192 | struct tcb *tcp; |
| 193 | { |
| 194 | struct timex txc; |
| 195 | |
| 196 | if (exiting(tcp)) { |
| 197 | if (tcp->u_arg[0] == 0) |
| 198 | tprintf("NULL"); |
| 199 | else if (syserror(tcp) || !verbose(tcp)) |
| 200 | tprintf("%#lx", tcp->u_arg[0]); |
| 201 | else if (umove(tcp, tcp->u_arg[0], &txc) < 0) |
| 202 | tprintf("{...}"); |
| 203 | else { |
| 204 | #if LINUX_VERSION_CODE < 66332 |
| 205 | tprintf("{mode=%d, offset=%ld, frequency=%ld, ", |
| 206 | txc.mode, txc.offset, txc.frequency); |
| 207 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 208 | txc.maxerror, txc.esterror, txc.status); |
| 209 | tprintf("time_constant=%ld, precision=%lu, ", |
| 210 | txc.time_constant, txc.precision); |
| 211 | tprintf("tolerance=%ld, time={%lu, %lu}}", |
| 212 | txc.tolerance, (long) txc.time.tv_sec, |
| 213 | (long) txc.time.tv_usec); |
| 214 | #else |
| 215 | tprintf("{modes=%d, offset=%ld, freq=%ld, ", |
| 216 | txc.modes, txc.offset, txc.freq); |
| 217 | tprintf("maxerror=%ld, esterror=%lu, status=%u, ", |
| 218 | txc.maxerror, txc.esterror, txc.status); |
| 219 | tprintf("constant=%ld, precision=%lu, ", |
| 220 | txc.constant, txc.precision); |
| 221 | tprintf("tolerance=%ld, time={%lu, %lu}}", |
| 222 | txc.tolerance, (long) txc.time.tv_sec, |
| 223 | (long) txc.time.tv_usec); |
| 224 | /* there's a bunch of other stuff, but it's not |
| 225 | * worth the time or the trouble to include */ |
| 226 | #endif |
| 227 | } |
| 228 | } |
| 229 | return 0; |
| 230 | } |
| 231 | #endif /* LINUX */ |
| 232 | |