… | |
… | |
22 | |
22 | |
23 | #ifndef SvREFCNT_inc_NN |
23 | #ifndef SvREFCNT_inc_NN |
24 | #define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv) |
24 | #define SvREFCNT_inc_NN(sv) SvREFCNT_inc (sv) |
25 | #endif |
25 | #endif |
26 | |
26 | |
27 | static pthread_key_t current_key; |
27 | static X_TLS_DECLARE(current_key); |
28 | |
28 | |
29 | static s_epipe ep; |
29 | static s_epipe ep; |
30 | static void *perl_thx; |
30 | static void *perl_thx; |
31 | static sigset_t cursigset, fullsigset; |
31 | static sigset_t cursigset, fullsigset; |
32 | |
32 | |
… | |
… | |
175 | static void |
175 | static void |
176 | pmapi_release (void) |
176 | pmapi_release (void) |
177 | { |
177 | { |
178 | if (!(thread_enable ? thread_enable & 1 : global_enable)) |
178 | if (!(thread_enable ? thread_enable & 1 : global_enable)) |
179 | { |
179 | { |
180 | pthread_setspecific (current_key, 0); |
180 | X_TLS_SET (current_key, 0); |
181 | return; |
181 | return; |
182 | } |
182 | } |
183 | |
183 | |
184 | struct tctx *ctx = tctx_get (); |
184 | struct tctx *ctx = tctx_get (); |
185 | ctx->coro = SvREFCNT_inc_NN (CORO_CURRENT); |
185 | ctx->coro = SvREFCNT_inc_NN (CORO_CURRENT); |
186 | ctx->wait_f = 0; |
186 | ctx->wait_f = 0; |
187 | |
187 | |
188 | pthread_setspecific (current_key, ctx); |
188 | X_TLS_SET (current_key, ctx); |
189 | pthread_sigmask (SIG_SETMASK, &fullsigset, &cursigset); |
189 | pthread_sigmask (SIG_SETMASK, &fullsigset, &cursigset); |
190 | |
190 | |
191 | X_LOCK (release_m); |
191 | X_LOCK (release_m); |
192 | |
192 | |
193 | if (idle <= min_idle) |
193 | if (idle <= min_idle) |
… | |
… | |
207 | |
207 | |
208 | static void |
208 | static void |
209 | pmapi_acquire (void) |
209 | pmapi_acquire (void) |
210 | { |
210 | { |
211 | int jeret; |
211 | int jeret; |
212 | struct tctx *ctx = pthread_getspecific (current_key); |
212 | struct tctx *ctx = X_TLS_GET (current_key); |
213 | |
213 | |
214 | if (!ctx) |
214 | if (!ctx) |
215 | return; |
215 | return; |
216 | |
216 | |
217 | X_LOCK (acquire_m); |
217 | X_LOCK (acquire_m); |
… | |
… | |
245 | { |
245 | { |
246 | #ifndef _WIN32 |
246 | #ifndef _WIN32 |
247 | sigfillset (&fullsigset); |
247 | sigfillset (&fullsigset); |
248 | #endif |
248 | #endif |
249 | |
249 | |
250 | pthread_key_create (¤t_key, 0); |
250 | X_TLS_INIT (current_key); |
251 | |
251 | |
252 | if (s_epipe_new (&ep)) |
252 | if (s_epipe_new (&ep)) |
253 | croak ("Coro::Multicore: unable to initialise event pipe.\n"); |
253 | croak ("Coro::Multicore: unable to initialise event pipe.\n"); |
254 | |
254 | |
255 | perl_thx = PERL_GET_CONTEXT; |
255 | perl_thx = PERL_GET_CONTEXT; |