Commit | Line | Data |
---|---|---|
d6376244 JH |
1 | /* thread.h |
2 | * | |
54ca4ee7 | 3 | * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
1d325971 | 4 | * by Larry Wall and others |
d6376244 JH |
5 | * |
6 | * You may distribute under the terms of either the GNU General Public | |
7 | * License or the Artistic License, as specified in the README file. | |
8 | * | |
9 | */ | |
10 | ||
3db8f154 | 11 | #if defined(USE_ITHREADS) |
12ca11f6 | 12 | |
fd8cd3a3 DS |
13 | #if defined(VMS) |
14 | #include <builtins.h> | |
15 | #endif | |
16 | ||
ea0efc06 | 17 | #ifdef WIN32 |
d55594ae | 18 | # include <win32thread.h> |
c2844c4f | 19 | #elif defined(NETWARE) |
2986a63f JH |
20 | # include <nw5thread.h> |
21 | #else | |
0d85d877 | 22 | # ifdef OLD_PTHREADS_API /* Here be dragons. */ |
ba869deb GS |
23 | # define DETACH(t) \ |
24 | STMT_START { \ | |
28a80024 MHM |
25 | int _eC_; \ |
26 | if ((_eC_ = pthread_detach(&(t)->self))) { \ | |
ba869deb | 27 | MUTEX_UNLOCK(&(t)->mutex); \ |
28a80024 MHM |
28 | Perl_croak_nocontext("panic: DETACH (%d) [%s:%d]", \ |
29 | _eC_, __FILE__, __LINE__); \ | |
ba869deb | 30 | } \ |
ea0efc06 | 31 | } STMT_END |
ba869deb GS |
32 | |
33 | # define PERL_GET_CONTEXT Perl_get_context() | |
34 | # define PERL_SET_CONTEXT(t) Perl_set_context((void*)t) | |
35 | ||
0d85d877 JH |
36 | # define PTHREAD_GETSPECIFIC_INT |
37 | # ifdef DJGPP | |
38 | # define pthread_addr_t any_t | |
39 | # define NEED_PTHREAD_INIT | |
6dc3770d | 40 | # define PTHREAD_CREATE_JOINABLE (1) |
0d85d877 | 41 | # endif |
20b634c2 JH |
42 | # ifdef OEMVS |
43 | # define pthread_addr_t void * | |
20b634c2 JH |
44 | # define pthread_create(t,a,s,d) pthread_create(t,&(a),s,d) |
45 | # define pthread_keycreate pthread_key_create | |
46 | # endif | |
0d85d877 JH |
47 | # ifdef VMS |
48 | # define pthread_attr_init(a) pthread_attr_create(a) | |
49 | # define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_setdetach_np(a,s) | |
6dc3770d | 50 | # define PTHREAD_CREATE(t,a,s,d) pthread_create(t,a,s,d) |
0d85d877 JH |
51 | # define pthread_key_create(k,d) pthread_keycreate(k,(pthread_destructor_t)(d)) |
52 | # define pthread_mutexattr_init(a) pthread_mutexattr_create(a) | |
9bbd4fab | 53 | # define pthread_mutexattr_settype(a,t) pthread_mutexattr_setkind_np(a,t) |
0d85d877 | 54 | # endif |
2eb25c99 JH |
55 | # if defined(__hpux) && defined(__ux_version) && __ux_version <= 1020 |
56 | # define pthread_attr_init(a) pthread_attr_create(a) | |
57 | /* XXX pthread_setdetach_np() missing in DCE threads on HP-UX 10.20 */ | |
10617789 | 58 | # define PTHREAD_ATTR_SETDETACHSTATE(a,s) (0) |
2eb25c99 JH |
59 | # define PTHREAD_CREATE(t,a,s,d) pthread_create(t,a,s,d) |
60 | # define pthread_key_create(k,d) pthread_keycreate(k,(pthread_destructor_t)(d)) | |
61 | # define pthread_mutexattr_init(a) pthread_mutexattr_create(a) | |
62 | # define pthread_mutexattr_settype(a,t) pthread_mutexattr_setkind_np(a,t) | |
63 | # endif | |
043fec90 | 64 | # if defined(DJGPP) || defined(OEMVS) |
0d85d877 JH |
65 | # define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_attr_setdetachstate(a,&(s)) |
66 | # define YIELD pthread_yield(NULL) | |
67 | # endif | |
0d85d877 | 68 | # endif |
2eb25c99 | 69 | # if !defined(__hpux) || !defined(__ux_version) || __ux_version > 1020 |
1cfa4ec7 | 70 | # define pthread_mutexattr_default NULL |
0d85d877 | 71 | # define pthread_condattr_default NULL |
2eb25c99 | 72 | # endif |
0d85d877 JH |
73 | #endif |
74 | ||
75 | #ifndef PTHREAD_CREATE | |
76 | /* You are not supposed to pass NULL as the 2nd arg of PTHREAD_CREATE(). */ | |
77 | # define PTHREAD_CREATE(t,a,s,d) pthread_create(t,&(a),s,d) | |
78 | #endif | |
79 | ||
80 | #ifndef PTHREAD_ATTR_SETDETACHSTATE | |
81 | # define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_attr_setdetachstate(a,s) | |
d55594ae | 82 | #endif |
1cfa4ec7 | 83 | |
ef4af2be JH |
84 | #ifndef PTHREAD_CREATE_JOINABLE |
85 | # ifdef OLD_PTHREAD_CREATE_JOINABLE | |
86 | # define PTHREAD_CREATE_JOINABLE OLD_PTHREAD_CREATE_JOINABLE | |
87 | # else | |
88 | # define PTHREAD_CREATE_JOINABLE 0 /* Panic? No, guess. */ | |
89 | # endif | |
90 | #endif | |
91 | ||
93a09687 JM |
92 | #ifdef __VMS |
93 | /* Default is 1024 on VAX, 8192 otherwise */ | |
3319632a CB |
94 | # ifdef __ia64 |
95 | # define THREAD_CREATE_NEEDS_STACK (48*1024) | |
96 | # else | |
97 | # define THREAD_CREATE_NEEDS_STACK (32*1024) | |
98 | # endif | |
93a09687 JM |
99 | #endif |
100 | ||
7f3d1cf1 BH |
101 | #ifdef I_MACH_CTHREADS |
102 | ||
103 | /* cthreads interface */ | |
104 | ||
105 | /* #include <mach/cthreads.h> is in perl.h #ifdef I_MACH_CTHREADS */ | |
106 | ||
ba869deb GS |
107 | #define MUTEX_INIT(m) \ |
108 | STMT_START { \ | |
109 | *m = mutex_alloc(); \ | |
110 | if (*m) { \ | |
111 | mutex_init(*m); \ | |
112 | } else { \ | |
28a80024 MHM |
113 | Perl_croak_nocontext("panic: MUTEX_INIT [%s:%d]", \ |
114 | __FILE__, __LINE__); \ | |
ba869deb GS |
115 | } \ |
116 | } STMT_END | |
117 | ||
118 | #define MUTEX_LOCK(m) mutex_lock(*m) | |
ba869deb | 119 | #define MUTEX_UNLOCK(m) mutex_unlock(*m) |
ba869deb GS |
120 | #define MUTEX_DESTROY(m) \ |
121 | STMT_START { \ | |
122 | mutex_free(*m); \ | |
123 | *m = 0; \ | |
124 | } STMT_END | |
125 | ||
126 | #define COND_INIT(c) \ | |
127 | STMT_START { \ | |
128 | *c = condition_alloc(); \ | |
129 | if (*c) { \ | |
130 | condition_init(*c); \ | |
131 | } \ | |
132 | else { \ | |
28a80024 MHM |
133 | Perl_croak_nocontext("panic: COND_INIT [%s:%d]", \ |
134 | __FILE__, __LINE__); \ | |
ba869deb GS |
135 | } \ |
136 | } STMT_END | |
7f3d1cf1 BH |
137 | |
138 | #define COND_SIGNAL(c) condition_signal(*c) | |
139 | #define COND_BROADCAST(c) condition_broadcast(*c) | |
140 | #define COND_WAIT(c, m) condition_wait(*c, *m) | |
ba869deb GS |
141 | #define COND_DESTROY(c) \ |
142 | STMT_START { \ | |
143 | condition_free(*c); \ | |
144 | *c = 0; \ | |
145 | } STMT_END | |
7f3d1cf1 | 146 | |
7f3d1cf1 | 147 | #define THREAD_RET_TYPE any_t |
7f3d1cf1 BH |
148 | |
149 | #define DETACH(t) cthread_detach(t->self) | |
a062e10d | 150 | #define JOIN(t, avp) (*(avp) = MUTABLE_AV(cthread_join(t->self))) |
7f3d1cf1 | 151 | |
ba869deb GS |
152 | #define PERL_SET_CONTEXT(t) cthread_set_data(cthread_self(), t) |
153 | #define PERL_GET_CONTEXT cthread_data(cthread_self()) | |
7f3d1cf1 BH |
154 | |
155 | #define INIT_THREADS cthread_init() | |
156 | #define YIELD cthread_yield() | |
ba869deb | 157 | #define ALLOC_THREAD_KEY NOOP |
e1b5da64 | 158 | #define FREE_THREAD_KEY NOOP |
7f3d1cf1 BH |
159 | #define SET_THREAD_SELF(thr) (thr->self = cthread_self()) |
160 | ||
161 | #endif /* I_MACH_CTHREADS */ | |
162 | ||
1cfa4ec7 | 163 | #ifndef YIELD |
e7a4f449 JH |
164 | # ifdef SCHED_YIELD |
165 | # define YIELD SCHED_YIELD | |
c2844c4f AC |
166 | # elif defined(HAS_SCHED_YIELD) |
167 | # define YIELD sched_yield() | |
168 | # elif defined(HAS_PTHREAD_YIELD) | |
e7a4f449 JH |
169 | /* pthread_yield(NULL) platforms are expected |
170 | * to have #defined YIELD for themselves. */ | |
c2844c4f | 171 | # define YIELD pthread_yield() |
e7a4f449 | 172 | # endif |
9731c6ca | 173 | #endif |
11343788 | 174 | |
227c31c3 JH |
175 | #ifdef __hpux |
176 | # define MUTEX_INIT_NEEDS_MUTEX_ZEROED | |
177 | #endif | |
178 | ||
ea0efc06 | 179 | #ifndef MUTEX_INIT |
ba869deb GS |
180 | |
181 | # ifdef MUTEX_INIT_NEEDS_MUTEX_ZEROED | |
227c31c3 | 182 | /* Temporary workaround, true bug is deeper. --jhi 1999-02-25 */ |
ba869deb | 183 | # define MUTEX_INIT(m) \ |
227c31c3 | 184 | STMT_START { \ |
28a80024 | 185 | int _eC_; \ |
227c31c3 | 186 | Zero((m), 1, perl_mutex); \ |
28a80024 MHM |
187 | if ((_eC_ = pthread_mutex_init((m), pthread_mutexattr_default))) \ |
188 | Perl_croak_nocontext("panic: MUTEX_INIT (%d) [%s:%d]", \ | |
189 | _eC_, __FILE__, __LINE__); \ | |
227c31c3 | 190 | } STMT_END |
ba869deb GS |
191 | # else |
192 | # define MUTEX_INIT(m) \ | |
ea0efc06 | 193 | STMT_START { \ |
28a80024 MHM |
194 | int _eC_; \ |
195 | if ((_eC_ = pthread_mutex_init((m), pthread_mutexattr_default))) \ | |
196 | Perl_croak_nocontext("panic: MUTEX_INIT (%d) [%s:%d]", \ | |
197 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 198 | } STMT_END |
ba869deb GS |
199 | # endif |
200 | ||
3baee7cc JH |
201 | # ifdef PERL_TSA_ACTIVE |
202 | # define perl_pthread_mutex_lock(m) perl_tsa_mutex_lock(m) | |
203 | # define perl_pthread_mutex_unlock(m) perl_tsa_mutex_unlock(m) | |
204 | # else | |
205 | # define perl_pthread_mutex_lock(m) pthread_mutex_lock(m) | |
206 | # define perl_pthread_mutex_unlock(m) pthread_mutex_unlock(m) | |
207 | # endif | |
208 | ||
ba869deb GS |
209 | # define MUTEX_LOCK(m) \ |
210 | STMT_START { \ | |
28a80024 | 211 | int _eC_; \ |
3baee7cc | 212 | if ((_eC_ = perl_pthread_mutex_lock((m)))) \ |
28a80024 MHM |
213 | Perl_croak_nocontext("panic: MUTEX_LOCK (%d) [%s:%d]", \ |
214 | _eC_, __FILE__, __LINE__); \ | |
cea2e8a9 | 215 | } STMT_END |
ba869deb | 216 | |
efc57feb | 217 | # define MUTEX_UNLOCK(m) \ |
ba869deb | 218 | STMT_START { \ |
28a80024 | 219 | int _eC_; \ |
3baee7cc | 220 | if ((_eC_ = perl_pthread_mutex_unlock((m)))) \ |
28a80024 MHM |
221 | Perl_croak_nocontext("panic: MUTEX_UNLOCK (%d) [%s:%d]", \ |
222 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 223 | } STMT_END |
ba869deb GS |
224 | |
225 | # define MUTEX_DESTROY(m) \ | |
226 | STMT_START { \ | |
28a80024 MHM |
227 | int _eC_; \ |
228 | if ((_eC_ = pthread_mutex_destroy((m)))) \ | |
229 | Perl_croak_nocontext("panic: MUTEX_DESTROY (%d) [%s:%d]", \ | |
230 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 MB |
231 | } STMT_END |
232 | #endif /* MUTEX_INIT */ | |
233 | ||
234 | #ifndef COND_INIT | |
ba869deb | 235 | # define COND_INIT(c) \ |
ea0efc06 | 236 | STMT_START { \ |
28a80024 MHM |
237 | int _eC_; \ |
238 | if ((_eC_ = pthread_cond_init((c), pthread_condattr_default))) \ | |
239 | Perl_croak_nocontext("panic: COND_INIT (%d) [%s:%d]", \ | |
240 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 241 | } STMT_END |
ba869deb GS |
242 | |
243 | # define COND_SIGNAL(c) \ | |
244 | STMT_START { \ | |
28a80024 MHM |
245 | int _eC_; \ |
246 | if ((_eC_ = pthread_cond_signal((c)))) \ | |
247 | Perl_croak_nocontext("panic: COND_SIGNAL (%d) [%s:%d]", \ | |
248 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 249 | } STMT_END |
ba869deb GS |
250 | |
251 | # define COND_BROADCAST(c) \ | |
252 | STMT_START { \ | |
28a80024 MHM |
253 | int _eC_; \ |
254 | if ((_eC_ = pthread_cond_broadcast((c)))) \ | |
255 | Perl_croak_nocontext("panic: COND_BROADCAST (%d) [%s:%d]", \ | |
256 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 257 | } STMT_END |
ba869deb GS |
258 | |
259 | # define COND_WAIT(c, m) \ | |
260 | STMT_START { \ | |
28a80024 MHM |
261 | int _eC_; \ |
262 | if ((_eC_ = pthread_cond_wait((c), (m)))) \ | |
263 | Perl_croak_nocontext("panic: COND_WAIT (%d) [%s:%d]", \ | |
264 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 265 | } STMT_END |
ba869deb GS |
266 | |
267 | # define COND_DESTROY(c) \ | |
268 | STMT_START { \ | |
28a80024 MHM |
269 | int _eC_; \ |
270 | if ((_eC_ = pthread_cond_destroy((c)))) \ | |
271 | Perl_croak_nocontext("panic: COND_DESTROY (%d) [%s:%d]", \ | |
272 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 MB |
273 | } STMT_END |
274 | #endif /* COND_INIT */ | |
33f46ff6 | 275 | |
5640a370 KW |
276 | #if defined(MUTEX_LOCK) && defined(MUTEX_UNLOCK) \ |
277 | && defined(COND_SIGNAL) && defined(COND_WAIT) | |
278 | ||
279 | /* These emulate native many-reader/1-writer locks. | |
280 | * Basically a locking reader just locks the semaphore long enough to increment | |
281 | * a counter; and similarly decrements it when when through. Any writer will | |
282 | * run only when the count of readers is 0. That is because it blocks on that | |
283 | * semaphore (doing a COND_WAIT) until it gets control of it, which won't | |
284 | * happen unless the count becomes 0. ALL readers and other writers are then | |
285 | * blocked until it releases the semaphore. The reader whose unlocking causes | |
286 | * the count to become 0 signals any waiting writers, and the system guarantees | |
287 | * that only one gets control at a time */ | |
288 | ||
289 | # define PERL_READ_LOCK(mutex) \ | |
290 | STMT_START { \ | |
c4f0298e KW |
291 | MUTEX_LOCK(mutex.lock); \ |
292 | (mutex)->readers_count++; \ | |
293 | MUTEX_UNLOCK(mutex.lock); \ | |
5640a370 KW |
294 | } STMT_END |
295 | ||
296 | # define PERL_READ_UNLOCK(mutex) \ | |
297 | STMT_START { \ | |
c4f0298e KW |
298 | MUTEX_LOCK(mutex.lock); \ |
299 | (mutex)->readers_count--; \ | |
300 | if ((mutex)->readers_count <= 0) { \ | |
0b83dfe6 | 301 | COND_SIGNAL(mutex.wakeup); \ |
c4f0298e | 302 | (mutex)->readers_count = 0; \ |
5640a370 | 303 | } \ |
c4f0298e | 304 | MUTEX_UNLOCK(mutex.lock); \ |
5640a370 KW |
305 | } STMT_END |
306 | ||
307 | # define PERL_WRITE_LOCK(mutex) \ | |
308 | STMT_START { \ | |
c4f0298e | 309 | MUTEX_LOCK(mutex.lock); \ |
5640a370 | 310 | do { \ |
c4f0298e | 311 | if ((mutex)->readers_count == 0) \ |
5640a370 | 312 | break; \ |
0b83dfe6 | 313 | COND_WAIT(mutex.wakeup, mutex.lock); \ |
5640a370 KW |
314 | } \ |
315 | while (1); \ | |
316 | \ | |
317 | /* Here, the mutex is locked, with no readers */ \ | |
318 | } STMT_END | |
319 | ||
2cca577c KW |
320 | # define PERL_WRITE_UNLOCK(mutex) \ |
321 | STMT_START { \ | |
0b83dfe6 | 322 | COND_SIGNAL(mutex.wakeup); \ |
2cca577c KW |
323 | MUTEX_UNLOCK(mutex.lock); \ |
324 | } STMT_END | |
c4f0298e | 325 | |
72dfa47e KW |
326 | # define PERL_RW_MUTEX_INIT(mutex) \ |
327 | STMT_START { \ | |
328 | MUTEX_INIT(mutex.lock); \ | |
0b83dfe6 | 329 | COND_INIT(mutex.wakeup); \ |
72dfa47e KW |
330 | (mutex)->readers_count = 0; \ |
331 | } STMT_END | |
332 | ||
333 | # define PERL_RW_MUTEX_DESTROY(mutex) \ | |
334 | STMT_START { \ | |
0b83dfe6 | 335 | COND_DESTROY(mutex.wakeup); \ |
72dfa47e KW |
336 | MUTEX_DESTROY(mutex.lock); \ |
337 | } STMT_END | |
338 | ||
5640a370 KW |
339 | #endif |
340 | ||
f826a10b | 341 | /* DETACH(t) must only be called while holding t->mutex */ |
ea0efc06 | 342 | #ifndef DETACH |
ba869deb GS |
343 | # define DETACH(t) \ |
344 | STMT_START { \ | |
28a80024 MHM |
345 | int _eC_; \ |
346 | if ((_eC_ = pthread_detach((t)->self))) { \ | |
ba869deb | 347 | MUTEX_UNLOCK(&(t)->mutex); \ |
28a80024 MHM |
348 | Perl_croak_nocontext("panic: DETACH (%d) [%s:%d]", \ |
349 | _eC_, __FILE__, __LINE__); \ | |
ba869deb | 350 | } \ |
ea0efc06 MB |
351 | } STMT_END |
352 | #endif /* DETACH */ | |
33f46ff6 | 353 | |
ea0efc06 | 354 | #ifndef JOIN |
ba869deb GS |
355 | # define JOIN(t, avp) \ |
356 | STMT_START { \ | |
28a80024 MHM |
357 | int _eC_; \ |
358 | if ((_eC_ = pthread_join((t)->self, (void**)(avp)))) \ | |
359 | Perl_croak_nocontext("panic: pthread_join (%d) [%s:%d]", \ | |
360 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 MB |
361 | } STMT_END |
362 | #endif /* JOIN */ | |
363 | ||
0953243c JH |
364 | /* Use an unchecked fetch of thread-specific data instead of a checked one. |
365 | * It would fail if the key were bogus, but if the key were bogus then | |
366 | * Really Bad Things would be happening anyway. --dan */ | |
026b9da6 | 367 | #if (defined(__ALPHA) && (__VMS_VER >= 70000000)) || \ |
cb23e6a4 | 368 | (defined(__alpha) && defined(__osf__) && !defined(__GNUC__)) /* Available only on >= 4.0 */ |
8b8b35ab JH |
369 | # define HAS_PTHREAD_UNCHECKED_GETSPECIFIC_NP /* Configure test needed */ |
370 | #endif | |
371 | ||
372 | #ifdef HAS_PTHREAD_UNCHECKED_GETSPECIFIC_NP | |
373 | # define PTHREAD_GETSPECIFIC(key) pthread_unchecked_getspecific_np(key) | |
374 | #else | |
6cfe8af5 | 375 | # define PTHREAD_GETSPECIFIC(key) pthread_getspecific(key) |
8b8b35ab JH |
376 | #endif |
377 | ||
378 | #ifndef PERL_GET_CONTEXT | |
379 | # define PERL_GET_CONTEXT PTHREAD_GETSPECIFIC(PL_thr_key) | |
ba869deb GS |
380 | #endif |
381 | ||
382 | #ifndef PERL_SET_CONTEXT | |
383 | # define PERL_SET_CONTEXT(t) \ | |
384 | STMT_START { \ | |
28a80024 MHM |
385 | int _eC_; \ |
386 | if ((_eC_ = pthread_setspecific(PL_thr_key, (void *)(t)))) \ | |
387 | Perl_croak_nocontext("panic: pthread_setspecific (%d) [%s:%d]", \ | |
388 | _eC_, __FILE__, __LINE__); \ | |
ea0efc06 | 389 | } STMT_END |
ba869deb | 390 | #endif /* PERL_SET_CONTEXT */ |
ea0efc06 | 391 | |
1feb2720 GS |
392 | #ifndef INIT_THREADS |
393 | # ifdef NEED_PTHREAD_INIT | |
394 | # define INIT_THREADS pthread_init() | |
395 | # endif | |
0d85d877 | 396 | #endif |
ea0efc06 | 397 | |
ba869deb GS |
398 | #ifndef ALLOC_THREAD_KEY |
399 | # define ALLOC_THREAD_KEY \ | |
400 | STMT_START { \ | |
23dd8dc9 | 401 | if (pthread_key_create(&PL_thr_key, 0)) { \ |
b469f1e0 | 402 | PERL_UNUSED_RESULT(write(2, STR_WITH_LEN("panic: pthread_key_create failed\n"))); \ |
c44d3fdb GS |
403 | exit(1); \ |
404 | } \ | |
ba869deb GS |
405 | } STMT_END |
406 | #endif | |
407 | ||
e1b5da64 GS |
408 | #ifndef FREE_THREAD_KEY |
409 | # define FREE_THREAD_KEY \ | |
410 | STMT_START { \ | |
411 | pthread_key_delete(PL_thr_key); \ | |
412 | } STMT_END | |
413 | #endif | |
414 | ||
50dd6e57 | 415 | #ifndef PTHREAD_ATFORK |
144e72cb | 416 | # ifdef HAS_PTHREAD_ATFORK |
417 | # define PTHREAD_ATFORK(prepare,parent,child) \ | |
de992003 | 418 | pthread_atfork(prepare,parent,child) |
144e72cb | 419 | # else |
8ff9412f C |
420 | # define PTHREAD_ATFORK(prepare,parent,child) \ |
421 | NOOP | |
144e72cb | 422 | # endif |
50dd6e57 GS |
423 | #endif |
424 | ||
1feb2720 GS |
425 | #ifndef THREAD_RET_TYPE |
426 | # define THREAD_RET_TYPE void * | |
1feb2720 GS |
427 | #endif /* THREAD_RET */ |
428 | ||
e2975953 JH |
429 | # define LOCK_DOLLARZERO_MUTEX MUTEX_LOCK(&PL_dollarzero_mutex) |
430 | # define UNLOCK_DOLLARZERO_MUTEX MUTEX_UNLOCK(&PL_dollarzero_mutex) | |
431 | ||
3db8f154 | 432 | #endif /* USE_ITHREADS */ |
1feb2720 GS |
433 | |
434 | #ifndef MUTEX_LOCK | |
63d37b7a | 435 | # define MUTEX_LOCK(m) NOOP |
1feb2720 GS |
436 | #endif |
437 | ||
1feb2720 | 438 | #ifndef MUTEX_UNLOCK |
63d37b7a | 439 | # define MUTEX_UNLOCK(m) NOOP |
1feb2720 | 440 | #endif |
1feb2720 GS |
441 | |
442 | #ifndef MUTEX_INIT | |
63d37b7a | 443 | # define MUTEX_INIT(m) NOOP |
1feb2720 GS |
444 | #endif |
445 | ||
446 | #ifndef MUTEX_DESTROY | |
63d37b7a | 447 | # define MUTEX_DESTROY(m) NOOP |
1feb2720 GS |
448 | #endif |
449 | ||
450 | #ifndef COND_INIT | |
63d37b7a | 451 | # define COND_INIT(c) NOOP |
1feb2720 GS |
452 | #endif |
453 | ||
454 | #ifndef COND_SIGNAL | |
63d37b7a | 455 | # define COND_SIGNAL(c) NOOP |
1feb2720 GS |
456 | #endif |
457 | ||
458 | #ifndef COND_BROADCAST | |
63d37b7a | 459 | # define COND_BROADCAST(c) NOOP |
1feb2720 GS |
460 | #endif |
461 | ||
462 | #ifndef COND_WAIT | |
63d37b7a | 463 | # define COND_WAIT(c, m) NOOP |
1feb2720 GS |
464 | #endif |
465 | ||
466 | #ifndef COND_DESTROY | |
63d37b7a | 467 | # define COND_DESTROY(c) NOOP |
1feb2720 GS |
468 | #endif |
469 | ||
5640a370 KW |
470 | #ifndef PERL_READ_LOCK |
471 | # define PERL_READ_LOCK NOOP | |
472 | # define PERL_READ_UNLOCK NOOP | |
473 | # define PERL_WRITE_LOCK NOOP | |
474 | # define PERL_WRITE_UNLOCK NOOP | |
475 | #endif | |
476 | ||
e2975953 | 477 | #ifndef LOCK_DOLLARZERO_MUTEX |
63d37b7a | 478 | # define LOCK_DOLLARZERO_MUTEX NOOP |
e2975953 JH |
479 | #endif |
480 | ||
481 | #ifndef UNLOCK_DOLLARZERO_MUTEX | |
63d37b7a | 482 | # define UNLOCK_DOLLARZERO_MUTEX NOOP |
e2975953 JH |
483 | #endif |
484 | ||
ba869deb | 485 | /* THR, SET_THR, and dTHR are there for compatibility with old versions */ |
1feb2720 | 486 | #ifndef THR |
ba869deb GS |
487 | # define THR PERL_GET_THX |
488 | #endif | |
489 | ||
490 | #ifndef SET_THR | |
491 | # define SET_THR(t) PERL_SET_THX(t) | |
1feb2720 GS |
492 | #endif |
493 | ||
494 | #ifndef dTHR | |
495 | # define dTHR dNOOP | |
496 | #endif | |
497 | ||
498 | #ifndef INIT_THREADS | |
499 | # define INIT_THREADS NOOP | |
500 | #endif | |
e9a8c099 MHM |
501 | |
502 | /* | |
14d04a33 | 503 | * ex: set ts=8 sts=4 sw=4 et: |
e9a8c099 | 504 | */ |