Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nspr_solaris_defs_h___ |
michael@0 | 7 | #define nspr_solaris_defs_h___ |
michael@0 | 8 | |
michael@0 | 9 | /* |
michael@0 | 10 | * Internal configuration macros |
michael@0 | 11 | */ |
michael@0 | 12 | |
michael@0 | 13 | #define PR_LINKER_ARCH "solaris" |
michael@0 | 14 | #define _PR_SI_SYSNAME "SOLARIS" |
michael@0 | 15 | #ifdef sparc |
michael@0 | 16 | #define _PR_SI_ARCHITECTURE "sparc" |
michael@0 | 17 | #elif defined(__x86_64) |
michael@0 | 18 | #define _PR_SI_ARCHITECTURE "x86-64" |
michael@0 | 19 | #elif defined(i386) |
michael@0 | 20 | #define _PR_SI_ARCHITECTURE "x86" |
michael@0 | 21 | #else |
michael@0 | 22 | #error unknown processor |
michael@0 | 23 | #endif |
michael@0 | 24 | #define PR_DLL_SUFFIX ".so" |
michael@0 | 25 | |
michael@0 | 26 | #define _PR_VMBASE 0x30000000 |
michael@0 | 27 | #define _PR_STACK_VMBASE 0x50000000 |
michael@0 | 28 | #define _MD_DEFAULT_STACK_SIZE (2*65536L) |
michael@0 | 29 | #define _MD_MMAP_FLAGS MAP_SHARED |
michael@0 | 30 | |
michael@0 | 31 | #undef HAVE_STACK_GROWING_UP |
michael@0 | 32 | |
michael@0 | 33 | #ifndef HAVE_WEAK_IO_SYMBOLS |
michael@0 | 34 | #define HAVE_WEAK_IO_SYMBOLS |
michael@0 | 35 | #endif |
michael@0 | 36 | |
michael@0 | 37 | #undef HAVE_WEAK_MALLOC_SYMBOLS |
michael@0 | 38 | #define HAVE_DLL |
michael@0 | 39 | #define USE_DLFCN |
michael@0 | 40 | #define NEED_STRFTIME_LOCK |
michael@0 | 41 | |
michael@0 | 42 | /* |
michael@0 | 43 | * Intel x86 has atomic instructions. |
michael@0 | 44 | * |
michael@0 | 45 | * Sparc v8 does not have instructions to efficiently implement |
michael@0 | 46 | * atomic increment/decrement operations. We use the default |
michael@0 | 47 | * atomic routine implementation in pratom.c. |
michael@0 | 48 | * |
michael@0 | 49 | * 64-bit Solaris requires sparc v9, which has atomic instructions. |
michael@0 | 50 | */ |
michael@0 | 51 | #if defined(i386) || defined(IS_64) |
michael@0 | 52 | #define _PR_HAVE_ATOMIC_OPS |
michael@0 | 53 | #endif |
michael@0 | 54 | |
michael@0 | 55 | #define _PR_POLL_AVAILABLE |
michael@0 | 56 | #define _PR_USE_POLL |
michael@0 | 57 | #define _PR_STAT_HAS_ST_ATIM |
michael@0 | 58 | #ifdef SOLARIS2_5 |
michael@0 | 59 | #define _PR_HAVE_SYSV_SEMAPHORES |
michael@0 | 60 | #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY |
michael@0 | 61 | #else |
michael@0 | 62 | #define _PR_HAVE_POSIX_SEMAPHORES |
michael@0 | 63 | #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY |
michael@0 | 64 | #endif |
michael@0 | 65 | #define _PR_HAVE_GETIPNODEBYNAME |
michael@0 | 66 | #define _PR_HAVE_GETIPNODEBYADDR |
michael@0 | 67 | #define _PR_HAVE_GETADDRINFO |
michael@0 | 68 | #define _PR_INET6_PROBE |
michael@0 | 69 | #define _PR_ACCEPT_INHERIT_NONBLOCK |
michael@0 | 70 | #ifdef _PR_INET6 |
michael@0 | 71 | #define _PR_HAVE_INET_NTOP |
michael@0 | 72 | #else |
michael@0 | 73 | #define AF_INET6 26 |
michael@0 | 74 | struct addrinfo { |
michael@0 | 75 | int ai_flags; |
michael@0 | 76 | int ai_family; |
michael@0 | 77 | int ai_socktype; |
michael@0 | 78 | int ai_protocol; |
michael@0 | 79 | size_t ai_addrlen; |
michael@0 | 80 | char *ai_canonname; |
michael@0 | 81 | struct sockaddr *ai_addr; |
michael@0 | 82 | struct addrinfo *ai_next; |
michael@0 | 83 | }; |
michael@0 | 84 | #define AI_CANONNAME 0x0010 |
michael@0 | 85 | #define AI_V4MAPPED 0x0001 |
michael@0 | 86 | #define AI_ALL 0x0002 |
michael@0 | 87 | #define AI_ADDRCONFIG 0x0004 |
michael@0 | 88 | #define _PR_HAVE_MD_SOCKADDR_IN6 |
michael@0 | 89 | /* isomorphic to struct in6_addr on Solaris 8 */ |
michael@0 | 90 | struct _md_in6_addr { |
michael@0 | 91 | union { |
michael@0 | 92 | PRUint8 _S6_u8[16]; |
michael@0 | 93 | PRUint32 _S6_u32[4]; |
michael@0 | 94 | PRUint32 __S6_align; |
michael@0 | 95 | } _S6_un; |
michael@0 | 96 | }; |
michael@0 | 97 | /* isomorphic to struct sockaddr_in6 on Solaris 8 */ |
michael@0 | 98 | struct _md_sockaddr_in6 { |
michael@0 | 99 | PRUint16 sin6_family; |
michael@0 | 100 | PRUint16 sin6_port; |
michael@0 | 101 | PRUint32 sin6_flowinfo; |
michael@0 | 102 | struct _md_in6_addr sin6_addr; |
michael@0 | 103 | PRUint32 sin6_scope_id; |
michael@0 | 104 | PRUint32 __sin6_src_id; |
michael@0 | 105 | }; |
michael@0 | 106 | #endif |
michael@0 | 107 | #if defined(_PR_PTHREADS) |
michael@0 | 108 | #define _PR_HAVE_GETHOST_R |
michael@0 | 109 | #define _PR_HAVE_GETHOST_R_POINTER |
michael@0 | 110 | #endif |
michael@0 | 111 | |
michael@0 | 112 | #include "prinrval.h" |
michael@0 | 113 | #define _MD_INTERVAL_INIT() |
michael@0 | 114 | NSPR_API(PRIntervalTime) _MD_Solaris_GetInterval(void); |
michael@0 | 115 | #define _MD_GET_INTERVAL _MD_Solaris_GetInterval |
michael@0 | 116 | NSPR_API(PRIntervalTime) _MD_Solaris_TicksPerSecond(void); |
michael@0 | 117 | #define _MD_INTERVAL_PER_SEC _MD_Solaris_TicksPerSecond |
michael@0 | 118 | |
michael@0 | 119 | #if defined(_PR_HAVE_ATOMIC_OPS) |
michael@0 | 120 | /* |
michael@0 | 121 | ** Atomic Operations |
michael@0 | 122 | */ |
michael@0 | 123 | #define _MD_INIT_ATOMIC() |
michael@0 | 124 | |
michael@0 | 125 | NSPR_API(PRInt32) _MD_AtomicIncrement(PRInt32 *val); |
michael@0 | 126 | #define _MD_ATOMIC_INCREMENT _MD_AtomicIncrement |
michael@0 | 127 | |
michael@0 | 128 | NSPR_API(PRInt32) _MD_AtomicAdd(PRInt32 *ptr, PRInt32 val); |
michael@0 | 129 | #define _MD_ATOMIC_ADD _MD_AtomicAdd |
michael@0 | 130 | |
michael@0 | 131 | NSPR_API(PRInt32) _MD_AtomicDecrement(PRInt32 *val); |
michael@0 | 132 | #define _MD_ATOMIC_DECREMENT _MD_AtomicDecrement |
michael@0 | 133 | |
michael@0 | 134 | NSPR_API(PRInt32) _MD_AtomicSet(PRInt32 *val, PRInt32 newval); |
michael@0 | 135 | #define _MD_ATOMIC_SET _MD_AtomicSet |
michael@0 | 136 | #endif /* _PR_HAVE_ATOMIC_OPS */ |
michael@0 | 137 | |
michael@0 | 138 | #if defined(_PR_PTHREADS) |
michael@0 | 139 | |
michael@0 | 140 | NSPR_API(void) _MD_EarlyInit(void); |
michael@0 | 141 | |
michael@0 | 142 | #define _MD_EARLY_INIT _MD_EarlyInit |
michael@0 | 143 | #define _MD_FINAL_INIT _PR_UnixInit |
michael@0 | 144 | |
michael@0 | 145 | #else /* _PR_PTHREADS */ |
michael@0 | 146 | |
michael@0 | 147 | /* |
michael@0 | 148 | * _PR_LOCAL_THREADS_ONLY implementation on Solaris |
michael@0 | 149 | */ |
michael@0 | 150 | |
michael@0 | 151 | #include "prthread.h" |
michael@0 | 152 | |
michael@0 | 153 | #include <errno.h> |
michael@0 | 154 | #include <ucontext.h> |
michael@0 | 155 | #include <sys/stack.h> |
michael@0 | 156 | #include <synch.h> |
michael@0 | 157 | |
michael@0 | 158 | /* |
michael@0 | 159 | ** Initialization Related definitions |
michael@0 | 160 | */ |
michael@0 | 161 | |
michael@0 | 162 | NSPR_API(void) _MD_EarlyInit(void); |
michael@0 | 163 | NSPR_API(void) _MD_SolarisInit(); |
michael@0 | 164 | #define _MD_EARLY_INIT _MD_EarlyInit |
michael@0 | 165 | #define _MD_FINAL_INIT _MD_SolarisInit |
michael@0 | 166 | #define _MD_INIT_THREAD _MD_InitializeThread |
michael@0 | 167 | |
michael@0 | 168 | #ifdef USE_SETJMP |
michael@0 | 169 | |
michael@0 | 170 | #include <setjmp.h> |
michael@0 | 171 | |
michael@0 | 172 | #define _PR_CONTEXT_TYPE jmp_buf |
michael@0 | 173 | |
michael@0 | 174 | #ifdef sparc |
michael@0 | 175 | #define _MD_GET_SP(_t) (_t)->md.context[2] |
michael@0 | 176 | #else |
michael@0 | 177 | #define _MD_GET_SP(_t) (_t)->md.context[4] |
michael@0 | 178 | #endif |
michael@0 | 179 | |
michael@0 | 180 | #define PR_NUM_GCREGS _JBLEN |
michael@0 | 181 | #define CONTEXT(_thread) (_thread)->md.context |
michael@0 | 182 | |
michael@0 | 183 | #else /* ! USE_SETJMP */ |
michael@0 | 184 | |
michael@0 | 185 | #ifdef sparc |
michael@0 | 186 | #define _PR_CONTEXT_TYPE ucontext_t |
michael@0 | 187 | #define _MD_GET_SP(_t) (_t)->md.context.uc_mcontext.gregs[REG_SP] |
michael@0 | 188 | /* |
michael@0 | 189 | ** Sparc's use register windows. the _MD_GetRegisters for the sparc's |
michael@0 | 190 | ** doesn't actually store anything into the argument buffer; instead the |
michael@0 | 191 | ** register windows are homed to the stack. I assume that the stack |
michael@0 | 192 | ** always has room for the registers to spill to... |
michael@0 | 193 | */ |
michael@0 | 194 | #define PR_NUM_GCREGS 0 |
michael@0 | 195 | #else |
michael@0 | 196 | #define _PR_CONTEXT_TYPE unsigned int edi; sigset_t oldMask, blockMask; ucontext_t |
michael@0 | 197 | #define _MD_GET_SP(_t) (_t)->md.context.uc_mcontext.gregs[USP] |
michael@0 | 198 | #define PR_NUM_GCREGS _JBLEN |
michael@0 | 199 | #endif |
michael@0 | 200 | |
michael@0 | 201 | #define CONTEXT(_thread) (&(_thread)->md.context) |
michael@0 | 202 | |
michael@0 | 203 | #endif /* ! USE_SETJMP */ |
michael@0 | 204 | |
michael@0 | 205 | #include <time.h> |
michael@0 | 206 | /* |
michael@0 | 207 | * Because clock_gettime() on Solaris/x86 always generates a |
michael@0 | 208 | * segmentation fault, we use an emulated version _pr_solx86_clock_gettime(), |
michael@0 | 209 | * which is implemented using gettimeofday(). |
michael@0 | 210 | */ |
michael@0 | 211 | #ifdef i386 |
michael@0 | 212 | #define GETTIME(tt) _pr_solx86_clock_gettime(CLOCK_REALTIME, (tt)) |
michael@0 | 213 | #else |
michael@0 | 214 | #define GETTIME(tt) clock_gettime(CLOCK_REALTIME, (tt)) |
michael@0 | 215 | #endif /* i386 */ |
michael@0 | 216 | |
michael@0 | 217 | #define _MD_SAVE_ERRNO(_thread) (_thread)->md.errcode = errno; |
michael@0 | 218 | #define _MD_RESTORE_ERRNO(_thread) errno = (_thread)->md.errcode; |
michael@0 | 219 | |
michael@0 | 220 | #ifdef sparc |
michael@0 | 221 | |
michael@0 | 222 | #ifdef USE_SETJMP |
michael@0 | 223 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
michael@0 | 224 | PR_BEGIN_MACRO \ |
michael@0 | 225 | int *context = (_thread)->md.context; \ |
michael@0 | 226 | *status = PR_TRUE; \ |
michael@0 | 227 | (void) setjmp(context); \ |
michael@0 | 228 | (_thread)->md.context[1] = (int) ((_sp) - 64); \ |
michael@0 | 229 | (_thread)->md.context[2] = (int) _main; \ |
michael@0 | 230 | (_thread)->md.context[3] = (int) _main + 4; \ |
michael@0 | 231 | _thread->no_sched = 0; \ |
michael@0 | 232 | PR_END_MACRO |
michael@0 | 233 | |
michael@0 | 234 | #define _MD_SWITCH_CONTEXT(_thread) \ |
michael@0 | 235 | if (!setjmp(CONTEXT(_thread))) { \ |
michael@0 | 236 | _MD_SAVE_ERRNO(_thread) \ |
michael@0 | 237 | _MD_SET_LAST_THREAD(_thread); \ |
michael@0 | 238 | _MD_SET_CURRENT_THREAD(_thread); \ |
michael@0 | 239 | _PR_Schedule(); \ |
michael@0 | 240 | } |
michael@0 | 241 | |
michael@0 | 242 | #define _MD_RESTORE_CONTEXT(_newThread) \ |
michael@0 | 243 | { \ |
michael@0 | 244 | _MD_RESTORE_ERRNO(_newThread) \ |
michael@0 | 245 | _MD_SET_CURRENT_THREAD(_newThread); \ |
michael@0 | 246 | longjmp(CONTEXT(_newThread), 1); \ |
michael@0 | 247 | } |
michael@0 | 248 | |
michael@0 | 249 | #else |
michael@0 | 250 | /* |
michael@0 | 251 | ** Initialize the thread context preparing it to execute _main. |
michael@0 | 252 | */ |
michael@0 | 253 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
michael@0 | 254 | PR_BEGIN_MACRO \ |
michael@0 | 255 | ucontext_t *uc = CONTEXT(_thread); \ |
michael@0 | 256 | *status = PR_TRUE; \ |
michael@0 | 257 | getcontext(uc); \ |
michael@0 | 258 | uc->uc_stack.ss_sp = (char *) ((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) & 0xfffffff8); \ |
michael@0 | 259 | uc->uc_stack.ss_size = _thread->stack->stackSize; \ |
michael@0 | 260 | uc->uc_stack.ss_flags = 0; /* ? */ \ |
michael@0 | 261 | uc->uc_mcontext.gregs[REG_SP] = (unsigned int) uc->uc_stack.ss_sp; \ |
michael@0 | 262 | uc->uc_mcontext.gregs[REG_PC] = (unsigned int) _main; \ |
michael@0 | 263 | uc->uc_mcontext.gregs[REG_nPC] = (unsigned int) ((char*)_main)+4; \ |
michael@0 | 264 | uc->uc_flags = UC_ALL; \ |
michael@0 | 265 | _thread->no_sched = 0; \ |
michael@0 | 266 | PR_END_MACRO |
michael@0 | 267 | |
michael@0 | 268 | /* |
michael@0 | 269 | ** Switch away from the current thread context by saving its state and |
michael@0 | 270 | ** calling the thread scheduler. Reload cpu when we come back from the |
michael@0 | 271 | ** context switch because it might have changed. |
michael@0 | 272 | */ |
michael@0 | 273 | #define _MD_SWITCH_CONTEXT(_thread) \ |
michael@0 | 274 | PR_BEGIN_MACRO \ |
michael@0 | 275 | if (!getcontext(CONTEXT(_thread))) { \ |
michael@0 | 276 | _MD_SAVE_ERRNO(_thread); \ |
michael@0 | 277 | _MD_SET_LAST_THREAD(_thread); \ |
michael@0 | 278 | _PR_Schedule(); \ |
michael@0 | 279 | } \ |
michael@0 | 280 | PR_END_MACRO |
michael@0 | 281 | |
michael@0 | 282 | /* |
michael@0 | 283 | ** Restore a thread context that was saved by _MD_SWITCH_CONTEXT or |
michael@0 | 284 | ** initialized by _MD_INIT_CONTEXT. |
michael@0 | 285 | */ |
michael@0 | 286 | #define _MD_RESTORE_CONTEXT(_newThread) \ |
michael@0 | 287 | PR_BEGIN_MACRO \ |
michael@0 | 288 | ucontext_t *uc = CONTEXT(_newThread); \ |
michael@0 | 289 | uc->uc_mcontext.gregs[11] = 1; \ |
michael@0 | 290 | _MD_RESTORE_ERRNO(_newThread); \ |
michael@0 | 291 | _MD_SET_CURRENT_THREAD(_newThread); \ |
michael@0 | 292 | setcontext(uc); \ |
michael@0 | 293 | PR_END_MACRO |
michael@0 | 294 | #endif |
michael@0 | 295 | |
michael@0 | 296 | #else /* x86 solaris */ |
michael@0 | 297 | |
michael@0 | 298 | #ifdef USE_SETJMP |
michael@0 | 299 | |
michael@0 | 300 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
michael@0 | 301 | PR_BEGIN_MACRO \ |
michael@0 | 302 | *status = PR_TRUE; \ |
michael@0 | 303 | if (setjmp(CONTEXT(_thread))) _main(); \ |
michael@0 | 304 | _MD_GET_SP(_thread) = (int) ((_sp) - 64); \ |
michael@0 | 305 | PR_END_MACRO |
michael@0 | 306 | |
michael@0 | 307 | #define _MD_SWITCH_CONTEXT(_thread) \ |
michael@0 | 308 | if (!setjmp(CONTEXT(_thread))) { \ |
michael@0 | 309 | _MD_SAVE_ERRNO(_thread) \ |
michael@0 | 310 | _PR_Schedule(); \ |
michael@0 | 311 | } |
michael@0 | 312 | |
michael@0 | 313 | #define _MD_RESTORE_CONTEXT(_newThread) \ |
michael@0 | 314 | { \ |
michael@0 | 315 | _MD_RESTORE_ERRNO(_newThread) \ |
michael@0 | 316 | _MD_SET_CURRENT_THREAD(_newThread); \ |
michael@0 | 317 | longjmp(CONTEXT(_newThread), 1); \ |
michael@0 | 318 | } |
michael@0 | 319 | |
michael@0 | 320 | #else /* USE_SETJMP */ |
michael@0 | 321 | |
michael@0 | 322 | #define WINDOWSIZE 0 |
michael@0 | 323 | |
michael@0 | 324 | int getedi(void); |
michael@0 | 325 | void setedi(int); |
michael@0 | 326 | |
michael@0 | 327 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
michael@0 | 328 | PR_BEGIN_MACRO \ |
michael@0 | 329 | ucontext_t *uc = CONTEXT(_thread); \ |
michael@0 | 330 | *status = PR_TRUE; \ |
michael@0 | 331 | getcontext(uc); \ |
michael@0 | 332 | /* Force sp to be double aligned! */ \ |
michael@0 | 333 | uc->uc_mcontext.gregs[USP] = (int) ((unsigned long)(_sp - WINDOWSIZE - SA(MINFRAME)) & 0xfffffff8); \ |
michael@0 | 334 | uc->uc_mcontext.gregs[PC] = (int) _main; \ |
michael@0 | 335 | (_thread)->no_sched = 0; \ |
michael@0 | 336 | PR_END_MACRO |
michael@0 | 337 | |
michael@0 | 338 | /* getcontext() may return 1, contrary to what the man page says */ |
michael@0 | 339 | #define _MD_SWITCH_CONTEXT(_thread) \ |
michael@0 | 340 | PR_BEGIN_MACRO \ |
michael@0 | 341 | ucontext_t *uc = CONTEXT(_thread); \ |
michael@0 | 342 | PR_ASSERT(_thread->no_sched); \ |
michael@0 | 343 | sigfillset(&((_thread)->md.blockMask)); \ |
michael@0 | 344 | sigprocmask(SIG_BLOCK, &((_thread)->md.blockMask), \ |
michael@0 | 345 | &((_thread)->md.oldMask)); \ |
michael@0 | 346 | (_thread)->md.edi = getedi(); \ |
michael@0 | 347 | if (! getcontext(uc)) { \ |
michael@0 | 348 | sigprocmask(SIG_SETMASK, &((_thread)->md.oldMask), NULL); \ |
michael@0 | 349 | uc->uc_mcontext.gregs[EDI] = (_thread)->md.edi; \ |
michael@0 | 350 | _MD_SAVE_ERRNO(_thread) \ |
michael@0 | 351 | _MD_SET_LAST_THREAD(_thread); \ |
michael@0 | 352 | _PR_Schedule(); \ |
michael@0 | 353 | } else { \ |
michael@0 | 354 | sigprocmask(SIG_SETMASK, &((_thread)->md.oldMask), NULL); \ |
michael@0 | 355 | setedi((_thread)->md.edi); \ |
michael@0 | 356 | PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \ |
michael@0 | 357 | _MD_LAST_THREAD()->no_sched = 0; \ |
michael@0 | 358 | } \ |
michael@0 | 359 | PR_END_MACRO |
michael@0 | 360 | |
michael@0 | 361 | /* |
michael@0 | 362 | ** Restore a thread context, saved by _PR_SWITCH_CONTEXT |
michael@0 | 363 | */ |
michael@0 | 364 | #define _MD_RESTORE_CONTEXT(_newthread) \ |
michael@0 | 365 | PR_BEGIN_MACRO \ |
michael@0 | 366 | ucontext_t *uc = CONTEXT(_newthread); \ |
michael@0 | 367 | uc->uc_mcontext.gregs[EAX] = 1; \ |
michael@0 | 368 | _MD_RESTORE_ERRNO(_newthread) \ |
michael@0 | 369 | _MD_SET_CURRENT_THREAD(_newthread); \ |
michael@0 | 370 | (_newthread)->no_sched = 1; \ |
michael@0 | 371 | setcontext(uc); \ |
michael@0 | 372 | PR_END_MACRO |
michael@0 | 373 | #endif /* USE_SETJMP */ |
michael@0 | 374 | |
michael@0 | 375 | #endif /* sparc */ |
michael@0 | 376 | |
michael@0 | 377 | struct _MDLock { |
michael@0 | 378 | PRInt8 notused; |
michael@0 | 379 | }; |
michael@0 | 380 | |
michael@0 | 381 | struct _MDCVar { |
michael@0 | 382 | PRInt8 notused; |
michael@0 | 383 | }; |
michael@0 | 384 | |
michael@0 | 385 | struct _MDSemaphore { |
michael@0 | 386 | PRInt8 notused; |
michael@0 | 387 | }; |
michael@0 | 388 | |
michael@0 | 389 | struct _MDThread { |
michael@0 | 390 | _PR_CONTEXT_TYPE context; |
michael@0 | 391 | int errcode; |
michael@0 | 392 | int id; |
michael@0 | 393 | }; |
michael@0 | 394 | |
michael@0 | 395 | struct _MDThreadStack { |
michael@0 | 396 | PRInt8 notused; |
michael@0 | 397 | }; |
michael@0 | 398 | |
michael@0 | 399 | struct _MDSegment { |
michael@0 | 400 | PRInt8 notused; |
michael@0 | 401 | }; |
michael@0 | 402 | |
michael@0 | 403 | /* |
michael@0 | 404 | * md-specific cpu structure field |
michael@0 | 405 | */ |
michael@0 | 406 | #define _PR_MD_MAX_OSFD FD_SETSIZE |
michael@0 | 407 | |
michael@0 | 408 | struct _MDCPU_Unix { |
michael@0 | 409 | PRCList ioQ; |
michael@0 | 410 | PRUint32 ioq_timeout; |
michael@0 | 411 | PRInt32 ioq_max_osfd; |
michael@0 | 412 | PRInt32 ioq_osfd_cnt; |
michael@0 | 413 | #ifndef _PR_USE_POLL |
michael@0 | 414 | fd_set fd_read_set, fd_write_set, fd_exception_set; |
michael@0 | 415 | PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], |
michael@0 | 416 | fd_exception_cnt[_PR_MD_MAX_OSFD]; |
michael@0 | 417 | #else |
michael@0 | 418 | struct pollfd *ioq_pollfds; |
michael@0 | 419 | int ioq_pollfds_size; |
michael@0 | 420 | #endif /* _PR_USE_POLL */ |
michael@0 | 421 | }; |
michael@0 | 422 | |
michael@0 | 423 | #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) |
michael@0 | 424 | #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) |
michael@0 | 425 | #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) |
michael@0 | 426 | #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) |
michael@0 | 427 | #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) |
michael@0 | 428 | #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) |
michael@0 | 429 | #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) |
michael@0 | 430 | #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) |
michael@0 | 431 | #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) |
michael@0 | 432 | #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) |
michael@0 | 433 | #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) |
michael@0 | 434 | #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) |
michael@0 | 435 | #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) |
michael@0 | 436 | |
michael@0 | 437 | #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 |
michael@0 | 438 | |
michael@0 | 439 | struct _MDCPU { |
michael@0 | 440 | struct _MDCPU_Unix md_unix; |
michael@0 | 441 | }; |
michael@0 | 442 | |
michael@0 | 443 | #define _MD_INIT_LOCKS() |
michael@0 | 444 | #define _MD_NEW_LOCK(lock) PR_SUCCESS |
michael@0 | 445 | #define _MD_FREE_LOCK(lock) |
michael@0 | 446 | #define _MD_LOCK(lock) |
michael@0 | 447 | #define _MD_UNLOCK(lock) |
michael@0 | 448 | #define _MD_INIT_IO() |
michael@0 | 449 | #define _MD_IOQ_LOCK() |
michael@0 | 450 | #define _MD_IOQ_UNLOCK() |
michael@0 | 451 | |
michael@0 | 452 | #define _MD_INIT_RUNNING_CPU(cpu) _MD_unix_init_running_cpu(cpu) |
michael@0 | 453 | #define _MD_INIT_THREAD _MD_InitializeThread |
michael@0 | 454 | #define _MD_EXIT_THREAD(thread) |
michael@0 | 455 | #define _MD_SUSPEND_THREAD(thread) |
michael@0 | 456 | #define _MD_RESUME_THREAD(thread) |
michael@0 | 457 | #define _MD_CLEAN_THREAD(_thread) |
michael@0 | 458 | |
michael@0 | 459 | extern PRStatus _MD_WAIT(struct PRThread *, PRIntervalTime timeout); |
michael@0 | 460 | extern PRStatus _MD_WAKEUP_WAITER(struct PRThread *); |
michael@0 | 461 | extern void _MD_YIELD(void); |
michael@0 | 462 | extern PRStatus _MD_InitializeThread(PRThread *thread); |
michael@0 | 463 | extern void _MD_SET_PRIORITY(struct _MDThread *thread, |
michael@0 | 464 | PRThreadPriority newPri); |
michael@0 | 465 | extern PRStatus _MD_CREATE_THREAD(PRThread *thread, void (*start) (void *), |
michael@0 | 466 | PRThreadPriority priority, PRThreadScope scope, PRThreadState state, |
michael@0 | 467 | PRUint32 stackSize); |
michael@0 | 468 | |
michael@0 | 469 | /* The following defines the unwrapped versions of select() and poll(). */ |
michael@0 | 470 | extern int _select(int nfds, fd_set *readfds, fd_set *writefds, |
michael@0 | 471 | fd_set *exceptfds, struct timeval *timeout); |
michael@0 | 472 | #define _MD_SELECT _select |
michael@0 | 473 | |
michael@0 | 474 | #include <stropts.h> |
michael@0 | 475 | #include <poll.h> |
michael@0 | 476 | #define _MD_POLL _poll |
michael@0 | 477 | extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout); |
michael@0 | 478 | |
michael@0 | 479 | PR_BEGIN_EXTERN_C |
michael@0 | 480 | |
michael@0 | 481 | /* |
michael@0 | 482 | ** Missing function prototypes |
michael@0 | 483 | */ |
michael@0 | 484 | extern int gethostname (char *name, int namelen); |
michael@0 | 485 | |
michael@0 | 486 | PR_END_EXTERN_C |
michael@0 | 487 | |
michael@0 | 488 | #endif /* _PR_PTHREADS */ |
michael@0 | 489 | |
michael@0 | 490 | extern void _MD_solaris_map_sendfile_error(int err); |
michael@0 | 491 | |
michael@0 | 492 | #endif /* nspr_solaris_defs_h___ */ |
michael@0 | 493 |