Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
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_irix_defs_h___ |
michael@0 | 7 | #define nspr_irix_defs_h___ |
michael@0 | 8 | |
michael@0 | 9 | #define _PR_HAVE_ATOMIC_CAS |
michael@0 | 10 | |
michael@0 | 11 | /* |
michael@0 | 12 | * MipsPro assembler defines _LANGUAGE_ASSEMBLY |
michael@0 | 13 | */ |
michael@0 | 14 | #ifndef _LANGUAGE_ASSEMBLY |
michael@0 | 15 | |
michael@0 | 16 | #include "prclist.h" |
michael@0 | 17 | #include "prthread.h" |
michael@0 | 18 | #include <sys/ucontext.h> |
michael@0 | 19 | |
michael@0 | 20 | /* |
michael@0 | 21 | * Internal configuration macros |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | #define PR_LINKER_ARCH "irix" |
michael@0 | 25 | #define _PR_SI_SYSNAME "IRIX" |
michael@0 | 26 | #define _PR_SI_ARCHITECTURE "mips" |
michael@0 | 27 | #define PR_DLL_SUFFIX ".so" |
michael@0 | 28 | |
michael@0 | 29 | #define _PR_VMBASE 0x30000000 |
michael@0 | 30 | #define _PR_STACK_VMBASE 0x50000000 |
michael@0 | 31 | #define _PR_NUM_GCREGS 9 |
michael@0 | 32 | #define _MD_MMAP_FLAGS MAP_PRIVATE |
michael@0 | 33 | |
michael@0 | 34 | #define _MD_DEFAULT_STACK_SIZE 65536L |
michael@0 | 35 | #define _MD_MIN_STACK_SIZE 16384L |
michael@0 | 36 | |
michael@0 | 37 | #undef HAVE_STACK_GROWING_UP |
michael@0 | 38 | #define HAVE_WEAK_IO_SYMBOLS |
michael@0 | 39 | #define HAVE_WEAK_MALLOC_SYMBOLS |
michael@0 | 40 | #define HAVE_DLL |
michael@0 | 41 | #define USE_DLFCN |
michael@0 | 42 | #define _PR_HAVE_ATOMIC_OPS |
michael@0 | 43 | #define _PR_POLL_AVAILABLE |
michael@0 | 44 | #define _PR_USE_POLL |
michael@0 | 45 | #define _PR_STAT_HAS_ST_ATIM |
michael@0 | 46 | #define _PR_HAVE_OFF64_T |
michael@0 | 47 | #define HAVE_POINTER_LOCALTIME_R |
michael@0 | 48 | #define _PR_HAVE_POSIX_SEMAPHORES |
michael@0 | 49 | #define PR_HAVE_POSIX_NAMED_SHARED_MEMORY |
michael@0 | 50 | #define _PR_ACCEPT_INHERIT_NONBLOCK |
michael@0 | 51 | |
michael@0 | 52 | #ifdef _PR_INET6 |
michael@0 | 53 | #define _PR_HAVE_INET_NTOP |
michael@0 | 54 | #define _PR_HAVE_GETIPNODEBYNAME |
michael@0 | 55 | #define _PR_HAVE_GETIPNODEBYADDR |
michael@0 | 56 | #define _PR_HAVE_GETADDRINFO |
michael@0 | 57 | #endif |
michael@0 | 58 | |
michael@0 | 59 | /* Initialization entry points */ |
michael@0 | 60 | NSPR_API(void) _MD_EarlyInit(void); |
michael@0 | 61 | #define _MD_EARLY_INIT _MD_EarlyInit |
michael@0 | 62 | |
michael@0 | 63 | NSPR_API(void) _MD_IrixInit(void); |
michael@0 | 64 | #define _MD_FINAL_INIT _MD_IrixInit |
michael@0 | 65 | |
michael@0 | 66 | #define _MD_INIT_IO() |
michael@0 | 67 | |
michael@0 | 68 | /* Timer operations */ |
michael@0 | 69 | NSPR_API(PRIntervalTime) _MD_IrixGetInterval(void); |
michael@0 | 70 | #define _MD_GET_INTERVAL _MD_IrixGetInterval |
michael@0 | 71 | |
michael@0 | 72 | NSPR_API(PRIntervalTime) _MD_IrixIntervalPerSec(void); |
michael@0 | 73 | #define _MD_INTERVAL_PER_SEC _MD_IrixIntervalPerSec |
michael@0 | 74 | |
michael@0 | 75 | /* GC operations */ |
michael@0 | 76 | NSPR_API(void *) _MD_GetSP(PRThread *thread); |
michael@0 | 77 | #define _MD_GET_SP _MD_GetSP |
michael@0 | 78 | |
michael@0 | 79 | /* The atomic operations */ |
michael@0 | 80 | #include <mutex.h> |
michael@0 | 81 | #define _MD_INIT_ATOMIC() |
michael@0 | 82 | #define _MD_ATOMIC_INCREMENT(val) add_then_test((unsigned long*)val, 1) |
michael@0 | 83 | #define _MD_ATOMIC_ADD(ptr, val) add_then_test((unsigned long*)ptr, (unsigned long)val) |
michael@0 | 84 | #define _MD_ATOMIC_DECREMENT(val) add_then_test((unsigned long*)val, 0xffffffff) |
michael@0 | 85 | #define _MD_ATOMIC_SET(val, newval) test_and_set((unsigned long*)val, newval) |
michael@0 | 86 | |
michael@0 | 87 | #if defined(_PR_PTHREADS) |
michael@0 | 88 | #else /* defined(_PR_PTHREADS) */ |
michael@0 | 89 | |
michael@0 | 90 | /************************************************************************/ |
michael@0 | 91 | |
michael@0 | 92 | #include <setjmp.h> |
michael@0 | 93 | #include <errno.h> |
michael@0 | 94 | #include <unistd.h> |
michael@0 | 95 | #include <bstring.h> |
michael@0 | 96 | #include <sys/time.h> |
michael@0 | 97 | #include <ulocks.h> |
michael@0 | 98 | #include <sys/prctl.h> |
michael@0 | 99 | |
michael@0 | 100 | |
michael@0 | 101 | /* |
michael@0 | 102 | * Data region private to each sproc. This region is setup by calling |
michael@0 | 103 | * mmap(...,MAP_LOCAL,...). The private data is mapped at the same |
michael@0 | 104 | * address in every sproc, but every sproc gets a private mapping. |
michael@0 | 105 | * |
michael@0 | 106 | * Just make sure that this structure fits in a page, as only one page |
michael@0 | 107 | * is allocated for the private region. |
michael@0 | 108 | */ |
michael@0 | 109 | struct sproc_private_data { |
michael@0 | 110 | struct PRThread *me; |
michael@0 | 111 | struct _PRCPU *cpu; |
michael@0 | 112 | struct PRThread *last; |
michael@0 | 113 | PRUintn intsOff; |
michael@0 | 114 | int sproc_pid; |
michael@0 | 115 | }; |
michael@0 | 116 | |
michael@0 | 117 | extern char *_nspr_sproc_private; |
michael@0 | 118 | |
michael@0 | 119 | #define _PR_PRDA() ((struct sproc_private_data *) _nspr_sproc_private) |
michael@0 | 120 | #define _MD_SET_CURRENT_THREAD(_thread) _PR_PRDA()->me = (_thread) |
michael@0 | 121 | #define _MD_THIS_THREAD() (_PR_PRDA()->me) |
michael@0 | 122 | #define _MD_LAST_THREAD() (_PR_PRDA()->last) |
michael@0 | 123 | #define _MD_SET_LAST_THREAD(_thread) _PR_PRDA()->last = (_thread) |
michael@0 | 124 | #define _MD_CURRENT_CPU() (_PR_PRDA()->cpu) |
michael@0 | 125 | #define _MD_SET_CURRENT_CPU(_cpu) _PR_PRDA()->cpu = (_cpu) |
michael@0 | 126 | #define _MD_SET_INTSOFF(_val) (_PR_PRDA()->intsOff = _val) |
michael@0 | 127 | #define _MD_GET_INTSOFF() (_PR_PRDA()->intsOff) |
michael@0 | 128 | |
michael@0 | 129 | #define _MD_SET_SPROC_PID(_val) (_PR_PRDA()->sproc_pid = _val) |
michael@0 | 130 | #define _MD_GET_SPROC_PID() (_PR_PRDA()->sproc_pid) |
michael@0 | 131 | |
michael@0 | 132 | NSPR_API(struct PRThread*) _MD_get_attached_thread(void); |
michael@0 | 133 | NSPR_API(struct PRThread*) _MD_get_current_thread(void); |
michael@0 | 134 | #define _MD_GET_ATTACHED_THREAD() _MD_get_attached_thread() |
michael@0 | 135 | #define _MD_CURRENT_THREAD() _MD_get_current_thread() |
michael@0 | 136 | |
michael@0 | 137 | #define _MD_CHECK_FOR_EXIT() { \ |
michael@0 | 138 | if (_pr_irix_exit_now) { \ |
michael@0 | 139 | _PR_POST_SEM(_pr_irix_exit_sem); \ |
michael@0 | 140 | _MD_Wakeup_CPUs(); \ |
michael@0 | 141 | _exit(0); \ |
michael@0 | 142 | } \ |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | #define _MD_ATTACH_THREAD(threadp) |
michael@0 | 146 | |
michael@0 | 147 | #define _MD_SAVE_ERRNO(_thread) (_thread)->md.errcode = errno; |
michael@0 | 148 | #define _MD_RESTORE_ERRNO(_thread) errno = (_thread)->md.errcode; |
michael@0 | 149 | |
michael@0 | 150 | extern struct _PRCPU *_pr_primordialCPU; |
michael@0 | 151 | extern usema_t *_pr_irix_exit_sem; |
michael@0 | 152 | extern PRInt32 _pr_irix_exit_now; |
michael@0 | 153 | extern int _pr_irix_primoridal_cpu_fd[]; |
michael@0 | 154 | extern PRInt32 _pr_irix_process_exit; |
michael@0 | 155 | extern PRInt32 _pr_irix_process_exit_code; |
michael@0 | 156 | |
michael@0 | 157 | /* Thread operations */ |
michael@0 | 158 | #define _PR_LOCK_HEAP() { \ |
michael@0 | 159 | PRIntn _is; \ |
michael@0 | 160 | if (_pr_primordialCPU) { \ |
michael@0 | 161 | if (_MD_GET_ATTACHED_THREAD() && \ |
michael@0 | 162 | !_PR_IS_NATIVE_THREAD( \ |
michael@0 | 163 | _MD_GET_ATTACHED_THREAD())) \ |
michael@0 | 164 | _PR_INTSOFF(_is); \ |
michael@0 | 165 | _PR_LOCK(_pr_heapLock); \ |
michael@0 | 166 | } |
michael@0 | 167 | |
michael@0 | 168 | #define _PR_UNLOCK_HEAP() if (_pr_primordialCPU) { \ |
michael@0 | 169 | _PR_UNLOCK(_pr_heapLock); \ |
michael@0 | 170 | if (_MD_GET_ATTACHED_THREAD() && \ |
michael@0 | 171 | !_PR_IS_NATIVE_THREAD( \ |
michael@0 | 172 | _MD_GET_ATTACHED_THREAD())) \ |
michael@0 | 173 | _PR_INTSON(_is); \ |
michael@0 | 174 | } \ |
michael@0 | 175 | } |
michael@0 | 176 | |
michael@0 | 177 | #define _PR_OPEN_POLL_SEM(_sem) usopenpollsema(_sem, 0666) |
michael@0 | 178 | #define _PR_WAIT_SEM(_sem) uspsema(_sem) |
michael@0 | 179 | #define _PR_POST_SEM(_sem) usvsema(_sem) |
michael@0 | 180 | |
michael@0 | 181 | #define _MD_CVAR_POST_SEM(threadp) usvsema((threadp)->md.cvar_pollsem) |
michael@0 | 182 | |
michael@0 | 183 | #define _MD_IOQ_LOCK() |
michael@0 | 184 | #define _MD_IOQ_UNLOCK() |
michael@0 | 185 | |
michael@0 | 186 | struct _MDLock { |
michael@0 | 187 | ulock_t lock; |
michael@0 | 188 | usptr_t *arena; |
michael@0 | 189 | }; |
michael@0 | 190 | |
michael@0 | 191 | /* |
michael@0 | 192 | * disable pre-emption for the LOCAL threads when calling the arena lock |
michael@0 | 193 | * routines |
michael@0 | 194 | */ |
michael@0 | 195 | |
michael@0 | 196 | #define _PR_LOCK(lock) { \ |
michael@0 | 197 | PRIntn _is; \ |
michael@0 | 198 | PRThread *me = _MD_GET_ATTACHED_THREAD(); \ |
michael@0 | 199 | if (me && !_PR_IS_NATIVE_THREAD(me)) \ |
michael@0 | 200 | _PR_INTSOFF(_is); \ |
michael@0 | 201 | ussetlock(lock); \ |
michael@0 | 202 | if (me && !_PR_IS_NATIVE_THREAD(me)) \ |
michael@0 | 203 | _PR_FAST_INTSON(_is); \ |
michael@0 | 204 | } |
michael@0 | 205 | |
michael@0 | 206 | #define _PR_UNLOCK(lock) { \ |
michael@0 | 207 | PRIntn _is; \ |
michael@0 | 208 | PRThread *me = _MD_GET_ATTACHED_THREAD(); \ |
michael@0 | 209 | if (me && !_PR_IS_NATIVE_THREAD(me)) \ |
michael@0 | 210 | _PR_INTSOFF(_is); \ |
michael@0 | 211 | usunsetlock(lock); \ |
michael@0 | 212 | if (me && !_PR_IS_NATIVE_THREAD(me)) \ |
michael@0 | 213 | _PR_FAST_INTSON(_is); \ |
michael@0 | 214 | } |
michael@0 | 215 | |
michael@0 | 216 | NSPR_API(PRStatus) _MD_NEW_LOCK(struct _MDLock *md); |
michael@0 | 217 | NSPR_API(void) _MD_FREE_LOCK(struct _MDLock *lockp); |
michael@0 | 218 | |
michael@0 | 219 | #define _MD_LOCK(_lockp) _PR_LOCK((_lockp)->lock) |
michael@0 | 220 | #define _MD_UNLOCK(_lockp) _PR_UNLOCK((_lockp)->lock) |
michael@0 | 221 | #define _MD_TEST_AND_LOCK(_lockp) (uscsetlock((_lockp)->lock, 1) == 0) |
michael@0 | 222 | |
michael@0 | 223 | extern ulock_t _pr_heapLock; |
michael@0 | 224 | |
michael@0 | 225 | struct _MDThread { |
michael@0 | 226 | jmp_buf jb; |
michael@0 | 227 | usptr_t *pollsem_arena; |
michael@0 | 228 | usema_t *cvar_pollsem; |
michael@0 | 229 | PRInt32 cvar_pollsemfd; |
michael@0 | 230 | PRInt32 cvar_pollsem_select; /* acquire sem by calling select */ |
michael@0 | 231 | PRInt32 cvar_wait; /* if 1, thread is waiting on cvar Q */ |
michael@0 | 232 | PRInt32 id; |
michael@0 | 233 | PRInt32 suspending_id; |
michael@0 | 234 | int errcode; |
michael@0 | 235 | }; |
michael@0 | 236 | |
michael@0 | 237 | struct _MDThreadStack { |
michael@0 | 238 | PRInt8 notused; |
michael@0 | 239 | }; |
michael@0 | 240 | |
michael@0 | 241 | struct _MDSemaphore { |
michael@0 | 242 | usema_t *sem; |
michael@0 | 243 | }; |
michael@0 | 244 | |
michael@0 | 245 | struct _MDCVar { |
michael@0 | 246 | ulock_t mdcvar_lock; |
michael@0 | 247 | }; |
michael@0 | 248 | |
michael@0 | 249 | struct _MDSegment { |
michael@0 | 250 | PRInt8 notused; |
michael@0 | 251 | }; |
michael@0 | 252 | |
michael@0 | 253 | /* |
michael@0 | 254 | * md-specific cpu structure field |
michael@0 | 255 | */ |
michael@0 | 256 | #define _PR_MD_MAX_OSFD FD_SETSIZE |
michael@0 | 257 | |
michael@0 | 258 | struct _MDCPU_Unix { |
michael@0 | 259 | PRCList ioQ; |
michael@0 | 260 | PRUint32 ioq_timeout; |
michael@0 | 261 | PRInt32 ioq_max_osfd; |
michael@0 | 262 | PRInt32 ioq_osfd_cnt; |
michael@0 | 263 | #ifndef _PR_USE_POLL |
michael@0 | 264 | fd_set fd_read_set, fd_write_set, fd_exception_set; |
michael@0 | 265 | PRInt16 fd_read_cnt[_PR_MD_MAX_OSFD],fd_write_cnt[_PR_MD_MAX_OSFD], |
michael@0 | 266 | fd_exception_cnt[_PR_MD_MAX_OSFD]; |
michael@0 | 267 | #else |
michael@0 | 268 | struct pollfd *ioq_pollfds; |
michael@0 | 269 | int ioq_pollfds_size; |
michael@0 | 270 | #endif /* _PR_USE_POLL */ |
michael@0 | 271 | }; |
michael@0 | 272 | |
michael@0 | 273 | #define _PR_IOQ(_cpu) ((_cpu)->md.md_unix.ioQ) |
michael@0 | 274 | #define _PR_ADD_TO_IOQ(_pq, _cpu) PR_APPEND_LINK(&_pq.links, &_PR_IOQ(_cpu)) |
michael@0 | 275 | #define _PR_FD_READ_SET(_cpu) ((_cpu)->md.md_unix.fd_read_set) |
michael@0 | 276 | #define _PR_FD_READ_CNT(_cpu) ((_cpu)->md.md_unix.fd_read_cnt) |
michael@0 | 277 | #define _PR_FD_WRITE_SET(_cpu) ((_cpu)->md.md_unix.fd_write_set) |
michael@0 | 278 | #define _PR_FD_WRITE_CNT(_cpu) ((_cpu)->md.md_unix.fd_write_cnt) |
michael@0 | 279 | #define _PR_FD_EXCEPTION_SET(_cpu) ((_cpu)->md.md_unix.fd_exception_set) |
michael@0 | 280 | #define _PR_FD_EXCEPTION_CNT(_cpu) ((_cpu)->md.md_unix.fd_exception_cnt) |
michael@0 | 281 | #define _PR_IOQ_TIMEOUT(_cpu) ((_cpu)->md.md_unix.ioq_timeout) |
michael@0 | 282 | #define _PR_IOQ_MAX_OSFD(_cpu) ((_cpu)->md.md_unix.ioq_max_osfd) |
michael@0 | 283 | #define _PR_IOQ_OSFD_CNT(_cpu) ((_cpu)->md.md_unix.ioq_osfd_cnt) |
michael@0 | 284 | #define _PR_IOQ_POLLFDS(_cpu) ((_cpu)->md.md_unix.ioq_pollfds) |
michael@0 | 285 | #define _PR_IOQ_POLLFDS_SIZE(_cpu) ((_cpu)->md.md_unix.ioq_pollfds_size) |
michael@0 | 286 | |
michael@0 | 287 | #define _PR_IOQ_MIN_POLLFDS_SIZE(_cpu) 32 |
michael@0 | 288 | |
michael@0 | 289 | |
michael@0 | 290 | struct _MDCPU { |
michael@0 | 291 | PRInt32 id; |
michael@0 | 292 | PRInt32 suspending_id; |
michael@0 | 293 | struct _MDCPU_Unix md_unix; |
michael@0 | 294 | }; |
michael@0 | 295 | |
michael@0 | 296 | /* |
michael@0 | 297 | ** Initialize the thread context preparing it to execute _main. |
michael@0 | 298 | */ |
michael@0 | 299 | #define _MD_INIT_CONTEXT(_thread, _sp, _main, status) \ |
michael@0 | 300 | PR_BEGIN_MACRO \ |
michael@0 | 301 | int *jb = (_thread)->md.jb; \ |
michael@0 | 302 | *status = PR_TRUE; \ |
michael@0 | 303 | (void) setjmp(jb); \ |
michael@0 | 304 | (_thread)->md.jb[JB_SP] = (int) ((_sp) - 64); \ |
michael@0 | 305 | (_thread)->md.jb[JB_PC] = (int) _main; \ |
michael@0 | 306 | _thread->no_sched = 0; \ |
michael@0 | 307 | PR_END_MACRO |
michael@0 | 308 | |
michael@0 | 309 | /* |
michael@0 | 310 | ** Switch away from the current thread context by saving its state and |
michael@0 | 311 | ** calling the thread scheduler. Reload cpu when we come back from the |
michael@0 | 312 | ** context switch because it might have changed. |
michael@0 | 313 | * |
michael@0 | 314 | * XXX RUNQ lock needed before clearing _PR_NO_SCHED flag, because the |
michael@0 | 315 | * thread may be unr RUNQ? |
michael@0 | 316 | */ |
michael@0 | 317 | #define _MD_SWITCH_CONTEXT(_thread) \ |
michael@0 | 318 | PR_BEGIN_MACRO \ |
michael@0 | 319 | PR_ASSERT(_thread->no_sched); \ |
michael@0 | 320 | if (!setjmp(_thread->md.jb)) { \ |
michael@0 | 321 | _MD_SAVE_ERRNO(_thread) \ |
michael@0 | 322 | _MD_SET_LAST_THREAD(_thread); \ |
michael@0 | 323 | _PR_Schedule(); \ |
michael@0 | 324 | } else { \ |
michael@0 | 325 | PR_ASSERT(_MD_LAST_THREAD() !=_MD_CURRENT_THREAD()); \ |
michael@0 | 326 | _MD_LAST_THREAD()->no_sched = 0; \ |
michael@0 | 327 | } \ |
michael@0 | 328 | PR_END_MACRO |
michael@0 | 329 | |
michael@0 | 330 | /* |
michael@0 | 331 | ** Restore a thread context that was saved by _MD_SWITCH_CONTEXT or |
michael@0 | 332 | ** initialized by _MD_INIT_CONTEXT. |
michael@0 | 333 | */ |
michael@0 | 334 | #define _MD_RESTORE_CONTEXT(_newThread) \ |
michael@0 | 335 | PR_BEGIN_MACRO \ |
michael@0 | 336 | int *jb = (_newThread)->md.jb; \ |
michael@0 | 337 | _MD_RESTORE_ERRNO(_newThread) \ |
michael@0 | 338 | _MD_SET_CURRENT_THREAD(_newThread); \ |
michael@0 | 339 | _newThread->no_sched = 1; \ |
michael@0 | 340 | longjmp(jb, 1); \ |
michael@0 | 341 | PR_END_MACRO |
michael@0 | 342 | |
michael@0 | 343 | NSPR_API(PRStatus) _MD_InitThread(struct PRThread *thread, |
michael@0 | 344 | PRBool wakeup_parent); |
michael@0 | 345 | NSPR_API(PRStatus) _MD_InitAttachedThread(struct PRThread *thread, |
michael@0 | 346 | PRBool wakeup_parent); |
michael@0 | 347 | #define _MD_INIT_THREAD(thread) _MD_InitThread(thread, PR_TRUE) |
michael@0 | 348 | #define _MD_INIT_ATTACHED_THREAD(thread) \ |
michael@0 | 349 | _MD_InitAttachedThread(thread, PR_FALSE) |
michael@0 | 350 | |
michael@0 | 351 | NSPR_API(void) _MD_ExitThread(struct PRThread *thread); |
michael@0 | 352 | #define _MD_EXIT_THREAD _MD_ExitThread |
michael@0 | 353 | |
michael@0 | 354 | NSPR_API(void) _MD_SuspendThread(struct PRThread *thread); |
michael@0 | 355 | #define _MD_SUSPEND_THREAD _MD_SuspendThread |
michael@0 | 356 | |
michael@0 | 357 | NSPR_API(void) _MD_ResumeThread(struct PRThread *thread); |
michael@0 | 358 | #define _MD_RESUME_THREAD _MD_ResumeThread |
michael@0 | 359 | |
michael@0 | 360 | NSPR_API(void) _MD_SuspendCPU(struct _PRCPU *thread); |
michael@0 | 361 | #define _MD_SUSPEND_CPU _MD_SuspendCPU |
michael@0 | 362 | |
michael@0 | 363 | NSPR_API(void) _MD_ResumeCPU(struct _PRCPU *thread); |
michael@0 | 364 | #define _MD_RESUME_CPU _MD_ResumeCPU |
michael@0 | 365 | |
michael@0 | 366 | #define _MD_BEGIN_SUSPEND_ALL() |
michael@0 | 367 | #define _MD_END_SUSPEND_ALL() |
michael@0 | 368 | #define _MD_BEGIN_RESUME_ALL() |
michael@0 | 369 | #define _MD_END_RESUME_ALL() |
michael@0 | 370 | |
michael@0 | 371 | NSPR_API(void) _MD_InitLocks(void); |
michael@0 | 372 | #define _MD_INIT_LOCKS _MD_InitLocks |
michael@0 | 373 | |
michael@0 | 374 | NSPR_API(void) _MD_CleanThread(struct PRThread *thread); |
michael@0 | 375 | #define _MD_CLEAN_THREAD _MD_CleanThread |
michael@0 | 376 | |
michael@0 | 377 | #define _MD_YIELD() sginap(0) |
michael@0 | 378 | |
michael@0 | 379 | /* The _PR_MD_WAIT_LOCK and _PR_MD_WAKEUP_WAITER functions put to sleep and |
michael@0 | 380 | * awaken a thread which is waiting on a lock or cvar. |
michael@0 | 381 | */ |
michael@0 | 382 | NSPR_API(PRStatus) _MD_wait(struct PRThread *, PRIntervalTime timeout); |
michael@0 | 383 | #define _MD_WAIT _MD_wait |
michael@0 | 384 | |
michael@0 | 385 | NSPR_API(void) _PR_MD_primordial_cpu(); |
michael@0 | 386 | NSPR_API(void) _PR_MD_WAKEUP_PRIMORDIAL_CPU(); |
michael@0 | 387 | |
michael@0 | 388 | NSPR_API(PRStatus) _MD_WakeupWaiter(struct PRThread *); |
michael@0 | 389 | #define _MD_WAKEUP_WAITER _MD_WakeupWaiter |
michael@0 | 390 | |
michael@0 | 391 | NSPR_API(void ) _MD_exit(PRIntn status); |
michael@0 | 392 | #define _MD_EXIT _MD_exit |
michael@0 | 393 | |
michael@0 | 394 | #include "prthread.h" |
michael@0 | 395 | |
michael@0 | 396 | NSPR_API(void) _MD_SetPriority(struct _MDThread *thread, |
michael@0 | 397 | PRThreadPriority newPri); |
michael@0 | 398 | #define _MD_SET_PRIORITY _MD_SetPriority |
michael@0 | 399 | |
michael@0 | 400 | NSPR_API(PRStatus) _MD_CreateThread( |
michael@0 | 401 | struct PRThread *thread, |
michael@0 | 402 | void (*start) (void *), |
michael@0 | 403 | PRThreadPriority priority, |
michael@0 | 404 | PRThreadScope scope, |
michael@0 | 405 | PRThreadState state, |
michael@0 | 406 | PRUint32 stackSize); |
michael@0 | 407 | #define _MD_CREATE_THREAD _MD_CreateThread |
michael@0 | 408 | |
michael@0 | 409 | extern void _MD_CleanupBeforeExit(void); |
michael@0 | 410 | #define _MD_CLEANUP_BEFORE_EXIT _MD_CleanupBeforeExit |
michael@0 | 411 | |
michael@0 | 412 | NSPR_API(void) _PR_MD_PRE_CLEANUP(PRThread *me); |
michael@0 | 413 | |
michael@0 | 414 | |
michael@0 | 415 | /* The following defines the unwrapped versions of select() and poll(). */ |
michael@0 | 416 | extern int _select(int nfds, fd_set *readfds, fd_set *writefds, |
michael@0 | 417 | fd_set *exceptfds, struct timeval *timeout); |
michael@0 | 418 | #define _MD_SELECT _select |
michael@0 | 419 | |
michael@0 | 420 | #include <stropts.h> |
michael@0 | 421 | #include <poll.h> |
michael@0 | 422 | #define _MD_POLL _poll |
michael@0 | 423 | extern int _poll(struct pollfd *fds, unsigned long nfds, int timeout); |
michael@0 | 424 | |
michael@0 | 425 | |
michael@0 | 426 | #define HAVE_THREAD_AFFINITY 1 |
michael@0 | 427 | |
michael@0 | 428 | NSPR_API(PRInt32) _MD_GetThreadAffinityMask(PRThread *unused, PRUint32 *mask); |
michael@0 | 429 | #define _MD_GETTHREADAFFINITYMASK _MD_GetThreadAffinityMask |
michael@0 | 430 | |
michael@0 | 431 | NSPR_API(void) _MD_InitRunningCPU(struct _PRCPU *cpu); |
michael@0 | 432 | #define _MD_INIT_RUNNING_CPU _MD_InitRunningCPU |
michael@0 | 433 | |
michael@0 | 434 | #endif /* defined(_PR_PTHREADS) */ |
michael@0 | 435 | |
michael@0 | 436 | #endif /* _LANGUAGE_ASSEMBLY */ |
michael@0 | 437 | |
michael@0 | 438 | #endif /* nspr_irix_defs_h___ */ |