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