ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/State.xs
(Generate patch)

Comparing Coro/Coro/State.xs (file contents):
Revision 1.432 by root, Wed May 8 00:44:44 2013 UTC vs.
Revision 1.438 by root, Mon Nov 18 10:27:53 2013 UTC

26#ifndef SVs_PADSTALE 26#ifndef SVs_PADSTALE
27# define SVs_PADSTALE 0 27# define SVs_PADSTALE 0
28#endif 28#endif
29 29
30#ifdef PadARRAY 30#ifdef PadARRAY
31# define NEWPADAPI 31# define NEWPADAPI 1
32# define newPADLIST(var) (Newz (0, var, 1, PADLIST), Newx (PadlistARRAY (var), 2, PAD *)) 32# define newPADLIST(var) (Newz (0, var, 1, PADLIST), Newx (PadlistARRAY (var), 2, PAD *))
33#else 33#else
34typedef AV PADNAMELIST; 34typedef AV PADNAMELIST;
35# if !PERL_VERSION_ATLEAST(5,8,0) 35# if !PERL_VERSION_ATLEAST(5,8,0)
36typedef AV PADLIST; 36typedef AV PADLIST;
42# define PadARRAY AvARRAY 42# define PadARRAY AvARRAY
43# define PadMAX AvFILLp 43# define PadMAX AvFILLp
44# define newPADLIST(var) ((var) = newAV (), av_extend (var, 1)) 44# define newPADLIST(var) ((var) = newAV (), av_extend (var, 1))
45#endif 45#endif
46 46
47/* 5.19.something has replaced SVt_BIND by SVt_INVLIST */
48/* we just alias it to SVt_IV, as that is sufficient for swap_sv for now */
49#if PERL_VERSION_ATLEAST(5,19,0)
50# define SVt_BIND SVt_IV
51#endif
52
47#if defined(_WIN32) 53#if defined(_WIN32)
48# undef HAS_GETTIMEOFDAY 54# undef HAS_GETTIMEOFDAY
49# undef setjmp 55# undef setjmp
50# undef longjmp 56# undef longjmp
51# undef _exit 57# undef _exit
511coro_derive_padlist (pTHX_ CV *cv) 517coro_derive_padlist (pTHX_ CV *cv)
512{ 518{
513 PADLIST *padlist = CvPADLIST (cv); 519 PADLIST *padlist = CvPADLIST (cv);
514 PADLIST *newpadlist; 520 PADLIST *newpadlist;
515 PAD *newpad; 521 PAD *newpad;
516 PADOFFSET const off = PadlistMAX (padlist) + 1; 522 PADOFFSET off = PadlistMAX (padlist) + 1;
517 523
518 newPADLIST(newpadlist); 524#if NEWPADAPI
519#if !PERL_VERSION_ATLEAST(5,15,3) 525
520 /* Padlists are AvREAL as of 5.15.3. See perl bug #98092 and perl commit 7d953ba. */ 526 /* if we had the original CvDEPTH, we might be able to steal the CvDEPTH+1 entry instead */
521 AvREAL_off (newpadlist); 527 /* 20131102194744.GA6705@schmorp.de, 20131102195825.2013.qmail@lists-nntp.develooper.com */
522#endif 528 while (!PadlistARRAY (padlist)[off - 1])
529 --off;
530
531 Perl_pad_push (aTHX_ padlist, off);
532
533 newpad = PadlistARRAY (padlist)[off];
534 PadlistARRAY (padlist)[off] = 0;
535
536#else
537
523#if PERL_VERSION_ATLEAST (5,10,0) 538#if PERL_VERSION_ATLEAST (5,10,0)
524 Perl_pad_push (aTHX_ padlist, off); 539 Perl_pad_push (aTHX_ padlist, off);
525#else 540#else
526 Perl_pad_push (aTHX_ padlist, off, 1); 541 Perl_pad_push (aTHX_ padlist, off, 1);
527#endif 542#endif
543
528 newpad = PadlistARRAY (padlist)[off]; 544 newpad = PadlistARRAY (padlist)[off];
529 PadlistMAX (padlist) = off - 1; 545 PadlistMAX (padlist) = off - 1;
546
547#endif
548
549 newPADLIST (newpadlist);
550#if !PERL_VERSION_ATLEAST(5,15,3)
551 /* Padlists are AvREAL as of 5.15.3. See perl bug #98092 and perl commit 7d953ba. */
552 AvREAL_off (newpadlist);
553#endif
530 554
531 /* Already extended to 2 elements by newPADLIST. */ 555 /* Already extended to 2 elements by newPADLIST. */
532 PadlistMAX (newpadlist) = 1; 556 PadlistMAX (newpadlist) = 1;
533 PadlistNAMES (newpadlist) = (PADNAMELIST *)SvREFCNT_inc_NN (PadlistNAMES (padlist)); 557 PadlistNAMES (newpadlist) = (PADNAMELIST *)SvREFCNT_inc_NN (PadlistNAMES (padlist));
534 PadlistARRAY (newpadlist)[1] = newpad; 558 PadlistARRAY (newpadlist)[1] = newpad;
546 570
547 while (i > 0) /* special-case index 0 */ 571 while (i > 0) /* special-case index 0 */
548 { 572 {
549 /* we try to be extra-careful here */ 573 /* we try to be extra-careful here */
550 PAD *pad = PadlistARRAY (padlist)[i--]; 574 PAD *pad = PadlistARRAY (padlist)[i--];
575
576 if (pad)
577 {
551 I32 j = PadMAX (pad); 578 I32 j = PadMAX (pad);
552 579
553 while (j >= 0) 580 while (j >= 0)
554 SvREFCNT_dec (PadARRAY (pad)[j--]); 581 SvREFCNT_dec (PadARRAY (pad)[j--]);
555 582
556 PadMAX (pad) = -1; 583 PadMAX (pad) = -1;
557 SvREFCNT_dec (pad); 584 SvREFCNT_dec (pad);
585 }
558 } 586 }
559 587
560 SvREFCNT_dec (PadlistNAMES (padlist)); 588 SvREFCNT_dec (PadlistNAMES (padlist));
561 589
562#ifdef NEWPADAPI 590#if NEWPADAPI
563 Safefree (PadlistARRAY (padlist)); 591 Safefree (PadlistARRAY (padlist));
564 Safefree (padlist); 592 Safefree (padlist);
565#else 593#else
566 AvFILLp (padlist) = -1; 594 AvFILLp (padlist) = -1;
567 AvREAL_off (padlist); 595 AvREAL_off (padlist);
3151 /* it quickly returns */ 3179 /* it quickly returns */
3152 if (CORO_THROW) 3180 if (CORO_THROW)
3153 return 0; 3181 return 0;
3154 3182
3155 /* one element that is an RV? repeat! */ 3183 /* one element that is an RV? repeat! */
3156 if (AvFILLp (state) == 0 && SvROK (AvARRAY (state)[0])) 3184 if (AvFILLp (state) == 0 && SvTYPE (AvARRAY (state)[0]) != SVt_PV)
3157 return 1; 3185 return 1;
3158 3186
3159 /* restore status */ 3187 /* restore status */
3160 { 3188 {
3161 SV *data_sv = av_pop (state); 3189 SV *data_sv = av_pop (state);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines