State.c

filter: Statementstmt 0.0% 0 / 5 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 5 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Thread/State.pm ↑ Summary
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of State.xs. Do not edit this file, edit State.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "State.xs"
10 #define PERL_NO_GET_CONTEXT
11
12 #include "EXTERN.h"
13 #include "perl.h"
14 #include "XSUB.h"
15
16 #ifdef USE_ITHREADS
17
18 #ifndef WIN32
19 #include <pthread.h>
20 #endif
21
22 /* from threasd.xs */
23
24 /* Values for 'state' member (CPAN threads) */
25 #define PERL_ITHR_JOINABLE 0
26 #define PERL_ITHR_DETACHED 1
27 #define PERL_ITHR_JOINED 2
28 #define PERL_ITHR_FINISHED 4
29
30
31 /* perl core threads <= 5.8.8 */
32 typedef struct ithread_s {
33 struct ithread_s *next; /* Next thread in the list */
34 struct ithread_s *prev; /* Prev thread in the list */
35 PerlInterpreter *interp; /* The threads interpreter */
36 I32 tid; /* Threads module's thread id */
37 perl_mutex mutex; /* Mutex for updating things in this struct */
38 I32 count; /* How many SVs have a reference to us */
39 signed char state; /* Are we detached ? */
40 int gimme; /* Context of create */
41 SV* init_function; /* Code to run */
42 SV* params; /* Args to pass function */
43 #ifdef WIN32
44 DWORD thr; /* OS's idea if thread id */
45 HANDLE handle; /* OS's waitable handle */
46 #else
47 pthread_t thr; /* OS's handle for the thread */
48 #endif
49 } ithread;
50
51
52 /* From CPAN threads 1.11 >>>> this typedef was removed */
53
54 /* From CPAN threads 1.23 */
55 typedef struct _ithread {
56 struct _ithread *next; /* Next thread in the list */
57 struct _ithread *prev; /* Prev thread in the list */
58 PerlInterpreter *interp; /* The threads interpreter */
59 UV tid; /* Threads module's thread id */
60 perl_mutex mutex; /* Mutex for updating things in this struct */
61 int count; /* How many SVs have a reference to us */
62 int state; /* Detached, joined, finished, etc. */
63 int gimme; /* Context of create */
64 SV *init_function; /* Code to run */
65 SV *params; /* Args to pass function */
66 #ifdef WIN32
67 DWORD thr; /* OS's idea if thread id */
68 HANDLE handle; /* OS's waitable handle */
69 #else
70 pthread_t thr; /* OS's handle for the thread */
71 #endif
72 IV stack_size;
73 } ithread2;
74
75
76
77 NV threads_version; /* current used threads version */
78 NV perl_version; /* joined status for 5.8.0 Win32 */
79
80 #define state_is_joined(thread) ithread_state_is_joined(aTHX_ thread)
81 #define state_is_finished(thread) ithread_state_is_finished(aTHX_ thread)
82 #define state__is_detached(thread) ithread_state_is_detached(aTHX_ thread)
83 #define state__is_running(thread) ithread_state_is_running(aTHX_ thread)
84 #define state__is_joinable(thread) ithread_state_is_joinable(aTHX_ thread)
85 #define state__wantarray(thread) ithread_state_wantarray(aTHX_ thread)
86 #define state_coderef(thread) ithread_state_coderef(aTHX_ thread)
87 #define state_is_not_joined_nor_detached(thread) \
88 ithread_state_is_not_joined_nor_detached(aTHX_ thread)
89
90
91 #define THREADS_IS_NEW (threads_version > 1.23)
92 #define JOIN_HAS_PROBLEM (perl_version < 5.008001)
93
94 #define ITHREAD_OLD ((ithread*)thread)
95 #define ITHREAD_NEW ((ithread2*)thread)
96
97 #define ITHREAD_STATE_IS( state ) \
98 (THREADS_IS_NEW ? \
99 ithread2_state_is(aTHX_ sv, state) \
100 : ithread_state_is(aTHX_ sv, state) \
101 ) \
102
103 #define FIX_580_JOINED(sv) state_is_joined_fiexd_580 (aTHX_ sv)
104
105
106
107 void* state_get_current_ithread (pTHX) {
108 void* thread;
109 SV* thr_sv;
110 int count;
111
112 dSP;
113 ENTER;
114 SAVETMPS;
115
116 PUSHMARK(SP);
117 XPUSHs(sv_2mortal(newSVpv("threads", 0)));
118 PUTBACK;
119 count = call_method("self", G_SCALAR);
120
121 SPAGAIN;
122
123 if (count != 1)
124 croak("%s\n","Internal error, couldn't call thread->self");
125
126 thr_sv = POPs;
127
128 if (THREADS_IS_NEW) {
129 thread = (void*)(INT2PTR(ithread2*, SvIV(SvRV(thr_sv))));
130 }
131 else {
132 thread = (void*)(INT2PTR(ithread*, SvIV(SvRV(thr_sv))));
133 }
134
135 PUTBACK;
136 FREETMPS;
137 LEAVE;
138
139 return thread;
140 }
141
142
143 void* state_sv_to_ithread(pTHX_ SV *sv) {
144 void* thread = !SvROK(sv) ? state_get_current_ithread(aTHX) :
145 THREADS_IS_NEW ?
146 (void*)INT2PTR(ithread2*, SvIV(SvRV(sv)))
147 : (void*)INT2PTR(ithread*, SvIV(SvRV(sv)))
148 ;
149 return thread;
150 }
151
152
153 int ithread_state_is (pTHX_ SV* sv, signed char state) {
154 void* thread = state_sv_to_ithread(aTHX_ sv);
155 return (ITHREAD_OLD->state & state) ? 1 : 0;
156 }
157
158
159 int ithread2_state_is (pTHX_ SV* sv, int state) {
160 void* thread = state_sv_to_ithread(aTHX_ sv);
161 return (ITHREAD_NEW->state & state) ? 1 : 0;
162 }
163
164
165 int state_is_joined_fiexd_580 (pTHX_ SV* sv) {
166 if( !ITHREAD_STATE_IS( PERL_ITHR_JOINED ) ){
167 void* thread = state_sv_to_ithread(aTHX_ sv);
168 return !((ithread*)thread)->interp;
169 }
170 else {
171 return 1;
172 }
173 }
174
175
176 int ithread_state_is_running (pTHX_ SV* sv) {
177 return ! ITHREAD_STATE_IS(PERL_ITHR_FINISHED);
178 }
179
180
181 int ithread_state_is_finished (pTHX_ SV* sv) {
182 return ITHREAD_STATE_IS( PERL_ITHR_FINISHED );
183 }
184
185
186 int ithread_state_is_detached (pTHX_ SV* sv) {
187 return ITHREAD_STATE_IS( PERL_ITHR_DETACHED );
188 }
189
190
191 int ithread_state_is_joined (pTHX_ SV* sv) {
192 if (JOIN_HAS_PROBLEM && !THREADS_IS_NEW) {
193 return FIX_580_JOINED(sv);
194 }
195 return ITHREAD_STATE_IS( PERL_ITHR_JOINED );
196 }
197
198
199 int ithread_state_is_joinable (pTHX_ SV* sv) {
200 void* thread = state_sv_to_ithread(aTHX_ sv);
201
202 if (THREADS_IS_NEW) {
203 return ( (ITHREAD_NEW->state & PERL_ITHR_FINISHED)
204 && !(ITHREAD_NEW->state & (PERL_ITHR_DETACHED|PERL_ITHR_JOINED)) );
205 }
206 else if (JOIN_HAS_PROBLEM) {
207 return ( (ITHREAD_OLD->state & PERL_ITHR_FINISHED)
208 && !((ITHREAD_OLD->state & PERL_ITHR_DETACHED) || FIX_580_JOINED(sv)) );
209 }
210 else {
211 return ( (ITHREAD_OLD->state & PERL_ITHR_FINISHED)
212 && !(ITHREAD_OLD->state & (PERL_ITHR_DETACHED|PERL_ITHR_JOINED)) );
213 }
214 }
215
216
217 int ithread_state_is_not_joined_nor_detached (pTHX_ SV* sv) {
218 void* thread = state_sv_to_ithread(aTHX_ sv);
219
220 if (THREADS_IS_NEW) {
221 return !(ITHREAD_NEW->state & (PERL_ITHR_DETACHED|PERL_ITHR_JOINED));
222 }
223 else if (JOIN_HAS_PROBLEM) {
224 return !((ITHREAD_OLD->state & PERL_ITHR_DETACHED) || FIX_580_JOINED(sv));
225 }
226 else {
227 return !(ITHREAD_OLD->state & (PERL_ITHR_DETACHED|PERL_ITHR_JOINED));
228 }
229 }
230
231
232 SV* ithread_state_wantarray (pTHX_ SV* sv) {
233 void* thread = state_sv_to_ithread(aTHX_ sv);
234 int gimme
235 = THREADS_IS_NEW ? ITHREAD_NEW->gimme
236 : ITHREAD_OLD->gimme
237 ;
238
239 return gimme & G_VOID ? &PL_sv_undef
240 : gimme & G_ARRAY ? &PL_sv_yes
241 : &PL_sv_no // but this isn't G_SCALAR?
242 ;
243 }
244
245
246 SV* ithread_state_coderef (pTHX_ SV* sv) {
247 void* thread = state_sv_to_ithread(aTHX_ sv);
248 SV* coderef = THREADS_IS_NEW
249 ? ITHREAD_NEW->init_function
250 : ITHREAD_OLD->init_function
251 ;
252
253 if (coderef && SvREFCNT(coderef)) {
254 SvREFCNT_inc(coderef);
255 return coderef;
256 }
257 else {
258 return &PL_sv_undef;
259 }
260 }
261
262
263 /* accessors to thread priority */
264
265 SV* ithread_state_get_priority (pTHX_ SV* sv) {
266 void* thread = state_sv_to_ithread(aTHX_ sv);
267 #ifdef WIN32
268 HANDLE thr = THREADS_IS_NEW ? ITHREAD_NEW->handle : ITHREAD_OLD->handle;
269
270 if (thr) {
271 int priority = GetThreadPriority(thr);
272 if (priority == THREAD_PRIORITY_ERROR_RETURN){
273 return &PL_sv_undef;
274 }
275 return newSViv(priority);
276 }
277 else {
278 return &PL_sv_undef;
279 }
280 #else
281 struct sched_param param;
282 int policy;
283 int priority;
284
285 pthread_t thr = THREADS_IS_NEW ? ITHREAD_NEW->thr : ITHREAD_OLD->thr;
286
287 if ( pthread_getschedparam(thr, &policy, &param) ){
288 return &PL_sv_undef;
289 }
290 return newSViv(param.sched_priority);
291 #endif
292 }
293
294
295 SV* ithread_state_set_priority (pTHX_ SV* sv, int priority) {
296 void* thread = state_sv_to_ithread(aTHX_ sv);
297 int old_p;
298 #ifdef WIN32
299 HANDLE thr = THREADS_IS_NEW ? ITHREAD_NEW->handle : ITHREAD_OLD->handle;
300
301 if (thr) {
302 old_p = GetThreadPriority(thr);
303 if ( SetThreadPriority(thr, priority) ){
304 return newSViv(old_p);
305 }
306 else {
307 return &PL_sv_undef;
308 }
309 }
310 else {
311 return &PL_sv_undef;
312 }
313 #else
314 struct sched_param param;
315 int policy;
316
317 pthread_t thr = THREADS_IS_NEW ? ITHREAD_NEW->thr : ITHREAD_OLD->thr;
318
319 if ( pthread_getschedparam(thr, &policy, &param) ) {
320 return &PL_sv_undef;
321 }
322
323 old_p = param.sched_priority;
324
325 param.sched_priority = priority;
326
327 if (pthread_setschedparam(thr, policy, &param)) {
328 return &PL_sv_undef;
329 }
330 return newSViv(old_p);
331 #endif
332 }
333
334
335 #endif /* USE_ITHREADS */
336
337
338
339 #line 340 "State.c"
340 #ifndef PERL_UNUSED_VAR
341 # define PERL_UNUSED_VAR(var) if (0) var = var
342 #endif
343  
344 #ifndef dVAR
345 # define dVAR dNOOP
346 #endif
347  
348  
349 /* This stuff is not part of the API! You have been warned. */
350 #ifndef PERL_VERSION_DECIMAL
351 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
352 #endif
353 #ifndef PERL_DECIMAL_VERSION
354 # define PERL_DECIMAL_VERSION \
355 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
356 #endif
357 #ifndef PERL_VERSION_GE
358 # define PERL_VERSION_GE(r,v,s) \
359 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
360 #endif
361 #ifndef PERL_VERSION_LE
362 # define PERL_VERSION_LE(r,v,s) \
363 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
364 #endif
365  
366 /* XS_INTERNAL is the explicit static-linkage variant of the default
367 * XS macro.
368 *
369 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
370 * "static", ie. it exports XSUB symbols. You probably don't want that
371 * for anything but the BOOT XSUB.
372 *
373 * See XSUB.h in core!
374 */
375  
376  
377 /* TODO: This might be compatible further back than 5.10.0. */
378 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
379 # undef XS_EXTERNAL
380 # undef XS_INTERNAL
381 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
382 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
383 # define XS_INTERNAL(name) static XSPROTO(name)
384 # endif
385 # if defined(__SYMBIAN32__)
386 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
387 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
388 # endif
389 # ifndef XS_EXTERNAL
390 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
391 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
392 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
393 # else
394 # ifdef __cplusplus
395 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
396 # define XS_INTERNAL(name) static XSPROTO(name)
397 # else
398 # define XS_EXTERNAL(name) XSPROTO(name)
399 # define XS_INTERNAL(name) static XSPROTO(name)
400 # endif
401 # endif
402 # endif
403 #endif
404  
405 /* perl >= 5.10.0 && perl <= 5.15.1 */
406  
407  
408 /* The XS_EXTERNAL macro is used for functions that must not be static
409 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
410 * macro defined, the best we can do is assume XS is the same.
411 * Dito for XS_INTERNAL.
412 */
413 #ifndef XS_EXTERNAL
414 # define XS_EXTERNAL(name) XS(name)
415 #endif
416 #ifndef XS_INTERNAL
417 # define XS_INTERNAL(name) XS(name)
418 #endif
419  
420 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
421 * internal macro that we're free to redefine for varying linkage due
422 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
423 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
424 */
425  
426 #undef XS_EUPXS
427 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
428 # define XS_EUPXS(name) XS_EXTERNAL(name)
429 #else
430 /* default to internal */
431 # define XS_EUPXS(name) XS_INTERNAL(name)
432 #endif
433  
434 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
435 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
436  
437 /* prototype to pass -Wmissing-prototypes */
438 static void
439 S_croak_xs_usage(const CV *const cv, const char *const params);
440  
441 static void
442 S_croak_xs_usage(const CV *const cv, const char *const params)
443 {
444 const GV *const gv = CvGV(cv);
445  
446 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
447  
448 if (gv) {
449 const char *const gvname = GvNAME(gv);
450 const HV *const stash = GvSTASH(gv);
451 const char *const hvname = stash ? HvNAME(stash) : NULL;
452  
453 if (hvname)
454 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
455 else
456 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
457 } else {
458 /* Pants. I don't think that it should be possible to get here. */
459 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
460 }
461 }
462 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
463  
464 #define croak_xs_usage S_croak_xs_usage
465  
466 #endif
467  
468 /* NOTE: the prototype of newXSproto() is different in versions of perls,
469 * so we define a portable version of newXSproto()
470 */
471 #ifdef newXS_flags
472 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
473 #else
474 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
475 #endif /* !defined(newXS_flags) */
476  
477 #if PERL_VERSION_LE(5, 21, 5)
478 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
479 #else
480 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
481 #endif
482  
483 /* simple backcompat versions of the TARGx() macros with no optimisation */
484 #ifndef TARGi
485 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
486 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
487 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
488 #endif
489  
490 #line 491 "State.c"
491 #ifdef USE_ITHREADS
492 #define XSubPPtmpAAAA 1
493  
494  
495 XS_EUPXS(XS_threads__is_running); /* prototype to pass -Wmissing-prototypes */
496 XS_EUPXS(XS_threads__is_running)
497 {
498 dVAR; dXSARGS;
499 if (items != 1)
500 croak_xs_usage(cv, "obj");
501 {
502 SV* obj = ST(0)
503 ;
504 int RETVAL;
505 dXSTARG;
506  
507 RETVAL = state__is_running(obj);
508 TARGi((IV)RETVAL, 1);
509 ST(0) = TARG;
510 }
511 XSRETURN(1);
512 }
513  
514  
515 XS_EUPXS(XS_threads_is_finished); /* prototype to pass -Wmissing-prototypes */
516 XS_EUPXS(XS_threads_is_finished)
517 {
518 dVAR; dXSARGS;
519 if (items != 1)
520 croak_xs_usage(cv, "obj");
521 {
522 SV* obj = ST(0)
523 ;
524 int RETVAL;
525 dXSTARG;
526  
527 RETVAL = state_is_finished(obj);
528 TARGi((IV)RETVAL, 1);
529 ST(0) = TARG;
530 }
531 XSRETURN(1);
532 }
533  
534  
535 XS_EUPXS(XS_threads__is_detached); /* prototype to pass -Wmissing-prototypes */
536 XS_EUPXS(XS_threads__is_detached)
537 {
538 dVAR; dXSARGS;
539 if (items != 1)
540 croak_xs_usage(cv, "obj");
541 {
542 SV* obj = ST(0)
543 ;
544 int RETVAL;
545 dXSTARG;
546  
547 RETVAL = state__is_detached(obj);
548 TARGi((IV)RETVAL, 1);
549 ST(0) = TARG;
550 }
551 XSRETURN(1);
552 }
553  
554  
555 XS_EUPXS(XS_threads_is_joined); /* prototype to pass -Wmissing-prototypes */
556 XS_EUPXS(XS_threads_is_joined)
557 {
558 dVAR; dXSARGS;
559 if (items != 1)
560 croak_xs_usage(cv, "obj");
561 {
562 SV* obj = ST(0)
563 ;
564 int RETVAL;
565 dXSTARG;
566  
567 RETVAL = state_is_joined(obj);
568 TARGi((IV)RETVAL, 1);
569 ST(0) = TARG;
570 }
571 XSRETURN(1);
572 }
573  
574  
575 XS_EUPXS(XS_threads__is_joinable); /* prototype to pass -Wmissing-prototypes */
576 XS_EUPXS(XS_threads__is_joinable)
577 {
578 dVAR; dXSARGS;
579 if (items != 1)
580 croak_xs_usage(cv, "obj");
581 {
582 SV* obj = ST(0)
583 ;
584 int RETVAL;
585 dXSTARG;
586  
587 RETVAL = state__is_joinable(obj);
588 TARGi((IV)RETVAL, 1);
589 ST(0) = TARG;
590 }
591 XSRETURN(1);
592 }
593  
594  
595 XS_EUPXS(XS_threads_is_not_joined_nor_detached); /* prototype to pass -Wmissing-prototypes */
596 XS_EUPXS(XS_threads_is_not_joined_nor_detached)
597 {
598 dVAR; dXSARGS;
599 if (items != 1)
600 croak_xs_usage(cv, "obj");
601 {
602 SV* obj = ST(0)
603 ;
604 int RETVAL;
605 dXSTARG;
606  
607 RETVAL = state_is_not_joined_nor_detached(obj);
608 TARGi((IV)RETVAL, 1);
609 ST(0) = TARG;
610 }
611 XSRETURN(1);
612 }
613  
614  
615 XS_EUPXS(XS_threads__wantarray); /* prototype to pass -Wmissing-prototypes */
616 XS_EUPXS(XS_threads__wantarray)
617 {
618 dVAR; dXSARGS;
619 if (items != 1)
620 croak_xs_usage(cv, "obj");
621 {
622 SV* obj = ST(0)
623 ;
624 SV * RETVAL;
625  
626 RETVAL = state__wantarray(obj);
627 RETVAL = sv_2mortal(RETVAL);
628 ST(0) = RETVAL;
629 }
630 XSRETURN(1);
631 }
632  
633  
634 XS_EUPXS(XS_threads_coderef); /* prototype to pass -Wmissing-prototypes */
635 XS_EUPXS(XS_threads_coderef)
636 {
637 dVAR; dXSARGS;
638 if (items != 1)
639 croak_xs_usage(cv, "obj");
640 {
641 SV* obj = ST(0)
642 ;
643 SV * RETVAL;
644  
645 RETVAL = state_coderef(obj);
646 RETVAL = sv_2mortal(RETVAL);
647 ST(0) = RETVAL;
648 }
649 XSRETURN(1);
650 }
651  
652  
653 XS_EUPXS(XS_threads_priority); /* prototype to pass -Wmissing-prototypes */
654 XS_EUPXS(XS_threads_priority)
655 {
656 dVAR; dXSARGS;
657 if (items < 1)
658 croak_xs_usage(cv, "obj, ...");
659 {
660 SV* obj = ST(0)
661 ;
662 #line 372 "State.xs"
663 int priority;
664 SV* ret;
665 #line 666 "State.c"
666 SV * RETVAL;
667 #line 375 "State.xs"
668 if (items > 1) {
669 priority = SvIV(ST(1));
670 ret = ithread_state_set_priority(aTHX_ obj, priority);
671 }
672 else {
673 ret = ithread_state_get_priority(aTHX_ obj);
674 }
675 RETVAL = ret;
676 #line 677 "State.c"
677 RETVAL = sv_2mortal(RETVAL);
678 ST(0) = RETVAL;
679 }
680 XSRETURN(1);
681 }
682  
683 #endif /* USE_ITHREADS */
684 #ifdef __cplusplus
685 extern "C" {
686 #endif
687 XS_EXTERNAL(boot_Thread__State); /* prototype to pass -Wmissing-prototypes */
688 0 XS_EXTERNAL(boot_Thread__State)
689 {
690 #if PERL_VERSION_LE(5, 21, 5)
691 dVAR; dXSARGS;
692 #else
693 0 dVAR; dXSBOOTARGSXSAPIVERCHK;
694 #endif
695 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
696 char* file = __FILE__;
697 #else
698 0 const char* file = __FILE__;
699 #endif
700  
701 PERL_UNUSED_VAR(file);
702  
703 PERL_UNUSED_VAR(cv); /* -W */
704 PERL_UNUSED_VAR(items); /* -W */
705 #if PERL_VERSION_LE(5, 21, 5)
706 XS_VERSION_BOOTCHECK;
707 # ifdef XS_APIVERSION_BOOTCHECK
708 XS_APIVERSION_BOOTCHECK;
709 # endif
710 #endif
711  
712 #if XSubPPtmpAAAA
713 newXS_deffile("threads::_is_running", XS_threads__is_running);
714 newXS_deffile("threads::is_finished", XS_threads_is_finished);
715 newXS_deffile("threads::_is_detached", XS_threads__is_detached);
716 newXS_deffile("threads::is_joined", XS_threads_is_joined);
717 newXS_deffile("threads::_is_joinable", XS_threads__is_joinable);
718 newXS_deffile("threads::is_not_joined_nor_detached", XS_threads_is_not_joined_nor_detached);
719 newXS_deffile("threads::_wantarray", XS_threads__wantarray);
720 newXS_deffile("threads::coderef", XS_threads_coderef);
721 newXS_deffile("threads::priority", XS_threads_priority);
722 #endif
723  
724 /* Initialisation Section */
725  
726 #if XSubPPtmpAAAA
727 #endif
728 #line 390 "State.xs"
729 {
730 #ifdef USE_ITHREADS
731 /* check threads VERSION for CPAN version */
732  
733 HV* stash;
734 HV* mains;
735 SV** svp;
736  
737 stash = gv_stashpv("threads", 0);
738 mains = gv_stashpv("main", 0);
739  
740 svp = hv_fetch(mains, "]", 1, 0);
741 if ( svp && SvNOK(GvSV(*svp)) ){
742 perl_version = SvNV(GvSV(*svp));
743 }
744  
745 if (stash) {
746 svp = hv_fetch(stash, "VERSION", 7, 0);
747 if ( svp && SvOK(GvSV(*svp)) ){
748 threads_version = SvNV(GvSV(*svp));
749 }
750 }
751  
752 if (!threads_version) {
753 croak("You must use threads before using Thread::State.");
754 }
755 else if (threads_version > 1.07 && threads_version < 1.23) {
756 croak("Thread::State requires CORE threads or CPAN threads version >= 1.23.");
757 }
758 #endif /* USE_ITHREADS */
759 }
760  
761 #line 762 "State.c"
762  
763 /* End of Initialisation Section */
764  
765 #if PERL_VERSION_LE(5, 21, 5)
766 # if PERL_VERSION_GE(5, 9, 0)
767 if (PL_unitcheckav)
768 call_list(PL_scopestack_ix, PL_unitcheckav);
769 # endif
770 XSRETURN_YES;
771 #else
772 0 Perl_xs_boot_epilog(aTHX_ ax);
773 #endif
774 0 }
775  
776 #ifdef __cplusplus
777 }
778 #endif
« blib/lib/Thread/State.pm ↑ Summary