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> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 6 | * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH |
| 7 | * port by Greg Banks <gbanks@pocketpenguins.com> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * 3. The name of the author may not be used to endorse or promote products |
| 19 | * derived from this software without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | * $Id$ |
| 33 | */ |
| 34 | |
| 35 | #include "defs.h" |
| 36 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 37 | #ifdef LINUX |
Roland McGrath | 05cdd3c | 2004-03-02 06:16:59 +0000 | [diff] [blame] | 38 | #include <asm/mman.h> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 40 | #include <sys/mman.h> |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 41 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 42 | #if defined(LINUX) && defined(I386) |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 43 | # include <asm/ldt.h> |
Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 44 | # ifdef HAVE_STRUCT_USER_DESC |
| 45 | # define modify_ldt_ldt_s user_desc |
| 46 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | #endif |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 48 | #if defined(LINUX) && defined(SH64) |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 49 | # include <asm/page.h> /* for PAGE_SHIFT */ |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 50 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 51 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 52 | #ifdef HAVE_LONG_LONG_OFF_T |
| 53 | /* |
| 54 | * Ugly hacks for systems that have a long long off_t |
| 55 | */ |
| 56 | #define sys_mmap64 sys_mmap |
| 57 | #endif |
| 58 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 60 | sys_brk(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 61 | { |
| 62 | if (entering(tcp)) { |
| 63 | tprintf("%#lx", tcp->u_arg[0]); |
| 64 | } |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 65 | #ifdef LINUX |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 66 | return RVAL_HEX; |
| 67 | #else |
| 68 | return 0; |
| 69 | #endif |
| 70 | } |
| 71 | |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 72 | #if defined(FREEBSD) || defined(SUNOS4) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 73 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 74 | sys_sbrk(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 75 | { |
| 76 | if (entering(tcp)) { |
| 77 | tprintf("%lu", tcp->u_arg[0]); |
| 78 | } |
| 79 | return RVAL_HEX; |
| 80 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 81 | #endif /* FREEBSD || SUNOS4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 83 | static const struct xlat mmap_prot[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | { PROT_NONE, "PROT_NONE", }, |
| 85 | { PROT_READ, "PROT_READ" }, |
| 86 | { PROT_WRITE, "PROT_WRITE" }, |
| 87 | { PROT_EXEC, "PROT_EXEC" }, |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 88 | #ifdef PROT_SEM |
| 89 | { PROT_SEM, "PROT_SEM" }, |
| 90 | #endif |
| 91 | #ifdef PROT_GROWSDOWN |
| 92 | { PROT_GROWSDOWN,"PROT_GROWSDOWN"}, |
| 93 | #endif |
| 94 | #ifdef PROT_GROWSUP |
| 95 | { PROT_GROWSUP, "PROT_GROWSUP" }, |
| 96 | #endif |
Roland McGrath | 586d6ab | 2008-08-25 03:00:47 +0000 | [diff] [blame] | 97 | #ifdef PROT_SAO |
| 98 | { PROT_SAO, "PROT_SAO" }, |
| 99 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 100 | { 0, NULL }, |
| 101 | }; |
| 102 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 103 | static const struct xlat mmap_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 104 | { MAP_SHARED, "MAP_SHARED" }, |
| 105 | { MAP_PRIVATE, "MAP_PRIVATE" }, |
| 106 | { MAP_FIXED, "MAP_FIXED" }, |
| 107 | #ifdef MAP_ANONYMOUS |
| 108 | { MAP_ANONYMOUS,"MAP_ANONYMOUS" }, |
| 109 | #endif |
Dmitry V. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 110 | #ifdef MAP_32BIT |
| 111 | { MAP_32BIT, "MAP_32BIT" }, |
| 112 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | #ifdef MAP_RENAME |
| 114 | { MAP_RENAME, "MAP_RENAME" }, |
| 115 | #endif |
| 116 | #ifdef MAP_NORESERVE |
| 117 | { MAP_NORESERVE,"MAP_NORESERVE" }, |
| 118 | #endif |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 119 | #ifdef MAP_POPULATE |
| 120 | { MAP_POPULATE, "MAP_POPULATE" }, |
| 121 | #endif |
| 122 | #ifdef MAP_NONBLOCK |
| 123 | { MAP_NONBLOCK, "MAP_NONBLOCK" }, |
| 124 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 125 | /* |
| 126 | * XXX - this was introduced in SunOS 4.x to distinguish between |
| 127 | * the old pre-4.x "mmap()", which: |
| 128 | * |
| 129 | * only let you map devices with an "mmap" routine (e.g., |
| 130 | * frame buffers) in; |
| 131 | * |
| 132 | * required you to specify the mapping address; |
| 133 | * |
| 134 | * returned 0 on success and -1 on failure; |
| 135 | * |
| 136 | * memory and which, and the 4.x "mmap()" which: |
| 137 | * |
| 138 | * can map plain files; |
| 139 | * |
| 140 | * can be asked to pick where to map the file; |
| 141 | * |
| 142 | * returns the address where it mapped the file on success |
| 143 | * and -1 on failure. |
| 144 | * |
| 145 | * It's not actually used in source code that calls "mmap()"; the |
| 146 | * "mmap()" routine adds it for you. |
| 147 | * |
| 148 | * It'd be nice to come up with some way of eliminating it from |
| 149 | * the flags, e.g. reporting calls *without* it as "old_mmap()" |
| 150 | * and calls with it as "mmap()". |
| 151 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 152 | #ifdef _MAP_NEW |
| 153 | { _MAP_NEW, "_MAP_NEW" }, |
| 154 | #endif |
| 155 | #ifdef MAP_GROWSDOWN |
| 156 | { MAP_GROWSDOWN,"MAP_GROWSDOWN" }, |
| 157 | #endif |
| 158 | #ifdef MAP_DENYWRITE |
| 159 | { MAP_DENYWRITE,"MAP_DENYWRITE" }, |
| 160 | #endif |
| 161 | #ifdef MAP_EXECUTABLE |
| 162 | { MAP_EXECUTABLE,"MAP_EXECUTABLE"}, |
| 163 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 164 | #ifdef MAP_INHERIT |
| 165 | { MAP_INHERIT,"MAP_INHERIT" }, |
| 166 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 167 | #ifdef MAP_FILE |
| 168 | { MAP_FILE,"MAP_FILE"}, |
| 169 | #endif |
| 170 | #ifdef MAP_LOCKED |
| 171 | { MAP_LOCKED,"MAP_LOCKED"}, |
| 172 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 173 | /* FreeBSD ones */ |
| 174 | #ifdef MAP_ANON |
| 175 | { MAP_ANON, "MAP_ANON" }, |
| 176 | #endif |
| 177 | #ifdef MAP_HASSEMAPHORE |
| 178 | { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" }, |
| 179 | #endif |
| 180 | #ifdef MAP_STACK |
| 181 | { MAP_STACK, "MAP_STACK" }, |
| 182 | #endif |
| 183 | #ifdef MAP_NOSYNC |
| 184 | { MAP_NOSYNC, "MAP_NOSYNC" }, |
| 185 | #endif |
| 186 | #ifdef MAP_NOCORE |
| 187 | { MAP_NOCORE, "MAP_NOCORE" }, |
| 188 | #endif |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 189 | #ifdef TILE |
| 190 | { MAP_CACHE_NO_LOCAL, "MAP_CACHE_NO_LOCAL" }, |
| 191 | { MAP_CACHE_NO_L2, "MAP_CACHE_NO_L2" }, |
| 192 | { MAP_CACHE_NO_L1, "MAP_CACHE_NO_L1" }, |
| 193 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | { 0, NULL }, |
| 195 | }; |
| 196 | |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 197 | #ifdef TILE |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 198 | static int |
| 199 | addtileflags(long flags) |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 200 | { |
| 201 | long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK); |
| 202 | flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK); |
| 203 | |
| 204 | if (flags & _MAP_CACHE_INCOHERENT) { |
| 205 | flags &= ~_MAP_CACHE_INCOHERENT; |
| 206 | if (home == MAP_CACHE_HOME_NONE) { |
| 207 | tprintf("|MAP_CACHE_INCOHERENT"); |
| 208 | return flags; |
| 209 | } |
| 210 | tprintf("|_MAP_CACHE_INCOHERENT"); |
| 211 | } |
| 212 | |
| 213 | switch (home) { |
| 214 | case 0: break; |
| 215 | case MAP_CACHE_HOME_HERE: tprintf("|MAP_CACHE_HOME_HERE"); break; |
| 216 | case MAP_CACHE_HOME_NONE: tprintf("|MAP_CACHE_HOME_NONE"); break; |
| 217 | case MAP_CACHE_HOME_SINGLE: tprintf("|MAP_CACHE_HOME_SINGLE"); break; |
| 218 | case MAP_CACHE_HOME_TASK: tprintf("|MAP_CACHE_HOME_TASK"); break; |
| 219 | case MAP_CACHE_HOME_HASH: tprintf("|MAP_CACHE_HOME_HASH"); break; |
| 220 | default: |
| 221 | tprintf("|MAP_CACHE_HOME(%d)", |
| 222 | (home >> _MAP_CACHE_HOME_SHIFT) ); |
| 223 | break; |
| 224 | } |
| 225 | |
| 226 | return flags; |
| 227 | } |
| 228 | #endif |
| 229 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 230 | #if !HAVE_LONG_LONG_OFF_T |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 231 | static int |
| 232 | print_mmap(struct tcb *tcp, long *u_arg, long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 233 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 235 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 236 | if (!u_arg[0]) |
| 237 | tprintf("NULL, "); |
| 238 | else |
| 239 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 240 | /* len */ |
| 241 | tprintf("%lu, ", u_arg[1]); |
| 242 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 243 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 244 | tprintf(", "); |
| 245 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 246 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 248 | #ifdef TILE |
| 249 | addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE)); |
| 250 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 251 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 252 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 253 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 254 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 255 | #endif |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 256 | /* fd */ |
| 257 | tprintf(", "); |
| 258 | printfd(tcp, u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 259 | /* offset */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 260 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 261 | } |
| 262 | return RVAL_HEX; |
| 263 | } |
| 264 | |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 265 | #ifdef LINUX |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 266 | int sys_old_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 267 | { |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 268 | #if defined(IA64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 269 | /* |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 270 | * IA64 processes never call this routine, they only use the |
| 271 | * new `sys_mmap' interface. |
| 272 | * For IA32 processes, this code converts the integer arguments |
| 273 | * that they pushed onto the stack, into longs. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 274 | * |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 275 | * Note that addresses with bit 31 set will be sign extended. |
| 276 | * Fortunately, those addresses are not currently being generated |
| 277 | * for IA32 processes so it's not a problem. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 278 | */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 279 | int i; |
| 280 | long u_arg[6]; |
| 281 | int narrow_arg[6]; |
| 282 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 283 | return 0; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 284 | for (i = 0; i < 6; i++) |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 285 | u_arg[i] = narrow_arg[i]; |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 286 | #elif defined(SH) || defined(SH64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 287 | /* SH has always passed the args in registers */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 288 | long *u_arg = tcp->u_arg; |
Roland McGrath | 6b1d43e | 2003-03-31 01:05:01 +0000 | [diff] [blame] | 289 | #else |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 290 | long u_arg[6]; |
Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 291 | # if defined(X86_64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 292 | if (current_personality == 1) { |
| 293 | int i; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 294 | unsigned narrow_arg[6]; |
| 295 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 296 | return 0; |
| 297 | for (i = 0; i < 6; ++i) |
| 298 | u_arg[i] = narrow_arg[i]; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 299 | } |
| 300 | else |
Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 301 | # endif |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 302 | if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 303 | return 0; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 304 | #endif /* other architectures */ |
| 305 | |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 306 | return print_mmap(tcp, u_arg, u_arg[5]); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 307 | } |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 308 | #endif /* LINUX */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 309 | |
| 310 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 311 | sys_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 312 | { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 313 | long long offset = tcp->u_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 314 | |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 315 | /* FIXME: why only SH64? i386 mmap2 syscall ends up |
| 316 | * in this function, but does not convert offset |
| 317 | * from pages to bytes. See test/mmap_offset_decode.c |
| 318 | * Why SH64 and i386 are handled differently? |
| 319 | */ |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 320 | #if defined(LINUX) && defined(SH64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 321 | /* |
| 322 | * Old mmap differs from new mmap in specifying the |
| 323 | * offset in units of bytes rather than pages. We |
| 324 | * pretend it's in byte units so the user only ever |
| 325 | * sees bytes in the printout. |
| 326 | */ |
| 327 | offset <<= PAGE_SHIFT; |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 328 | #endif |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 329 | #if defined(LINUX_MIPSN32) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 330 | offset = tcp->ext_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 331 | #endif |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 332 | return print_mmap(tcp, tcp->u_arg, offset); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 333 | } |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 334 | #endif /* !HAVE_LONG_LONG_OFF_T */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 335 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 336 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 337 | /* TODO: comment which arches use this routine. |
| 338 | * For one, does ALPHA on Linux use this?? |
| 339 | * From code it seems that it might use 7 or 8 registers, |
| 340 | * which is strange - Linux syscalls can pass maximum of 6 parameters! |
| 341 | */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 342 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 343 | sys_mmap64(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 344 | { |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 345 | if (entering(tcp)) { |
Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 346 | #if !defined(LINUX) || defined(ALPHA) |
| 347 | long *u_arg = tcp->u_arg; |
| 348 | #else |
| 349 | long u_arg[7]; |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 350 | if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, |
| 351 | (char *) u_arg) == -1) |
| 352 | return 0; |
Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 353 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 354 | /* addr */ |
| 355 | tprintf("%#lx, ", u_arg[0]); |
| 356 | /* len */ |
| 357 | tprintf("%lu, ", u_arg[1]); |
| 358 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 359 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 360 | tprintf(", "); |
| 361 | /* flags */ |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 362 | #ifdef MAP_TYPE |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 363 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 364 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 365 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 366 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 367 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 368 | /* fd */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 369 | tprintf(", "); |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 370 | printfd(tcp, u_arg[4]); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 371 | /* offset */ |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 372 | #if !defined(LINUX) || defined(ALPHA) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 373 | printllval(tcp, ", %#llx", 5); |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 374 | #else |
| 375 | /* NOTE: not verified that [5] and [6] should be used. |
| 376 | * It's possible that long long is 64-bit aligned in memory |
| 377 | * and we need to use [6] and [7] here instead: |
| 378 | */ |
| 379 | tprintf(", %#llx", LONG_LONG(u_arg[5], u_arg[6])); |
| 380 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 381 | } |
| 382 | return RVAL_HEX; |
| 383 | } |
Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 384 | #endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 385 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 386 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 387 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 388 | sys_munmap(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 389 | { |
| 390 | if (entering(tcp)) { |
| 391 | tprintf("%#lx, %lu", |
| 392 | tcp->u_arg[0], tcp->u_arg[1]); |
| 393 | } |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 398 | sys_mprotect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 399 | { |
| 400 | if (entering(tcp)) { |
| 401 | tprintf("%#lx, %lu, ", |
| 402 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 403 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 404 | } |
| 405 | return 0; |
| 406 | } |
| 407 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 408 | #ifdef LINUX |
| 409 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 410 | static const struct xlat mremap_flags[] = { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 411 | { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" }, |
Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 412 | #ifdef MREMAP_FIXED |
| 413 | { MREMAP_FIXED, "MREMAP_FIXED" }, |
| 414 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 415 | { 0, NULL } |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 416 | }; |
| 417 | |
| 418 | int |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 419 | sys_mremap(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 420 | { |
| 421 | if (entering(tcp)) { |
| 422 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 423 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 424 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 425 | #ifdef MREMAP_FIXED |
| 426 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 427 | (MREMAP_MAYMOVE | MREMAP_FIXED)) |
| 428 | tprintf(", %#lx", tcp->u_arg[4]); |
| 429 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 430 | } |
| 431 | return RVAL_HEX; |
| 432 | } |
| 433 | |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 434 | static const struct xlat madvise_cmds[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 435 | #ifdef MADV_NORMAL |
| 436 | { MADV_NORMAL, "MADV_NORMAL" }, |
| 437 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 438 | #ifdef MADV_RANDOM |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 439 | { MADV_RANDOM, "MADV_RANDOM" }, |
| 440 | #endif |
| 441 | #ifdef MADV_SEQUENTIAL |
| 442 | { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" }, |
| 443 | #endif |
| 444 | #ifdef MADV_WILLNEED |
| 445 | { MADV_WILLNEED, "MADV_WILLNEED" }, |
| 446 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 447 | #ifdef MADV_DONTNEED |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 448 | { MADV_DONTNEED, "MADV_DONTNEED" }, |
| 449 | #endif |
| 450 | { 0, NULL }, |
| 451 | }; |
| 452 | |
| 453 | |
| 454 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 455 | sys_madvise(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 456 | { |
| 457 | if (entering(tcp)) { |
| 458 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 459 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 460 | } |
| 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 465 | static const struct xlat mlockall_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 466 | #ifdef MCL_CURRENT |
| 467 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 468 | #endif |
| 469 | #ifdef MCL_FUTURE |
| 470 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 471 | #endif |
| 472 | { 0, NULL} |
| 473 | }; |
| 474 | |
| 475 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 476 | sys_mlockall(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 477 | { |
| 478 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 479 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 480 | } |
| 481 | return 0; |
| 482 | } |
| 483 | |
| 484 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 485 | #endif /* LINUX */ |
| 486 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 487 | #ifdef MS_ASYNC |
| 488 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 489 | static const struct xlat mctl_sync[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 490 | #ifdef MS_SYNC |
| 491 | { MS_SYNC, "MS_SYNC" }, |
| 492 | #endif |
John Hughes | aca07f3 | 2001-10-16 18:12:27 +0000 | [diff] [blame] | 493 | { MS_ASYNC, "MS_ASYNC" }, |
| 494 | { MS_INVALIDATE,"MS_INVALIDATE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 495 | { 0, NULL }, |
| 496 | }; |
| 497 | |
| 498 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 499 | sys_msync(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 500 | { |
| 501 | if (entering(tcp)) { |
| 502 | /* addr */ |
| 503 | tprintf("%#lx", tcp->u_arg[0]); |
| 504 | /* len */ |
| 505 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 506 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 507 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 508 | } |
| 509 | return 0; |
| 510 | } |
| 511 | |
| 512 | #endif /* MS_ASYNC */ |
| 513 | |
| 514 | #ifdef MC_SYNC |
| 515 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 516 | static const struct xlat mctl_funcs[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 517 | { MC_LOCK, "MC_LOCK" }, |
| 518 | { MC_LOCKAS, "MC_LOCKAS" }, |
| 519 | { MC_SYNC, "MC_SYNC" }, |
| 520 | { MC_UNLOCK, "MC_UNLOCK" }, |
| 521 | { MC_UNLOCKAS, "MC_UNLOCKAS" }, |
| 522 | { 0, NULL }, |
| 523 | }; |
| 524 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 525 | static const struct xlat mctl_lockas[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 526 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 527 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 528 | { 0, NULL }, |
| 529 | }; |
| 530 | |
| 531 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 532 | sys_mctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 533 | { |
| 534 | int arg, function; |
| 535 | |
| 536 | if (entering(tcp)) { |
| 537 | /* addr */ |
| 538 | tprintf("%#lx", tcp->u_arg[0]); |
| 539 | /* len */ |
| 540 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 541 | /* function */ |
| 542 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 543 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 544 | /* arg */ |
| 545 | arg = tcp->u_arg[3]; |
| 546 | tprintf(", "); |
| 547 | switch (function) { |
| 548 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 549 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 550 | break; |
| 551 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 552 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 553 | break; |
| 554 | default: |
| 555 | tprintf("%#x", arg); |
| 556 | break; |
| 557 | } |
| 558 | } |
| 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | #endif /* MC_SYNC */ |
| 563 | |
| 564 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 565 | sys_mincore(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | { |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 567 | unsigned long i, len; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 568 | char *vec = NULL; |
| 569 | |
| 570 | if (entering(tcp)) { |
| 571 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 572 | } else { |
| 573 | len = tcp->u_arg[1]; |
| 574 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 575 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 576 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 577 | tprintf("%#lx", tcp->u_arg[2]); |
| 578 | else { |
| 579 | tprintf("["); |
| 580 | for (i = 0; i < len; i++) { |
| 581 | if (abbrev(tcp) && i >= max_strlen) { |
| 582 | tprintf("..."); |
| 583 | break; |
| 584 | } |
| 585 | tprintf((vec[i] & 1) ? "1" : "0"); |
| 586 | } |
| 587 | tprintf("]"); |
| 588 | } |
| 589 | if (vec) |
| 590 | free(vec); |
| 591 | } |
| 592 | return 0; |
| 593 | } |
| 594 | |
Roland McGrath | da6c92c | 2007-09-12 01:26:29 +0000 | [diff] [blame] | 595 | #if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 596 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 597 | sys_getpagesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 598 | { |
| 599 | if (exiting(tcp)) |
| 600 | return RVAL_HEX; |
| 601 | return 0; |
| 602 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 603 | #endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 604 | |
| 605 | #if defined(LINUX) && defined(__i386__) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 606 | void |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 607 | print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 608 | { |
| 609 | tprintf("base_addr:%#08lx, " |
| 610 | "limit:%d, " |
| 611 | "seg_32bit:%d, " |
| 612 | "contents:%d, " |
| 613 | "read_exec_only:%d, " |
| 614 | "limit_in_pages:%d, " |
| 615 | "seg_not_present:%d, " |
| 616 | "useable:%d}", |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 617 | (long) ldt_entry->base_addr, |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 618 | ldt_entry->limit, |
| 619 | ldt_entry->seg_32bit, |
| 620 | ldt_entry->contents, |
| 621 | ldt_entry->read_exec_only, |
| 622 | ldt_entry->limit_in_pages, |
| 623 | ldt_entry->seg_not_present, |
| 624 | ldt_entry->useable); |
| 625 | } |
| 626 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 627 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 628 | sys_modify_ldt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 629 | { |
| 630 | if (entering(tcp)) { |
| 631 | struct modify_ldt_ldt_s copy; |
| 632 | tprintf("%ld", tcp->u_arg[0]); |
| 633 | if (tcp->u_arg[1] == 0 |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 634 | || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 635 | || umove(tcp, tcp->u_arg[1], ©) == -1) |
| 636 | tprintf(", %lx", tcp->u_arg[1]); |
| 637 | else { |
| 638 | tprintf(", {entry_number:%d, ", copy.entry_number); |
| 639 | if (!verbose(tcp)) |
| 640 | tprintf("...}"); |
| 641 | else { |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 642 | print_ldt_entry(©); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 643 | } |
| 644 | } |
| 645 | tprintf(", %lu", tcp->u_arg[2]); |
| 646 | } |
| 647 | return 0; |
| 648 | } |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 649 | |
| 650 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 651 | sys_set_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 652 | { |
| 653 | struct modify_ldt_ldt_s copy; |
| 654 | if (entering(tcp)) { |
| 655 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 656 | if (copy.entry_number == -1) |
| 657 | tprintf("{entry_number:%d -> ", |
| 658 | copy.entry_number); |
| 659 | else |
| 660 | tprintf("{entry_number:"); |
| 661 | } |
| 662 | } else { |
| 663 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 664 | tprintf("%d, ", copy.entry_number); |
| 665 | if (!verbose(tcp)) |
| 666 | tprintf("...}"); |
| 667 | else { |
| 668 | print_ldt_entry(©); |
| 669 | } |
| 670 | } else { |
| 671 | tprintf("%lx", tcp->u_arg[0]); |
| 672 | } |
| 673 | } |
| 674 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 675 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 679 | sys_get_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 680 | { |
| 681 | struct modify_ldt_ldt_s copy; |
| 682 | if (exiting(tcp)) { |
| 683 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 684 | tprintf("{entry_number:%d, ", copy.entry_number); |
| 685 | if (!verbose(tcp)) |
| 686 | tprintf("...}"); |
| 687 | else { |
| 688 | print_ldt_entry(©); |
| 689 | } |
| 690 | } else { |
| 691 | tprintf("%lx", tcp->u_arg[0]); |
| 692 | } |
| 693 | } |
| 694 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 695 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 696 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 697 | #endif /* LINUX && __i386__ */ |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 698 | |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 699 | #if defined(LINUX) && defined(M68K) |
| 700 | |
| 701 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 702 | sys_set_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 703 | { |
| 704 | if (entering(tcp)) |
| 705 | tprintf("%#lx", tcp->u_arg[0]); |
| 706 | return 0; |
| 707 | |
| 708 | } |
| 709 | |
| 710 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 711 | sys_get_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 712 | { |
| 713 | return RVAL_HEX; |
| 714 | } |
| 715 | #endif |
| 716 | |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 717 | #if defined(LINUX) |
| 718 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 719 | sys_remap_file_pages(struct tcb *tcp) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 720 | { |
| 721 | if (entering(tcp)) { |
| 722 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 723 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 724 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 725 | #ifdef MAP_TYPE |
| 726 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 727 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 728 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 729 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 730 | #endif |
| 731 | } |
| 732 | return 0; |
| 733 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 734 | |
| 735 | |
| 736 | #define MPOL_DEFAULT 0 |
| 737 | #define MPOL_PREFERRED 1 |
| 738 | #define MPOL_BIND 2 |
| 739 | #define MPOL_INTERLEAVE 3 |
| 740 | |
| 741 | #define MPOL_F_NODE (1<<0) |
| 742 | #define MPOL_F_ADDR (1<<1) |
| 743 | |
| 744 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 745 | #define MPOL_MF_MOVE (1<<1) |
| 746 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 747 | |
| 748 | |
| 749 | static const struct xlat policies[] = { |
| 750 | { MPOL_DEFAULT, "MPOL_DEFAULT" }, |
| 751 | { MPOL_PREFERRED, "MPOL_PREFERRED" }, |
| 752 | { MPOL_BIND, "MPOL_BIND" }, |
| 753 | { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" }, |
| 754 | { 0, NULL } |
| 755 | }; |
| 756 | |
| 757 | static const struct xlat mbindflags[] = { |
| 758 | { MPOL_MF_STRICT, "MPOL_MF_STRICT" }, |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 759 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 760 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 761 | { 0, NULL } |
| 762 | }; |
| 763 | |
| 764 | static const struct xlat mempolicyflags[] = { |
| 765 | { MPOL_F_NODE, "MPOL_F_NODE" }, |
| 766 | { MPOL_F_ADDR, "MPOL_F_ADDR" }, |
| 767 | { 0, NULL } |
| 768 | }; |
| 769 | |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 770 | static const struct xlat move_pages_flags[] = { |
| 771 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 772 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
| 773 | { 0, NULL } |
| 774 | }; |
| 775 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 776 | |
| 777 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 778 | get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 779 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 780 | unsigned long nlongs, size, end; |
| 781 | |
| 782 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 783 | size = nlongs * sizeof(long); |
| 784 | end = ptr + size; |
| 785 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 786 | && (end > ptr))) { |
| 787 | unsigned long n, cur, abbrev_end; |
| 788 | int failed = 0; |
| 789 | |
| 790 | if (abbrev(tcp)) { |
| 791 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 792 | if (abbrev_end < ptr) |
| 793 | abbrev_end = end; |
| 794 | } else { |
| 795 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 796 | } |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 797 | tprintf(", {"); |
| 798 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 799 | if (cur > ptr) |
| 800 | tprintf(", "); |
| 801 | if (cur >= abbrev_end) { |
| 802 | tprintf("..."); |
| 803 | break; |
| 804 | } |
| 805 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
| 806 | tprintf("?"); |
| 807 | failed = 1; |
| 808 | break; |
| 809 | } |
| 810 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 811 | } |
| 812 | tprintf("}"); |
| 813 | if (failed) |
| 814 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 815 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 816 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 817 | tprintf(", %lu", maxnodes); |
| 818 | } |
| 819 | |
| 820 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 821 | sys_mbind(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 822 | { |
| 823 | if (entering(tcp)) { |
Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 824 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 825 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 826 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
| 827 | tprintf(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 828 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 829 | } |
| 830 | return 0; |
| 831 | } |
| 832 | |
| 833 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 834 | sys_set_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 835 | { |
| 836 | if (entering(tcp)) { |
| 837 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 838 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 839 | } |
| 840 | return 0; |
| 841 | } |
| 842 | |
| 843 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 844 | sys_get_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 845 | { |
| 846 | if (exiting(tcp)) { |
| 847 | int pol; |
| 848 | if (tcp->u_arg[0] == 0) |
| 849 | tprintf("NULL"); |
| 850 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 851 | tprintf("%#lx", tcp->u_arg[0]); |
| 852 | else |
| 853 | printxval(policies, pol, "MPOL_???"); |
| 854 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 855 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 856 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 857 | } |
| 858 | return 0; |
| 859 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 860 | |
| 861 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 862 | sys_move_pages(struct tcb *tcp) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 863 | { |
| 864 | if (entering(tcp)) { |
| 865 | unsigned long npages = tcp->u_arg[1]; |
| 866 | tprintf("%ld, %lu, ", tcp->u_arg[0], npages); |
| 867 | if (tcp->u_arg[2] == 0) |
| 868 | tprintf("NULL, "); |
| 869 | else { |
| 870 | int i; |
| 871 | long puser = tcp->u_arg[2]; |
| 872 | tprintf("{"); |
| 873 | for (i = 0; i < npages; ++i) { |
| 874 | void *p; |
| 875 | if (i > 0) |
| 876 | tprintf(", "); |
| 877 | if (umove(tcp, puser, &p) < 0) { |
| 878 | tprintf("???"); |
| 879 | break; |
| 880 | } |
| 881 | tprintf("%p", p); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 882 | puser += sizeof(void *); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 883 | } |
| 884 | tprintf("}, "); |
| 885 | } |
| 886 | if (tcp->u_arg[3] == 0) |
| 887 | tprintf("NULL, "); |
| 888 | else { |
| 889 | int i; |
| 890 | long nodeuser = tcp->u_arg[3]; |
| 891 | tprintf("{"); |
| 892 | for (i = 0; i < npages; ++i) { |
| 893 | int node; |
| 894 | if (i > 0) |
| 895 | tprintf(", "); |
| 896 | if (umove(tcp, nodeuser, &node) < 0) { |
| 897 | tprintf("???"); |
| 898 | break; |
| 899 | } |
| 900 | tprintf("%#x", node); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 901 | nodeuser += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 902 | } |
| 903 | tprintf("}, "); |
| 904 | } |
| 905 | } |
| 906 | if (exiting(tcp)) { |
| 907 | unsigned long npages = tcp->u_arg[1]; |
| 908 | if (tcp->u_arg[4] == 0) |
| 909 | tprintf("NULL, "); |
| 910 | else { |
| 911 | int i; |
| 912 | long statususer = tcp->u_arg[4]; |
| 913 | tprintf("{"); |
| 914 | for (i = 0; i < npages; ++i) { |
| 915 | int status; |
| 916 | if (i > 0) |
| 917 | tprintf(", "); |
| 918 | if (umove(tcp, statususer, &status) < 0) { |
| 919 | tprintf("???"); |
| 920 | break; |
| 921 | } |
| 922 | tprintf("%#x", status); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 923 | statususer += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 924 | } |
| 925 | tprintf("}, "); |
| 926 | } |
| 927 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 928 | } |
| 929 | return 0; |
| 930 | } |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 931 | #endif |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 932 | |
| 933 | #if defined(LINUX) && defined(POWERPC) |
| 934 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 935 | sys_subpage_prot(struct tcb *tcp) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 936 | { |
| 937 | if (entering(tcp)) { |
| 938 | unsigned long cur, end, abbrev_end, entries; |
| 939 | unsigned int entry; |
| 940 | |
| 941 | tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 942 | entries = tcp->u_arg[1] >> 16; |
| 943 | if (!entries || !tcp->u_arg[2]) { |
| 944 | tprintf("{}"); |
| 945 | return 0; |
| 946 | } |
| 947 | cur = tcp->u_arg[2]; |
| 948 | end = cur + (sizeof(int) * entries); |
| 949 | if (!verbose(tcp) || end < tcp->u_arg[2]) { |
| 950 | tprintf("%#lx", tcp->u_arg[2]); |
| 951 | return 0; |
| 952 | } |
| 953 | if (abbrev(tcp)) { |
| 954 | abbrev_end = cur + (sizeof(int) * max_strlen); |
| 955 | if (abbrev_end > end) |
| 956 | abbrev_end = end; |
| 957 | } |
| 958 | else |
| 959 | abbrev_end = end; |
| 960 | tprintf("{"); |
| 961 | for (; cur < end; cur += sizeof(int)) { |
| 962 | if (cur > tcp->u_arg[2]) |
| 963 | tprintf(", "); |
| 964 | if (cur >= abbrev_end) { |
| 965 | tprintf("..."); |
| 966 | break; |
| 967 | } |
| 968 | if (umove(tcp, cur, &entry) < 0) { |
| 969 | tprintf("??? [%#lx]", cur); |
| 970 | break; |
| 971 | } |
| 972 | else |
| 973 | tprintf("%#08x", entry); |
| 974 | } |
| 975 | tprintf("}"); |
| 976 | } |
| 977 | |
| 978 | return 0; |
| 979 | } |
| 980 | #endif |