… | |
… | |
14 | #include "perliol.h" |
14 | #include "perliol.h" |
15 | |
15 | |
16 | #include "schmorp.h" |
16 | #include "schmorp.h" |
17 | |
17 | |
18 | #define ECB_NO_THREADS 1 |
18 | #define ECB_NO_THREADS 1 |
|
|
19 | #define ECB_NO_LIBM 1 |
19 | #include "ecb.h" |
20 | #include "ecb.h" |
20 | |
21 | |
21 | #include <stddef.h> |
22 | #include <stddef.h> |
22 | #include <stdio.h> |
23 | #include <stdio.h> |
23 | #include <errno.h> |
24 | #include <errno.h> |
… | |
… | |
26 | #ifndef SVs_PADSTALE |
27 | #ifndef SVs_PADSTALE |
27 | # define SVs_PADSTALE 0 |
28 | # define SVs_PADSTALE 0 |
28 | #endif |
29 | #endif |
29 | |
30 | |
30 | #ifdef PadARRAY |
31 | #ifdef PadARRAY |
31 | # define NEWPADAPI |
32 | # define NEWPADAPI 1 |
32 | # define newPADLIST(var) (Newz (0, var, 1, PADLIST), Newx (PadlistARRAY (var), 2, PAD *)) |
33 | # define newPADLIST(var) (Newz (0, var, 1, PADLIST), Newx (PadlistARRAY (var), 2, PAD *)) |
33 | #else |
34 | #else |
34 | typedef AV PADNAMELIST; |
35 | typedef AV PADNAMELIST; |
35 | # if !PERL_VERSION_ATLEAST(5,8,0) |
36 | # if !PERL_VERSION_ATLEAST(5,8,0) |
36 | typedef AV PADLIST; |
37 | typedef AV PADLIST; |
… | |
… | |
42 | # define PadARRAY AvARRAY |
43 | # define PadARRAY AvARRAY |
43 | # define PadMAX AvFILLp |
44 | # define PadMAX AvFILLp |
44 | # define newPADLIST(var) ((var) = newAV (), av_extend (var, 1)) |
45 | # define newPADLIST(var) ((var) = newAV (), av_extend (var, 1)) |
45 | #endif |
46 | #endif |
46 | |
47 | |
|
|
48 | /* 5.19.something has replaced SVt_BIND by SVt_INVLIST */ |
|
|
49 | /* we just alias it to SVt_IV, as that is sufficient for swap_sv for now */ |
|
|
50 | #if PERL_VERSION_ATLEAST(5,19,0) |
|
|
51 | # define SVt_BIND SVt_IV |
|
|
52 | #endif |
|
|
53 | |
47 | #if defined(_WIN32) |
54 | #if defined(_WIN32) |
48 | # undef HAS_GETTIMEOFDAY |
55 | # undef HAS_GETTIMEOFDAY |
49 | # undef setjmp |
56 | # undef setjmp |
50 | # undef longjmp |
57 | # undef longjmp |
51 | # undef _exit |
58 | # undef _exit |
… | |
… | |
511 | coro_derive_padlist (pTHX_ CV *cv) |
518 | coro_derive_padlist (pTHX_ CV *cv) |
512 | { |
519 | { |
513 | PADLIST *padlist = CvPADLIST (cv); |
520 | PADLIST *padlist = CvPADLIST (cv); |
514 | PADLIST *newpadlist; |
521 | PADLIST *newpadlist; |
515 | PAD *newpad; |
522 | PAD *newpad; |
516 | PADOFFSET const off = PadlistMAX (padlist) + 1; |
523 | PADOFFSET off = PadlistMAX (padlist) + 1; |
517 | |
524 | |
518 | newPADLIST(newpadlist); |
525 | #if NEWPADAPI |
519 | #if !PERL_VERSION_ATLEAST(5,15,3) |
526 | |
520 | /* Padlists are AvREAL as of 5.15.3. See perl bug #98092 and perl commit 7d953ba. */ |
527 | /* if we had the original CvDEPTH, we might be able to steal the CvDEPTH+1 entry instead */ |
521 | AvREAL_off (newpadlist); |
528 | /* 20131102194744.GA6705@schmorp.de, 20131102195825.2013.qmail@lists-nntp.develooper.com */ |
522 | #endif |
529 | while (!PadlistARRAY (padlist)[off - 1]) |
|
|
530 | --off; |
|
|
531 | |
|
|
532 | Perl_pad_push (aTHX_ padlist, off); |
|
|
533 | |
|
|
534 | newpad = PadlistARRAY (padlist)[off]; |
|
|
535 | PadlistARRAY (padlist)[off] = 0; |
|
|
536 | |
|
|
537 | #else |
|
|
538 | |
523 | #if PERL_VERSION_ATLEAST (5,10,0) |
539 | #if PERL_VERSION_ATLEAST (5,10,0) |
524 | Perl_pad_push (aTHX_ padlist, off); |
540 | Perl_pad_push (aTHX_ padlist, off); |
525 | #else |
541 | #else |
526 | Perl_pad_push (aTHX_ padlist, off, 1); |
542 | Perl_pad_push (aTHX_ padlist, off, 1); |
527 | #endif |
543 | #endif |
|
|
544 | |
528 | newpad = PadlistARRAY (padlist)[off]; |
545 | newpad = PadlistARRAY (padlist)[off]; |
529 | PadlistMAX (padlist) = off - 1; |
546 | PadlistMAX (padlist) = off - 1; |
|
|
547 | |
|
|
548 | #endif |
|
|
549 | |
|
|
550 | newPADLIST (newpadlist); |
|
|
551 | #if !PERL_VERSION_ATLEAST(5,15,3) |
|
|
552 | /* Padlists are AvREAL as of 5.15.3. See perl bug #98092 and perl commit 7d953ba. */ |
|
|
553 | AvREAL_off (newpadlist); |
|
|
554 | #endif |
530 | |
555 | |
531 | /* Already extended to 2 elements by newPADLIST. */ |
556 | /* Already extended to 2 elements by newPADLIST. */ |
532 | PadlistMAX (newpadlist) = 1; |
557 | PadlistMAX (newpadlist) = 1; |
533 | PadlistNAMES (newpadlist) = (PADNAMELIST *)SvREFCNT_inc_NN (PadlistNAMES (padlist)); |
558 | PadlistNAMES (newpadlist) = (PADNAMELIST *)SvREFCNT_inc_NN (PadlistNAMES (padlist)); |
534 | PadlistARRAY (newpadlist)[1] = newpad; |
559 | PadlistARRAY (newpadlist)[1] = newpad; |
… | |
… | |
546 | |
571 | |
547 | while (i > 0) /* special-case index 0 */ |
572 | while (i > 0) /* special-case index 0 */ |
548 | { |
573 | { |
549 | /* we try to be extra-careful here */ |
574 | /* we try to be extra-careful here */ |
550 | PAD *pad = PadlistARRAY (padlist)[i--]; |
575 | PAD *pad = PadlistARRAY (padlist)[i--]; |
|
|
576 | |
|
|
577 | if (pad) |
|
|
578 | { |
551 | I32 j = PadMAX (pad); |
579 | I32 j = PadMAX (pad); |
552 | |
580 | |
553 | while (j >= 0) |
581 | while (j >= 0) |
554 | SvREFCNT_dec (PadARRAY (pad)[j--]); |
582 | SvREFCNT_dec (PadARRAY (pad)[j--]); |
555 | |
583 | |
556 | PadMAX (pad) = -1; |
584 | PadMAX (pad) = -1; |
557 | SvREFCNT_dec (pad); |
585 | SvREFCNT_dec (pad); |
|
|
586 | } |
558 | } |
587 | } |
559 | |
588 | |
560 | SvREFCNT_dec (PadlistNAMES (padlist)); |
589 | SvREFCNT_dec (PadlistNAMES (padlist)); |
561 | |
590 | |
562 | #ifdef NEWPADAPI |
591 | #if NEWPADAPI |
563 | Safefree (PadlistARRAY (padlist)); |
592 | Safefree (PadlistARRAY (padlist)); |
564 | Safefree (padlist); |
593 | Safefree (padlist); |
565 | #else |
594 | #else |
566 | AvFILLp (padlist) = -1; |
595 | AvFILLp (padlist) = -1; |
567 | AvREAL_off (padlist); |
596 | AvREAL_off (padlist); |
… | |
… | |
1888 | /* nothing to schedule: call the idle handler */ |
1917 | /* nothing to schedule: call the idle handler */ |
1889 | if (SvROK (sv_idle) |
1918 | if (SvROK (sv_idle) |
1890 | && SvOBJECT (SvRV (sv_idle))) |
1919 | && SvOBJECT (SvRV (sv_idle))) |
1891 | { |
1920 | { |
1892 | if (SvRV (sv_idle) == SvRV (coro_current)) |
1921 | if (SvRV (sv_idle) == SvRV (coro_current)) |
|
|
1922 | { |
|
|
1923 | require_pv ("Carp"); |
|
|
1924 | |
|
|
1925 | { |
|
|
1926 | dSP; |
|
|
1927 | |
|
|
1928 | ENTER; |
|
|
1929 | SAVETMPS; |
|
|
1930 | |
|
|
1931 | PUSHMARK (SP); |
1893 | croak ("FATAL: $Coro::IDLE blocked itself - did you try to block inside an event loop callback? Caught"); |
1932 | XPUSHs (sv_2mortal (newSVpv ("FATAL: $Coro::IDLE blocked itself - did you try to block inside an event loop callback? Caught", 0))); |
|
|
1933 | PUTBACK; |
|
|
1934 | call_pv ("Carp::confess", G_VOID | G_DISCARD); |
|
|
1935 | |
|
|
1936 | FREETMPS; |
|
|
1937 | LEAVE; |
|
|
1938 | } |
|
|
1939 | } |
1894 | |
1940 | |
1895 | ++coro_nready; /* hack so that api_ready doesn't invoke ready hook */ |
1941 | ++coro_nready; /* hack so that api_ready doesn't invoke ready hook */ |
1896 | api_ready (aTHX_ SvRV (sv_idle)); |
1942 | api_ready (aTHX_ SvRV (sv_idle)); |
1897 | --coro_nready; |
1943 | --coro_nready; |
1898 | } |
1944 | } |
… | |
… | |
3151 | /* it quickly returns */ |
3197 | /* it quickly returns */ |
3152 | if (CORO_THROW) |
3198 | if (CORO_THROW) |
3153 | return 0; |
3199 | return 0; |
3154 | |
3200 | |
3155 | /* one element that is an RV? repeat! */ |
3201 | /* one element that is an RV? repeat! */ |
3156 | if (AvFILLp (state) == 0 && SvROK (AvARRAY (state)[0])) |
3202 | if (AvFILLp (state) == 0 && SvTYPE (AvARRAY (state)[0]) != SVt_PV) |
3157 | return 1; |
3203 | return 1; |
3158 | |
3204 | |
3159 | /* restore status */ |
3205 | /* restore status */ |
3160 | { |
3206 | { |
3161 | SV *data_sv = av_pop (state); |
3207 | SV *data_sv = av_pop (state); |