OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 /* ***** BEGIN LICENSE BLOCK ***** |
| 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 4 * |
| 5 * The contents of this file are subject to the Mozilla Public License Version |
| 6 * 1.1 (the "License"); you may not use this file except in compliance with |
| 7 * the License. You may obtain a copy of the License at |
| 8 * http://www.mozilla.org/MPL/ |
| 9 * |
| 10 * Software distributed under the License is distributed on an "AS IS" basis, |
| 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 12 * for the specific language governing rights and limitations under the |
| 13 * License. |
| 14 * |
| 15 * The Original Code is the Netscape Portable Runtime (NSPR). |
| 16 * |
| 17 * The Initial Developer of the Original Code is |
| 18 * Netscape Communications Corporation. |
| 19 * Portions created by the Initial Developer are Copyright (C) 1998-2000 |
| 20 * the Initial Developer. All Rights Reserved. |
| 21 * |
| 22 * Contributor(s): |
| 23 * |
| 24 * Alternatively, the contents of this file may be used under the terms of |
| 25 * either the GNU General Public License Version 2 or later (the "GPL"), or |
| 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
| 27 * in which case the provisions of the GPL or the LGPL are applicable instead |
| 28 * of those above. If you wish to allow use of your version of this file only |
| 29 * under the terms of either the GPL or the LGPL, and not to allow others to |
| 30 * use your version of this file under the terms of the MPL, indicate your |
| 31 * decision by deleting the provisions above and replace them with the notice |
| 32 * and other provisions required by the GPL or the LGPL. If you do not delete |
| 33 * the provisions above, a recipient may use your version of this file under |
| 34 * the terms of any one of the MPL, the GPL or the LGPL. |
| 35 * |
| 36 * ***** END LICENSE BLOCK ***** */ |
| 37 |
| 38 #ifndef nspr_linux_defs_h___ |
| 39 #define nspr_linux_defs_h___ |
| 40 |
| 41 #include "prthread.h" |
| 42 |
| 43 /* |
| 44 * Internal configuration macros |
| 45 */ |
| 46 |
| 47 #define PR_LINKER_ARCH "linux" |
| 48 #define _PR_SI_SYSNAME "LINUX" |
| 49 #ifdef __powerpc64__ |
| 50 #define _PR_SI_ARCHITECTURE "ppc64" |
| 51 #elif defined(__powerpc__) |
| 52 #define _PR_SI_ARCHITECTURE "ppc" |
| 53 #elif defined(__alpha) |
| 54 #define _PR_SI_ARCHITECTURE "alpha" |
| 55 #elif defined(__ia64__) |
| 56 #define _PR_SI_ARCHITECTURE "ia64" |
| 57 #elif defined(__x86_64__) |
| 58 #define _PR_SI_ARCHITECTURE "x86-64" |
| 59 #elif defined(__mc68000__) |
| 60 #define _PR_SI_ARCHITECTURE "m68k" |
| 61 #elif defined(__sparc__) |
| 62 #define _PR_SI_ARCHITECTURE "sparc" |
| 63 #elif defined(__i386__) |
| 64 #define _PR_SI_ARCHITECTURE "x86" |
| 65 #elif defined(__mips__) |
| 66 #define _PR_SI_ARCHITECTURE "mips" |
| 67 #elif defined(__arm__) |
| 68 #define _PR_SI_ARCHITECTURE "arm" |
| 69 #elif defined(__hppa__) |
| 70 #define _PR_SI_ARCHITECTURE "hppa" |
| 71 #elif defined(__s390x__) |
| 72 #define _PR_SI_ARCHITECTURE "s390x" |
| 73 #elif defined(__s390__) |
| 74 #define _PR_SI_ARCHITECTURE "s390" |
| 75 #else |
| 76 #error "Unknown CPU architecture" |
| 77 #endif |
| 78 #define PR_DLL_SUFFIX ".so" |
| 79 |
| 80 #define _PR_VMBASE 0x30000000 |
| 81 #define _PR_STACK_VMBASE 0x50000000 |
| 82 #define _MD_DEFAULT_STACK_SIZE 65536L |
| 83 #define _MD_MMAP_FLAGS MAP_PRIVATE |
| 84 |
| 85 #undef HAVE_STACK_GROWING_UP |
| 86 |
| 87 /* |
| 88 * Elf linux supports dl* functions |
| 89 */ |
| 90 #define HAVE_DLL |
| 91 #define USE_DLFCN |
| 92 |
| 93 #if defined(__i386__) |
| 94 #define _PR_HAVE_ATOMIC_OPS |
| 95 #define _MD_INIT_ATOMIC() |
| 96 extern PRInt32 _PR_x86_AtomicIncrement(PRInt32 *val); |
| 97 #define _MD_ATOMIC_INCREMENT _PR_x86_AtomicIncrement |
| 98 extern PRInt32 _PR_x86_AtomicDecrement(PRInt32 *val); |
| 99 #define _MD_ATOMIC_DECREMENT _PR_x86_AtomicDecrement |
| 100 extern PRInt32 _PR_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val); |
| 101 #define _MD_ATOMIC_ADD _PR_x86_AtomicAdd |
| 102 extern PRInt32 _PR_x86_AtomicSet(PRInt32 *val, PRInt32 newval); |
| 103 #define _MD_ATOMIC_SET _PR_x86_AtomicSet |
| 104 #endif |
| 105 |
| 106 #if defined(__ia64__) |
| 107 #define _PR_HAVE_ATOMIC_OPS |
| 108 #define _MD_INIT_ATOMIC() |
| 109 extern PRInt32 _PR_ia64_AtomicIncrement(PRInt32 *val); |
| 110 #define _MD_ATOMIC_INCREMENT _PR_ia64_AtomicIncrement |
| 111 extern PRInt32 _PR_ia64_AtomicDecrement(PRInt32 *val); |
| 112 #define _MD_ATOMIC_DECREMENT _PR_ia64_AtomicDecrement |
| 113 extern PRInt32 _PR_ia64_AtomicAdd(PRInt32 *ptr, PRInt32 val); |
| 114 #define _MD_ATOMIC_ADD _PR_ia64_AtomicAdd |
| 115 extern PRInt32 _PR_ia64_AtomicSet(PRInt32 *val, PRInt32 newval); |
| 116 #define _MD_ATOMIC_SET _PR_ia64_AtomicSet |
| 117 #endif |
| 118 |
| 119 #if defined(__x86_64__) |
| 120 #define _PR_HAVE_ATOMIC_OPS |
| 121 #define _MD_INIT_ATOMIC() |
| 122 extern PRInt32 _PR_x86_64_AtomicIncrement(PRInt32 *val); |
| 123 #define _MD_ATOMIC_INCREMENT _PR_x86_64_AtomicIncrement |
| 124 extern PRInt32 _PR_x86_64_AtomicDecrement(PRInt32 *val); |
| 125 #define _MD_ATOMIC_DECREMENT _PR_x86_64_AtomicDecrement |
| 126 extern PRInt32 _PR_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val); |
| 127 #define _MD_ATOMIC_ADD _PR_x86_64_AtomicAdd |
| 128 extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval); |
| 129 #define _MD_ATOMIC_SET _PR_x86_64_AtomicSet |
| 130 #endif |
| 131 |
| 132 #if defined(__alpha) |
| 133 #define _PR_HAVE_ATOMIC_OPS |
| 134 #define _MD_INIT_ATOMIC() |
| 135 #define _MD_ATOMIC_ADD(ptr, i) ({ \ |
| 136 PRInt32 __atomic_tmp, __atomic_ret; \ |
| 137 __asm__ __volatile__( \ |
| 138 "1: ldl_l %[ret], %[val] \n" \ |
| 139 " addl %[ret], %[inc], %[tmp] \n" \ |
| 140 " addl %[ret], %[inc], %[ret] \n" \ |
| 141 " stl_c %[tmp], %[val] \n" \ |
| 142 " beq %[tmp], 2f \n" \ |
| 143 ".subsection 2 \n" \ |
| 144 "2: br 1b \n" \ |
| 145 ".previous" \ |
| 146 : [ret] "=&r" (__atomic_ret), \ |
| 147 [tmp] "=&r" (__atomic_tmp), \ |
| 148 [val] "=m" (*ptr) \ |
| 149 : [inc] "Ir" (i), "m" (*ptr)); \ |
| 150 __atomic_ret; \ |
| 151 }) |
| 152 #define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1) |
| 153 #define _MD_ATOMIC_DECREMENT(ptr) ({ \ |
| 154 PRInt32 __atomic_tmp, __atomic_ret; \ |
| 155 __asm__ __volatile__( \ |
| 156 "1: ldl_l %[ret], %[val] \n" \ |
| 157 " subl %[ret], 1, %[tmp] \n" \ |
| 158 " subl %[ret], 1, %[ret] \n" \ |
| 159 " stl_c %[tmp], %[val] \n" \ |
| 160 " beq %[tmp], 2f \n" \ |
| 161 ".subsection 2 \n" \ |
| 162 "2: br 1b \n" \ |
| 163 ".previous" \ |
| 164 : [ret] "=&r" (__atomic_ret), \ |
| 165 [tmp] "=&r" (__atomic_tmp), \ |
| 166 [val] "=m" (*ptr) \ |
| 167 : "m" (*ptr)); \ |
| 168 __atomic_ret; \ |
| 169 }) |
| 170 #define _MD_ATOMIC_SET(ptr, n) ({ \ |
| 171 PRInt32 __atomic_tmp, __atomic_ret; \ |
| 172 __asm__ __volatile__( \ |
| 173 "1: ldl_l %[ret], %[val] \n" \ |
| 174 " mov %[newval], %[tmp] \n" \ |
| 175 " stl_c %[tmp], %[val] \n" \ |
| 176 " beq %[tmp], 2f \n" \ |
| 177 ".subsection 2 \n" \ |
| 178 "2: br 1b \n" \ |
| 179 ".previous" \ |
| 180 : [ret] "=&r" (__atomic_ret), \ |
| 181 [tmp] "=&r"(__atomic_tmp), \ |
| 182 [val] "=m" (*ptr) \ |
| 183 : [newval] "Ir" (n), "m" (*ptr)); \ |
| 184 __atomic_ret; \ |
| 185 }) |
| 186 #endif |
| 187 |
| 188 #define USE_SETJMP |
| 189 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 190 #define _PR_POLL_AVAILABLE |
| 191 #endif |
| 192 #undef _PR_USE_POLL |
| 193 #define _PR_STAT_HAS_ONLY_ST_ATIME |
| 194 #if defined(__alpha) || defined(__ia64__) |
| 195 #define _PR_HAVE_LARGE_OFF_T |
| 196 #elif (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) |
| 197 #define _PR_HAVE_OFF64_T |
| 198 #else |
| 199 #define _PR_NO_LARGE_FILES |
| 200 #endif |
| 201 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) |
| 202 #define _PR_INET6 |
| 203 #define _PR_HAVE_INET_NTOP |
| 204 #define _PR_HAVE_GETHOSTBYNAME2 |
| 205 #define _PR_HAVE_GETADDRINFO |
| 206 #define _PR_INET6_PROBE |
| 207 #endif |
| 208 #define _PR_HAVE_SYSV_SEMAPHORES |
| 209 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY |
| 210 #if (__GLIBC__ >= 2) && defined(_PR_PTHREADS) |
| 211 #define _PR_HAVE_GETHOST_R |
| 212 #define _PR_HAVE_GETHOST_R_INT |
| 213 #endif |
| 214 |
| 215 #ifdef _PR_PTHREADS |
| 216 |
| 217 extern void _MD_CleanupBeforeExit(void); |
| 218 #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit |
| 219 |
| 220 #else /* ! _PR_PTHREADS */ |
| 221 |
| 222 #include <setjmp.h> |
| 223 |
| 224 #define PR_CONTEXT_TYPE sigjmp_buf |
| 225 |
| 226 #define CONTEXT(_th) ((_th)->md.context) |
| 227 |
| 228 #ifdef __powerpc__ |
| 229 /* |
| 230 * PowerPC based MkLinux |
| 231 * |
| 232 * On the PowerPC, the new style jmp_buf isn't used until glibc |
| 233 * 2.1. |
| 234 */ |
| 235 #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) |
| 236 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_GPR1] |
| 237 #else |
| 238 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__misc[0] |
| 239 #endif /* glibc 2.1 or later */ |
| 240 #define _MD_SET_FP(_t, val) |
| 241 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 242 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 243 /* aix = 64, macos = 70 */ |
| 244 #define PR_NUM_GCREGS 64 |
| 245 |
| 246 #elif defined(__alpha) |
| 247 /* Alpha based Linux */ |
| 248 |
| 249 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 250 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP] |
| 251 #define _MD_SET_FP(_t, val) |
| 252 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 253 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 254 #define _MD_SP_TYPE long int |
| 255 #else |
| 256 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp |
| 257 #define _MD_SET_FP(_t, val) |
| 258 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 259 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 260 #define _MD_SP_TYPE __ptr_t |
| 261 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 262 |
| 263 /* XXX not sure if this is correct, or maybe it should be 17? */ |
| 264 #define PR_NUM_GCREGS 9 |
| 265 |
| 266 #elif defined(__ia64__) |
| 267 |
| 268 #define _MD_GET_SP(_t) ((long *)((_t)->md.context[0].__jmpbuf)[0]) |
| 269 #define _MD_SET_FP(_t, val) |
| 270 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 271 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 272 #define _MD_SP_TYPE long int |
| 273 |
| 274 #define PR_NUM_GCREGS _JBLEN |
| 275 |
| 276 #elif defined(__mc68000__) |
| 277 /* m68k based Linux */ |
| 278 |
| 279 /* |
| 280 * On the m68k, glibc still uses the old style sigjmp_buf, even |
| 281 * in glibc 2.0.7. |
| 282 */ |
| 283 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 284 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp |
| 285 #define _MD_SET_FP(_t, val) |
| 286 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 287 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 288 #define _MD_SP_TYPE int |
| 289 #else |
| 290 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp |
| 291 #define _MD_SET_FP(_t, val) |
| 292 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 293 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 294 #define _MD_SP_TYPE __ptr_t |
| 295 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 296 |
| 297 /* XXX not sure if this is correct, or maybe it should be 17? */ |
| 298 #define PR_NUM_GCREGS 9 |
| 299 |
| 300 #elif defined(__sparc__) |
| 301 /* Sparc */ |
| 302 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 303 /* |
| 304 * You need glibc2-2.0.7-25 or later. The libraries that came with |
| 305 * Red Hat 5.1 are not new enough, but they are in 5.2. |
| 306 */ |
| 307 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP] |
| 308 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_FP] = val) |
| 309 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 310 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_FP]) |
| 311 #define _MD_SP_TYPE int |
| 312 #else |
| 313 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__fp |
| 314 #define _MD_SET_FP(_t, val) |
| 315 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 316 #define _MD_GET_FP_PTR(_t) ((void *) 0) |
| 317 #define _MD_SP_TYPE __ptr_t |
| 318 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 319 |
| 320 #elif defined(__i386__) |
| 321 /* Intel based Linux */ |
| 322 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 323 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[JB_SP] |
| 324 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[JB_BP] = val) |
| 325 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 326 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[JB_BP]) |
| 327 #define _MD_SP_TYPE int |
| 328 #else |
| 329 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp |
| 330 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__bp = val) |
| 331 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 332 #define _MD_GET_FP_PTR(_t) &((_t)->md.context[0].__jmpbuf[0].__bp) |
| 333 #define _MD_SP_TYPE __ptr_t |
| 334 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 335 #define PR_NUM_GCREGS 6 |
| 336 |
| 337 #elif defined(__mips__) |
| 338 /* Linux/MIPS */ |
| 339 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 340 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[0].__sp |
| 341 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[0].__fp = (val)) |
| 342 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 343 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[0].__fp) |
| 344 #define _MD_SP_TYPE __ptr_t |
| 345 #else |
| 346 #error "Linux/MIPS pre-glibc2 not supported yet" |
| 347 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 348 |
| 349 #elif defined(__arm__) |
| 350 /* ARM/Linux */ |
| 351 #if defined(__GLIBC__) && __GLIBC__ >= 2 |
| 352 #define _MD_GET_SP(_t) (_t)->md.context[0].__jmpbuf[20] |
| 353 #define _MD_SET_FP(_t, val) ((_t)->md.context[0].__jmpbuf[19] = (val)) |
| 354 #define _MD_GET_SP_PTR(_t) &(_MD_GET_SP(_t)) |
| 355 #define _MD_GET_FP_PTR(_t) (&(_t)->md.context[0].__jmpbuf[19]) |
| 356 #define _MD_SP_TYPE __ptr_t |
| 357 #else |
| 358 #error "ARM/Linux pre-glibc2 not supported yet" |
| 359 #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 360 |
| 361 #else |
| 362 |
| 363 #error "Unknown CPU architecture" |
| 364 |
| 365 #endif /*__powerpc__*/ |
| 366 |
| 367 /* |
| 368 ** Initialize a thread context to run "_main()" when started |
| 369 */ |
| 370 #ifdef __powerpc__ |
| 371 |
| 372 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
| 373 { \ |
| 374 *status = PR_TRUE; \ |
| 375 if (sigsetjmp(CONTEXT(_thread), 1)) { \ |
| 376 _main(); \ |
| 377 } \ |
| 378 _MD_GET_SP(_thread) = (unsigned char*) ((_sp) - 128); \ |
| 379 _thread->md.sp = _MD_GET_SP_PTR(_thread); \ |
| 380 _thread->md.fp = _MD_GET_FP_PTR(_thread); \ |
| 381 _MD_SET_FP(_thread, 0); \ |
| 382 } |
| 383 |
| 384 #elif defined(__mips__) |
| 385 |
| 386 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
| 387 { \ |
| 388 *status = PR_TRUE; \ |
| 389 (void) sigsetjmp(CONTEXT(_thread), 1); \ |
| 390 _thread->md.context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \ |
| 391 _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \ |
| 392 _thread->md.sp = _MD_GET_SP_PTR(_thread); \ |
| 393 _thread->md.fp = _MD_GET_FP_PTR(_thread); \ |
| 394 _MD_SET_FP(_thread, 0); \ |
| 395 } |
| 396 |
| 397 #else |
| 398 |
| 399 #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
| 400 { \ |
| 401 *status = PR_TRUE; \ |
| 402 if (sigsetjmp(CONTEXT(_thread), 1)) { \ |
| 403 _main(); \ |
| 404 } \ |
| 405 _MD_GET_SP(_thread) = (_MD_SP_TYPE) ((_sp) - 64); \ |
| 406 _thread->md.sp = _MD_GET_SP_PTR(_thread); \ |
| 407 _thread->md.fp = _MD_GET_FP_PTR(_thread); \ |
| 408 _MD_SET_FP(_thread, 0); \ |
| 409 } |
| 410 |
| 411 #endif /*__powerpc__*/ |
| 412 |
| 413 #define _MD_SWITCH_CONTEXT(_thread) \ |
| 414 if (!sigsetjmp(CONTEXT(_thread), 1)) { \ |
| 415 (_thread)->md.errcode = errno; \ |
| 416 _PR_Schedule(); \ |
| 417 } |
| 418 |
| 419 /* |
| 420 ** Restore a thread context, saved by _MD_SWITCH_CONTEXT |
| 421 */ |
| 422 #define _MD_RESTORE_CONTEXT(_thread) \ |
| 423 { \ |
| 424 errno = (_thread)->md.errcode; \ |
| 425 _MD_SET_CURRENT_THREAD(_thread); \ |
| 426 siglongjmp(CONTEXT(_thread), 1); \ |
| 427 } |
| 428 |
| 429 /* Machine-dependent (MD) data structures */ |
| 430 |
| 431 struct _MDThread { |
| 432 PR_CONTEXT_TYPE context; |
| 433 void *sp; |
| 434 void *fp; |
| 435 int id; |
| 436 int errcode; |
| 437 }; |
| 438 |
| 439 struct _MDThreadStack { |
| 440 PRInt8 notused; |
| 441 }; |
| 442 |
| 443 struct _MDLock { |
| 444 PRInt8 notused; |
| 445 }; |
| 446 |
| 447 struct _MDSemaphore { |
| 448 PRInt8 notused; |
| 449 }; |
| 450 |
| 451 struct _MDCVar { |
| 452 PRInt8 notused; |
| 453 }; |
| 454 |
| 455 struct _MDSegment { |
| 456 PRInt8 notused; |
| 457 }; |
| 458 |
| 459 /* |
| 460 * md-specific cpu structure field |
| 461 */ |
| 462 #include <sys/time.h> /* for FD_SETSIZE */ |
| 463 #define _PR_MD_MAX_OSFD FD_SETSIZE |
| 464 |
| 465 struct _MDCPU_Unix { |
| 466 PRCList ioQ; |
| 467 PRUint32 ioq_timeout; |
| 468 PRInt32 ioq_max_osfd; |
| 469 PRInt32 ioq_osfd_cnt; |
| 470 #ifndef _PR_USE_POLL |
| 471 fd_set fd_read_set, fd_write_set, fd_exception_set; |
| 472 PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], |
| 473 fd_exception_cnt[_PR_MD_MAX_OSFD]; |
| 474 #else |
| 475 struct pollfd *ioq_pollfds; |
| 476 int ioq_pollfds_size; |
| 477 #endif /* _PR_USE_POLL */ |
| 478 }; |
| 479 |
| 480 #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) |
| 481 #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) |
| 482 #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) |
| 483 #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) |
| 484 #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) |
| 485 #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) |
| 486 #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) |
| 487 #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) |
| 488 #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) |
| 489 #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) |
| 490 #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) |
| 491 #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) |
| 492 #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) |
| 493 |
| 494 #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 |
| 495 |
| 496 struct _MDCPU { |
| 497 struct _MDCPU_Unix md_unix; |
| 498 }; |
| 499 |
| 500 #define _MD_INIT_LOCKS() |
| 501 #define _MD_NEW_LOCK(lock) PR_SUCCESS |
| 502 #define _MD_FREE_LOCK(lock) |
| 503 #define _MD_LOCK(lock) |
| 504 #define _MD_UNLOCK(lock) |
| 505 #define _MD_INIT_IO() |
| 506 #define _MD_IOQ_LOCK() |
| 507 #define _MD_IOQ_UNLOCK() |
| 508 |
| 509 extern PRStatus _MD_InitializeThread(PRThread *thread); |
| 510 |
| 511 #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) |
| 512 #define _MD_INIT_THREAD _MD_InitializeThread |
| 513 #define _MD_EXIT_THREAD(thread) |
| 514 #define _MD_SUSPEND_THREAD(thread) _MD_suspend_thread |
| 515 #define _MD_RESUME_THREAD(thread) _MD_resume_thread |
| 516 #define _MD_CLEAN_THREAD(_thread) |
| 517 |
| 518 extern PRStatus _MD_CREATE_THREAD( |
| 519 PRThread *thread, |
| 520 void (*start) (void *), |
| 521 PRThreadPriority priority, |
| 522 PRThreadScope scope, |
| 523 PRThreadState state, |
| 524 PRUint32 stackSize); |
| 525 extern void _MD_SET_PRIORITY(struct _MDThread *thread, PRUintn newPri); |
| 526 extern PRStatus _MD_WAIT(PRThread *, PRIntervalTime timeout); |
| 527 extern PRStatus _MD_WAKEUP_WAITER(PRThread *); |
| 528 extern void _MD_YIELD(void); |
| 529 |
| 530 #endif /* ! _PR_PTHREADS */ |
| 531 |
| 532 extern void _MD_EarlyInit(void); |
| 533 extern PRIntervalTime _PR_UNIX_GetInterval(void); |
| 534 extern PRIntervalTime _PR_UNIX_TicksPerSecond(void); |
| 535 |
| 536 #define _MD_EARLY_INIT _MD_EarlyInit |
| 537 #define _MD_FINAL_INIT _PR_UnixInit |
| 538 #define _MD_GET_INTERVAL _PR_UNIX_GetInterval |
| 539 #define _MD_INTERVAL_PER_SEC _PR_UNIX_TicksPerSecond |
| 540 |
| 541 /* |
| 542 * We wrapped the select() call. _MD_SELECT refers to the built-in, |
| 543 * unwrapped version. |
| 544 */ |
| 545 #define _MD_SELECT __select |
| 546 |
| 547 #ifdef _PR_POLL_AVAILABLE |
| 548 #include <sys/poll.h> |
| 549 extern int __syscall_poll(struct pollfd *ufds, unsigned long int nfds, |
| 550 int timeout); |
| 551 #define _MD_POLL __syscall_poll |
| 552 #endif |
| 553 |
| 554 /* For writev() */ |
| 555 #include <sys/uio.h> |
| 556 |
| 557 extern void _MD_linux_map_sendfile_error(int err); |
| 558 |
| 559 #endif /* nspr_linux_defs_h___ */ |
OLD | NEW |