Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 | /* |
michael@0 | 7 | * SCO ODT 5.0 - originally created by mikep |
michael@0 | 8 | */ |
michael@0 | 9 | #include "primpl.h" |
michael@0 | 10 | |
michael@0 | 11 | #include <setjmp.h> |
michael@0 | 12 | |
michael@0 | 13 | void _MD_EarlyInit(void) |
michael@0 | 14 | { |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) |
michael@0 | 18 | { |
michael@0 | 19 | if (isCurrent) { |
michael@0 | 20 | (void) setjmp(CONTEXT(t)); |
michael@0 | 21 | } |
michael@0 | 22 | *np = sizeof(CONTEXT(t)) / sizeof(PRWord); |
michael@0 | 23 | return (PRWord *) CONTEXT(t); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | #ifdef ALARMS_BREAK_TCP /* I don't think they do */ |
michael@0 | 27 | |
michael@0 | 28 | PRInt32 _MD_connect(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen, |
michael@0 | 29 | PRIntervalTime timeout) |
michael@0 | 30 | { |
michael@0 | 31 | PRInt32 rv; |
michael@0 | 32 | |
michael@0 | 33 | _MD_BLOCK_CLOCK_INTERRUPTS(); |
michael@0 | 34 | rv = _connect(osfd,addr,addrlen); |
michael@0 | 35 | _MD_UNBLOCK_CLOCK_INTERRUPTS(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | PRInt32 _MD_accept(PRInt32 osfd, PRNetAddr *addr, PRInt32 addrlen, |
michael@0 | 39 | PRIntervalTime timeout) |
michael@0 | 40 | { |
michael@0 | 41 | PRInt32 rv; |
michael@0 | 42 | |
michael@0 | 43 | _MD_BLOCK_CLOCK_INTERRUPTS(); |
michael@0 | 44 | rv = _accept(osfd,addr,addrlen); |
michael@0 | 45 | _MD_UNBLOCK_CLOCK_INTERRUPTS(); |
michael@0 | 46 | return(rv); |
michael@0 | 47 | } |
michael@0 | 48 | #endif |
michael@0 | 49 | |
michael@0 | 50 | /* |
michael@0 | 51 | * These are also implemented in pratom.c using NSPR locks. Any reason |
michael@0 | 52 | * this might be better or worse? If you like this better, define |
michael@0 | 53 | * _PR_HAVE_ATOMIC_OPS in include/md/unixware.h |
michael@0 | 54 | */ |
michael@0 | 55 | #ifdef _PR_HAVE_ATOMIC_OPS |
michael@0 | 56 | /* Atomic operations */ |
michael@0 | 57 | #include <stdio.h> |
michael@0 | 58 | static FILE *_uw_semf; |
michael@0 | 59 | |
michael@0 | 60 | void |
michael@0 | 61 | _MD_INIT_ATOMIC(void) |
michael@0 | 62 | { |
michael@0 | 63 | /* Sigh. Sure wish SYSV semaphores weren't such a pain to use */ |
michael@0 | 64 | if ((_uw_semf = tmpfile()) == NULL) |
michael@0 | 65 | PR_ASSERT(0); |
michael@0 | 66 | |
michael@0 | 67 | return; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | void |
michael@0 | 71 | _MD_ATOMIC_INCREMENT(PRInt32 *val) |
michael@0 | 72 | { |
michael@0 | 73 | flockfile(_uw_semf); |
michael@0 | 74 | (*val)++; |
michael@0 | 75 | unflockfile(_uw_semf); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | void |
michael@0 | 79 | _MD_ATOMIC_ADD(PRInt32 *ptr, PRInt32 val) |
michael@0 | 80 | { |
michael@0 | 81 | flockfile(_uw_semf); |
michael@0 | 82 | (*ptr) += val; |
michael@0 | 83 | unflockfile(_uw_semf); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | void |
michael@0 | 87 | _MD_ATOMIC_DECREMENT(PRInt32 *val) |
michael@0 | 88 | { |
michael@0 | 89 | flockfile(_uw_semf); |
michael@0 | 90 | (*val)--; |
michael@0 | 91 | unflockfile(_uw_semf); |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | void |
michael@0 | 95 | _MD_ATOMIC_SET(PRInt32 *val, PRInt32 newval) |
michael@0 | 96 | { |
michael@0 | 97 | flockfile(_uw_semf); |
michael@0 | 98 | *val = newval; |
michael@0 | 99 | unflockfile(_uw_semf); |
michael@0 | 100 | } |
michael@0 | 101 | #endif |
michael@0 | 102 | |
michael@0 | 103 | void |
michael@0 | 104 | _MD_SET_PRIORITY(_MDThread *thread, PRUintn newPri) |
michael@0 | 105 | { |
michael@0 | 106 | return; |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | PRStatus |
michael@0 | 110 | _MD_InitializeThread(PRThread *thread) |
michael@0 | 111 | { |
michael@0 | 112 | return PR_SUCCESS; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | PRStatus |
michael@0 | 116 | _MD_WAIT(PRThread *thread, PRIntervalTime ticks) |
michael@0 | 117 | { |
michael@0 | 118 | PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); |
michael@0 | 119 | _PR_MD_SWITCH_CONTEXT(thread); |
michael@0 | 120 | return PR_SUCCESS; |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | PRStatus |
michael@0 | 124 | _MD_WAKEUP_WAITER(PRThread *thread) |
michael@0 | 125 | { |
michael@0 | 126 | if (thread) { |
michael@0 | 127 | PR_ASSERT(!(thread->flags & _PR_GLOBAL_SCOPE)); |
michael@0 | 128 | } |
michael@0 | 129 | return PR_SUCCESS; |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | /* These functions should not be called for SCO */ |
michael@0 | 133 | void |
michael@0 | 134 | _MD_YIELD(void) |
michael@0 | 135 | { |
michael@0 | 136 | PR_NOT_REACHED("_MD_YIELD should not be called for SCO."); |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | PRStatus |
michael@0 | 140 | _MD_CREATE_THREAD( |
michael@0 | 141 | PRThread *thread, |
michael@0 | 142 | void (*start) (void *), |
michael@0 | 143 | PRThreadPriority priority, |
michael@0 | 144 | PRThreadScope scope, |
michael@0 | 145 | PRThreadState state, |
michael@0 | 146 | PRUint32 stackSize) |
michael@0 | 147 | { |
michael@0 | 148 | PR_NOT_REACHED("_MD_CREATE_THREAD should not be called for SCO."); |
michael@0 | 149 | } |