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.54 by pcg, Sat Mar 13 06:45:04 2004 UTC vs.
Revision 1.56 by pcg, Thu Apr 1 02:41:05 2004 UTC

1#define PERL_NO_GET_CONTEXT
2
1#include "EXTERN.h" 3#include "EXTERN.h"
2#include "perl.h" 4#include "perl.h"
3#include "XSUB.h" 5#include "XSUB.h"
4 6
5#include "patchlevel.h" 7#include "patchlevel.h"
53 55
54#define labs(l) ((l) >= 0 ? (l) : -(l)) 56#define labs(l) ((l) >= 0 ? (l) : -(l))
55 57
56#include "CoroAPI.h" 58#include "CoroAPI.h"
57 59
60#ifdef USE_ITHREADS
61static perl_mutex coro_mutex;
62# define LOCK do { MUTEX_LOCK (&coro_mutex); } while (0)
63# define UNLOCK do { MUTEX_UNLOCK (&coro_mutex); } while (0)
64#else
65# define LOCK 0
66# define UNLOCK 0
67#endif
68
58static struct CoroAPI coroapi; 69static struct CoroAPI coroapi;
70static AV *main_mainstack; /* used to differentiate between $main and others */
71static HV *coro_state_stash;
72static SV *ucoro_state_sv;
73static U32 ucoro_state_hash;
74static __thread SV *coro_mortal; /* will be freed after next transfer */
59 75
60/* this is actually not only the c stack but also c registers etc... */ 76/* this is actually not only the c stack but also c registers etc... */
61typedef struct { 77typedef struct {
62 int refcnt; /* pointer reference counter */ 78 int refcnt; /* pointer reference counter */
63 int usecnt; /* shared by how many coroutines */ 79 int usecnt; /* shared by how many coroutines */
121}; 137};
122 138
123typedef struct coro *Coro__State; 139typedef struct coro *Coro__State;
124typedef struct coro *Coro__State_or_hashref; 140typedef struct coro *Coro__State_or_hashref;
125 141
126static AV *main_mainstack; /* used to differentiate between $main and others */
127static HV *coro_state_stash;
128static SV *ucoro_state_sv;
129static U32 ucoro_state_hash;
130static HV *padlist_cache;
131static SV *coro_mortal; /* will be freed after next transfer */
132
133/* mostly copied from op.c:cv_clone2 */ 142/* mostly copied from op.c:cv_clone2 */
134STATIC AV * 143STATIC AV *
135clone_padlist (AV *protopadlist) 144clone_padlist (pTHX_ AV *protopadlist)
136{ 145{
137 AV *av; 146 AV *av;
138 I32 ix; 147 I32 ix;
139 AV *protopad_name = (AV *) * av_fetch (protopadlist, 0, FALSE); 148 AV *protopad_name = (AV *) * av_fetch (protopadlist, 0, FALSE);
140 AV *protopad = (AV *) * av_fetch (protopadlist, 1, FALSE); 149 AV *protopad = (AV *) * av_fetch (protopadlist, 1, FALSE);
164 AvFLAGS (av) = AVf_REIFY; 173 AvFLAGS (av) = AVf_REIFY;
165 174
166 for (ix = fpad; ix > 0; ix--) 175 for (ix = fpad; ix > 0; ix--)
167 { 176 {
168 SV *namesv = (ix <= fname) ? pname[ix] : Nullsv; 177 SV *namesv = (ix <= fname) ? pname[ix] : Nullsv;
178
169 if (namesv && namesv != &PL_sv_undef) 179 if (namesv && namesv != &PL_sv_undef)
170 { 180 {
171 char *name = SvPVX (namesv); /* XXX */ 181 char *name = SvPVX (namesv); /* XXX */
182
172 if (SvFLAGS (namesv) & SVf_FAKE || *name == '&') 183 if (SvFLAGS (namesv) & SVf_FAKE || *name == '&')
173 { /* lexical from outside? */ 184 { /* lexical from outside? */
174 npad[ix] = SvREFCNT_inc (ppad[ix]); 185 npad[ix] = SvREFCNT_inc (ppad[ix]);
175 } 186 }
176 else 187 else
182 sv = (SV *) newAV (); 193 sv = (SV *) newAV ();
183 else if (*name == '%') 194 else if (*name == '%')
184 sv = (SV *) newHV (); 195 sv = (SV *) newHV ();
185 else 196 else
186 sv = NEWSV (0, 0); 197 sv = NEWSV (0, 0);
198
187#ifdef SvPADBUSY 199#ifdef SvPADBUSY
188 if (!SvPADBUSY (sv)) 200 if (!SvPADBUSY (sv))
189#endif 201#endif
190 SvPADMY_on (sv); 202 SvPADMY_on (sv);
203
191 npad[ix] = sv; 204 npad[ix] = sv;
192 } 205 }
193 } 206 }
194 else if (IS_PADGV (ppad[ix]) || IS_PADCONST (ppad[ix])) 207 else if (IS_PADGV (ppad[ix]) || IS_PADCONST (ppad[ix]))
195 { 208 {
225 238
226 return newpadlist; 239 return newpadlist;
227} 240}
228 241
229STATIC void 242STATIC void
230free_padlist (AV *padlist) 243free_padlist (pTHX_ AV *padlist)
231{ 244{
232 /* may be during global destruction */ 245 /* may be during global destruction */
233 if (SvREFCNT (padlist)) 246 if (SvREFCNT (padlist))
234 { 247 {
235 I32 i = AvFILLp (padlist); 248 I32 i = AvFILLp (padlist);
256 AV *padlist; 269 AV *padlist;
257 AV *av = (AV *)mg->mg_obj; 270 AV *av = (AV *)mg->mg_obj;
258 271
259 /* casting is fun. */ 272 /* casting is fun. */
260 while (&PL_sv_undef != (SV *)(padlist = (AV *)av_pop (av))) 273 while (&PL_sv_undef != (SV *)(padlist = (AV *)av_pop (av)))
261 free_padlist (padlist); 274 free_padlist (aTHX_ padlist);
262} 275}
263 276
264#define PERL_MAGIC_coro PERL_MAGIC_ext 277#define PERL_MAGIC_coro PERL_MAGIC_ext
265 278
266static MGVTBL vtbl_coro = {0, 0, 0, 0, coro_cv_free}; 279static MGVTBL vtbl_coro = {0, 0, 0, 0, coro_cv_free};
267 280
268/* the next two functions merely cache the padlists */ 281/* the next two functions merely cache the padlists */
269STATIC void 282STATIC void
270get_padlist (CV *cv) 283get_padlist (pTHX_ CV *cv)
271{ 284{
272 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro); 285 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro);
273 286
274 if (mg && AvFILLp ((AV *)mg->mg_obj) >= 0) 287 if (mg && AvFILLp ((AV *)mg->mg_obj) >= 0)
275 CvPADLIST (cv) = (AV *)av_pop ((AV *)mg->mg_obj); 288 CvPADLIST (cv) = (AV *)av_pop ((AV *)mg->mg_obj);
276 else 289 else
277 CvPADLIST (cv) = clone_padlist (CvPADLIST (cv)); 290 CvPADLIST (cv) = clone_padlist (aTHX_ CvPADLIST (cv));
278} 291}
279 292
280STATIC void 293STATIC void
281put_padlist (CV *cv) 294put_padlist (pTHX_ CV *cv)
282{ 295{
283 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro); 296 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro);
284 297
285 if (!mg) 298 if (!mg)
286 { 299 {
348 { 361 {
349 AV *padlist = (AV *)POPs; 362 AV *padlist = (AV *)POPs;
350 363
351 if (padlist) 364 if (padlist)
352 { 365 {
353 put_padlist (cv); /* mark this padlist as available */ 366 put_padlist (aTHX_ cv); /* mark this padlist as available */
354 CvPADLIST(cv) = padlist; 367 CvPADLIST(cv) = padlist;
355#ifdef USE_THREADS
356 /*CvOWNER(cv) = (struct perl_thread *)POPs;*/
357#endif
358 } 368 }
359 369
360 ++CvDEPTH(cv); 370 ++CvDEPTH(cv);
361 } 371 }
362 372
389 if (CxTYPE(cx) == CXt_SUB) 399 if (CxTYPE(cx) == CXt_SUB)
390 { 400 {
391 CV *cv = cx->blk_sub.cv; 401 CV *cv = cx->blk_sub.cv;
392 if (CvDEPTH(cv)) 402 if (CvDEPTH(cv))
393 { 403 {
394#ifdef USE_THREADS
395 /*XPUSHs ((SV *)CvOWNER(cv));*/
396 /*CvOWNER(cv) = 0;*/
397 /*error must unlock this cv etc.. etc...*/
398#endif
399 EXTEND (SP, CvDEPTH(cv)*2); 404 EXTEND (SP, CvDEPTH(cv)*2);
400 405
401 while (--CvDEPTH(cv)) 406 while (--CvDEPTH(cv))
402 { 407 {
403 /* this tells the restore code to increment CvDEPTH */ 408 /* this tells the restore code to increment CvDEPTH */
406 } 411 }
407 412
408 PUSHs ((SV *)CvPADLIST(cv)); 413 PUSHs ((SV *)CvPADLIST(cv));
409 PUSHs ((SV *)cv); 414 PUSHs ((SV *)cv);
410 415
411 get_padlist (cv); /* this is a monster */ 416 get_padlist (aTHX_ cv); /* this is a monster */
412 } 417 }
413 } 418 }
414#ifdef CXt_FORMAT 419#ifdef CXt_FORMAT
415 else if (CxTYPE(cx) == CXt_FORMAT) 420 else if (CxTYPE(cx) == CXt_FORMAT)
416 { 421 {
475 * not usually need a lot of stackspace. 480 * not usually need a lot of stackspace.
476 */ 481 */
477STATIC void 482STATIC void
478coro_init_stacks (pTHX) 483coro_init_stacks (pTHX)
479{ 484{
485 LOCK;
486
480 PL_curstackinfo = new_stackinfo(96, 1024/sizeof(PERL_CONTEXT) - 1); 487 PL_curstackinfo = new_stackinfo(96, 1024/sizeof(PERL_CONTEXT) - 1);
481 PL_curstackinfo->si_type = PERLSI_MAIN; 488 PL_curstackinfo->si_type = PERLSI_MAIN;
482 PL_curstack = PL_curstackinfo->si_stack; 489 PL_curstack = PL_curstackinfo->si_stack;
483 PL_mainstack = PL_curstack; /* remember in case we switch stacks */ 490 PL_mainstack = PL_curstack; /* remember in case we switch stacks */
484 491
508 PL_savestack_max = 96; 515 PL_savestack_max = 96;
509 516
510 New(54,PL_retstack,8,OP*); 517 New(54,PL_retstack,8,OP*);
511 PL_retstack_ix = 0; 518 PL_retstack_ix = 0;
512 PL_retstack_max = 8; 519 PL_retstack_max = 8;
520
521 UNLOCK;
513} 522}
514 523
515/* 524/*
516 * destroy the stacks, the callchain etc... 525 * destroy the stacks, the callchain etc...
517 */ 526 */
566 New (0, stack, 1, coro_stack); 575 New (0, stack, 1, coro_stack);
567 576
568 stack->refcnt = 1; 577 stack->refcnt = 1;
569 stack->usecnt = 1; 578 stack->usecnt = 1;
570 stack->gencnt = ctx->gencnt = 0; 579 stack->gencnt = ctx->gencnt = 0;
580
571 if (alloc) 581 if (alloc)
572 { 582 {
573#if HAVE_MMAP 583#if HAVE_MMAP
574 stack->ssize = 16384 * sizeof (long); /* mmap should do allocate-on-write for us */ 584 stack->ssize = 16384 * sizeof (long); /* mmap should do allocate-on-write for us */
575 stack->sptr = mmap (0, stack->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); 585 stack->sptr = mmap (0, stack->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
616setup_coro (void *arg) 626setup_coro (void *arg)
617{ 627{
618 /* 628 /*
619 * emulate part of the perl startup here. 629 * emulate part of the perl startup here.
620 */ 630 */
631 dTHX;
621 dSP; 632 dSP;
622 Coro__State ctx = (Coro__State)arg; 633 Coro__State ctx = (Coro__State)arg;
623 SV *sub_init = (SV *)get_cv (SUB_INIT, FALSE); 634 SV *sub_init = (SV *)get_cv (SUB_INIT, FALSE);
624 635
625 coro_init_stacks (aTHX); 636 coro_init_stacks (aTHX);
674continue_coro (void *arg) 685continue_coro (void *arg)
675{ 686{
676 /* 687 /*
677 * this is a _very_ stripped down perl interpreter ;) 688 * this is a _very_ stripped down perl interpreter ;)
678 */ 689 */
690 dTHX;
679 Coro__State ctx = (Coro__State)arg; 691 Coro__State ctx = (Coro__State)arg;
680 JMPENV coro_start_env; 692 JMPENV coro_start_env;
681 693
682 PL_top_env = &ctx->start_env; 694 PL_top_env = &ctx->start_env;
683 695
687 699
688 abort (); 700 abort ();
689} 701}
690 702
691STATIC void 703STATIC void
692transfer(pTHX_ struct coro *prev, struct coro *next, int flags) 704transfer (pTHX_ struct coro *prev, struct coro *next, int flags)
693{ 705{
694 dSTACKLEVEL; 706 dSTACKLEVEL;
695 static struct coro *xnext;
696 707
697 if (prev != next) 708 if (prev != next)
698 { 709 {
699 xnext = next;
700
701 if (next->mainstack) 710 if (next->mainstack)
702 { 711 {
712 LOCK;
703 SAVE (prev, flags); 713 SAVE (prev, flags);
704 LOAD (next); 714 LOAD (next);
715 UNLOCK;
705 716
706 /* mark this state as in-use */ 717 /* mark this state as in-use */
707 next->mainstack = 0; 718 next->mainstack = 0;
708 next->tmps_ix = -2; 719 next->tmps_ix = -2;
709 720
728 continue_coro, (void *)next, 739 continue_coro, (void *)next,
729 next->stack->sptr, labs (next->stack->ssize)); 740 next->stack->sptr, labs (next->stack->ssize));
730 } 741 }
731 742
732 coro_transfer (&(prev->stack->cctx), &(next->stack->cctx)); 743 coro_transfer (&(prev->stack->cctx), &(next->stack->cctx));
744 prev->cursp = stacklevel;
733 /* don't add any code here */ 745 /* don't add any code here */
734 } 746 }
735 747 else
748 next->cursp = stacklevel;
736 } 749 }
737 else if (next->tmps_ix == -2) 750 else if (next->tmps_ix == -2)
738 croak ("tried to transfer to running coroutine"); 751 croak ("tried to transfer to running coroutine");
739 else 752 else
740 { 753 {
754 LOCK;
741 SAVE (prev, -1); /* first get rid of the old state */ 755 SAVE (prev, -1); /* first get rid of the old state */
756 UNLOCK;
742 757
743 if (flags & TRANSFER_SAVE_CCTXT) 758 if (flags & TRANSFER_SAVE_CCTXT)
744 { 759 {
745 if (!prev->stack) 760 if (!prev->stack)
746 allocate_stack (prev, 0); 761 allocate_stack (prev, 0);
748 if (prev->stack->sptr && flags & TRANSFER_LAZY_STACK) 763 if (prev->stack->sptr && flags & TRANSFER_LAZY_STACK)
749 { 764 {
750 PL_top_env = &next->start_env; 765 PL_top_env = &next->start_env;
751 766
752 setup_coro (next); 767 setup_coro (next);
768 next->cursp = stacklevel;
753 769
754 prev->stack->refcnt++; 770 prev->stack->refcnt++;
755 prev->stack->usecnt++; 771 prev->stack->usecnt++;
756 next->stack = prev->stack; 772 next->stack = prev->stack;
757 next->gencnt = prev->gencnt; 773 next->gencnt = prev->gencnt;
762 allocate_stack (next, 1); 778 allocate_stack (next, 1);
763 coro_create (&(next->stack->cctx), 779 coro_create (&(next->stack->cctx),
764 setup_coro, (void *)next, 780 setup_coro, (void *)next,
765 next->stack->sptr, labs (next->stack->ssize)); 781 next->stack->sptr, labs (next->stack->ssize));
766 coro_transfer (&(prev->stack->cctx), &(next->stack->cctx)); 782 coro_transfer (&(prev->stack->cctx), &(next->stack->cctx));
783 prev->cursp = stacklevel;
767 /* don't add any code here */ 784 /* don't add any code here */
768 } 785 }
769 } 786 }
770 else 787 else
788 {
771 setup_coro (next); 789 setup_coro (next);
790 next->cursp = stacklevel;
791 }
772 } 792 }
773
774 /*
775 * xnext is now either prev or next, depending on wether
776 * we switched the c stack or not. that's why I use a global
777 * variable, that should become thread-specific at one point.
778 */
779 xnext->cursp = stacklevel;
780 } 793 }
781 794
795 LOCK;
782 if (coro_mortal) 796 if (coro_mortal)
783 { 797 {
784 SvREFCNT_dec (coro_mortal); 798 SvREFCNT_dec (coro_mortal);
785 coro_mortal = 0; 799 coro_mortal = 0;
786 } 800 }
801 UNLOCK;
787} 802}
788 803
789#define SV_CORO(sv,func) \ 804#define SV_CORO(sv,func) \
790 do { \ 805 do { \
791 if (SvROK (sv)) \ 806 if (SvROK (sv)) \
792 sv = SvRV (sv); \ 807 sv = SvRV (sv); \
793 \ 808 \
794 if (SvTYPE(sv) == SVt_PVHV) \ 809 if (SvTYPE (sv) == SVt_PVHV) \
795 { \ 810 { \
796 HE *he = hv_fetch_ent((HV *)sv, ucoro_state_sv, 0, ucoro_state_hash); \ 811 HE *he = hv_fetch_ent ((HV *)sv, ucoro_state_sv, 0, ucoro_state_hash); \
797 \ 812 \
798 if (!he) \ 813 if (!he) \
799 croak ("%s() -- %s is a hashref but lacks the " UCORO_STATE " key", func, # sv); \ 814 croak ("%s() -- %s is a hashref but lacks the " UCORO_STATE " key", func, # sv); \
800 \ 815 \
801 (sv) = SvRV (HeVAL(he)); \ 816 (sv) = SvRV (HeVAL(he)); \
802 } \ 817 } \
803 \ 818 \
804 /* must also be changed inside Coro::Cont::yield */ \ 819 /* must also be changed inside Coro::Cont::yield */ \
805 if (!SvOBJECT(sv) || SvSTASH(sv) != coro_state_stash) \ 820 if (!SvOBJECT (sv) || SvSTASH (sv) != coro_state_stash) \
806 croak ("%s() -- %s is not (and contains not) a Coro::State object", func, # sv); \ 821 croak ("%s() -- %s is not (and contains not) a Coro::State object", func, # sv); \
807 \ 822 \
808 } while(0) 823 } while(0)
809 824
810#define SvSTATE(sv) (struct coro *)SvIV (sv) 825#define SvSTATE(sv) (struct coro *)SvIV (sv)
813api_transfer(pTHX_ SV *prev, SV *next, int flags) 828api_transfer(pTHX_ SV *prev, SV *next, int flags)
814{ 829{
815 SV_CORO (prev, "Coro::transfer"); 830 SV_CORO (prev, "Coro::transfer");
816 SV_CORO (next, "Coro::transfer"); 831 SV_CORO (next, "Coro::transfer");
817 832
818 transfer(aTHX_ SvSTATE(prev), SvSTATE(next), flags); 833 transfer (aTHX_ SvSTATE (prev), SvSTATE (next), flags);
819} 834}
820 835
821/** Coro ********************************************************************/ 836/** Coro ********************************************************************/
822 837
823#define PRIO_MAX 3 838#define PRIO_MAX 3
831static GV *coro_current, *coro_idle; 846static GV *coro_current, *coro_idle;
832static AV *coro_ready[PRIO_MAX-PRIO_MIN+1]; 847static AV *coro_ready[PRIO_MAX-PRIO_MIN+1];
833static int coro_nready; 848static int coro_nready;
834 849
835static void 850static void
836coro_enq (SV *sv) 851coro_enq (pTHX_ SV *sv)
837{ 852{
838 if (SvTYPE (sv) == SVt_PVHV) 853 if (SvTYPE (sv) == SVt_PVHV)
839 { 854 {
840 SV **xprio = hv_fetch ((HV *)sv, "prio", 4, 0); 855 SV **xprio = hv_fetch ((HV *)sv, "prio", 4, 0);
841 int prio = xprio ? SvIV (*xprio) : PRIO_NORMAL; 856 int prio = xprio ? SvIV (*xprio) : PRIO_NORMAL;
852 867
853 croak ("Coro::ready tried to enqueue something that is not a coroutine"); 868 croak ("Coro::ready tried to enqueue something that is not a coroutine");
854} 869}
855 870
856static SV * 871static SV *
857coro_deq (int min_prio) 872coro_deq (pTHX_ int min_prio)
858{ 873{
859 int prio = PRIO_MAX - PRIO_MIN; 874 int prio = PRIO_MAX - PRIO_MIN;
860 875
861 min_prio -= PRIO_MIN; 876 min_prio -= PRIO_MIN;
862 if (min_prio < 0) 877 if (min_prio < 0)
873} 888}
874 889
875static void 890static void
876api_ready (SV *coro) 891api_ready (SV *coro)
877{ 892{
893 dTHX;
894
878 if (SvROK (coro)) 895 if (SvROK (coro))
879 coro = SvRV (coro); 896 coro = SvRV (coro);
880 897
898 LOCK;
881 coro_enq (SvREFCNT_inc (coro)); 899 coro_enq (aTHX_ SvREFCNT_inc (coro));
900 UNLOCK;
882} 901}
883 902
884static void 903static void
885api_schedule (void) 904api_schedule (void)
886{ 905{
906 dTHX;
907
887 SV *prev, *next; 908 SV *prev, *next;
888 909
910 LOCK;
911
889 prev = SvRV (GvSV (coro_current)); 912 prev = SvRV (GvSV (coro_current));
890 next = coro_deq (PRIO_MIN); 913 next = coro_deq (aTHX_ PRIO_MIN);
891 914
892 if (!next) 915 if (!next)
893 next = SvREFCNT_inc (SvRV (GvSV (coro_idle))); 916 next = SvREFCNT_inc (SvRV (GvSV (coro_idle)));
894 917
895 /* free this only after the transfer */ 918 /* free this only after the transfer */
898 921
899 SvRV (GvSV (coro_current)) = next; 922 SvRV (GvSV (coro_current)) = next;
900 923
901 SV_CORO (next, "Coro::schedule"); 924 SV_CORO (next, "Coro::schedule");
902 925
926 UNLOCK;
927
903 transfer (aTHX_ SvSTATE (prev), SvSTATE (next), 928 transfer (aTHX_ SvSTATE (prev), SvSTATE (next),
904 TRANSFER_SAVE_ALL | TRANSFER_LAZY_STACK); 929 TRANSFER_SAVE_ALL | TRANSFER_LAZY_STACK);
905} 930}
906 931
907static void 932static void
908api_cede (void) 933api_cede (void)
909{ 934{
935 dTHX;
936
937 LOCK;
910 coro_enq (SvREFCNT_inc (SvRV (GvSV (coro_current)))); 938 coro_enq (aTHX_ SvREFCNT_inc (SvRV (GvSV (coro_current))));
939 UNLOCK;
911 940
912 api_schedule (); 941 api_schedule ();
913} 942}
914 943
915MODULE = Coro::State PACKAGE = Coro::State 944MODULE = Coro::State PACKAGE = Coro::State
916 945
917PROTOTYPES: ENABLE 946PROTOTYPES: ENABLE
918 947
919BOOT: 948BOOT:
920{ /* {} necessary for stoopid perl-5.6.x */ 949{ /* {} necessary for stoopid perl-5.6.x */
950#ifdef USE_ITHREADS
951 MUTEX_INIT (&coro_mutex);
952#endif
953
921 ucoro_state_sv = newSVpv (UCORO_STATE, sizeof(UCORO_STATE) - 1); 954 ucoro_state_sv = newSVpv (UCORO_STATE, sizeof(UCORO_STATE) - 1);
922 PERL_HASH(ucoro_state_hash, UCORO_STATE, sizeof(UCORO_STATE) - 1); 955 PERL_HASH(ucoro_state_hash, UCORO_STATE, sizeof(UCORO_STATE) - 1);
923 coro_state_stash = gv_stashpv ("Coro::State", TRUE); 956 coro_state_stash = gv_stashpv ("Coro::State", TRUE);
924 957
925 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (TRANSFER_SAVE_DEFAV)); 958 newCONSTSUB (coro_state_stash, "SAVE_DEFAV", newSViv (TRANSFER_SAVE_DEFAV));
926 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (TRANSFER_SAVE_DEFSV)); 959 newCONSTSUB (coro_state_stash, "SAVE_DEFSV", newSViv (TRANSFER_SAVE_DEFSV));
927 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (TRANSFER_SAVE_ERRSV)); 960 newCONSTSUB (coro_state_stash, "SAVE_ERRSV", newSViv (TRANSFER_SAVE_ERRSV));
928 newCONSTSUB (coro_state_stash, "SAVE_CCTXT", newSViv (TRANSFER_SAVE_CCTXT)); 961 newCONSTSUB (coro_state_stash, "SAVE_CCTXT", newSViv (TRANSFER_SAVE_CCTXT));
929
930 if (!padlist_cache)
931 padlist_cache = newHV ();
932 962
933 main_mainstack = PL_mainstack; 963 main_mainstack = PL_mainstack;
934 964
935 coroapi.ver = CORO_API_VERSION; 965 coroapi.ver = CORO_API_VERSION;
936 coroapi.transfer = api_transfer; 966 coroapi.transfer = api_transfer;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines