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.89 by root, Sat Nov 25 00:40:26 2006 UTC vs.
Revision 1.106 by root, Mon Nov 27 02:08:55 2006 UTC

1#define PERL_NO_GET_CONTEXT
2
3#include "libcoro/coro.c" 1#include "libcoro/coro.c"
4 2
5#include "EXTERN.h" 3#include "EXTERN.h"
6#include "perl.h" 4#include "perl.h"
7#include "XSUB.h" 5#include "XSUB.h"
8 6
9#include "patchlevel.h" 7#include "patchlevel.h"
10 8
11#if PERL_VERSION < 6 9#if USE_VALGRIND
10# include <valgrind/valgrind.h>
11#endif
12
13#define PERL_VERSION_ATLEAST(a,b,c) \
14 (PERL_REVISION > (a) \
15 || (PERL_REVISION == (a) \
16 && (PERL_VERSION > (b) \
17 || (PERL_VERSION == (b) && PERLSUBVERSION >= (c)))))
18
19#if !PERL_VERSION_ATLEAST (5,6,0)
12# ifndef PL_ppaddr 20# ifndef PL_ppaddr
13# define PL_ppaddr ppaddr 21# define PL_ppaddr ppaddr
14# endif 22# endif
15# ifndef call_sv 23# ifndef call_sv
16# define call_sv perl_call_sv 24# define call_sv perl_call_sv
27# ifndef IS_PADCONST 35# ifndef IS_PADCONST
28# define IS_PADCONST(v) 0 36# define IS_PADCONST(v) 0
29# endif 37# endif
30#endif 38#endif
31 39
40#include <stdio.h>
32#include <errno.h> 41#include <errno.h>
33 42
34#if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64 43#if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64
35# undef STACKGUARD 44# undef STACKGUARD
36#endif 45#endif
53# ifndef PAGESIZE 62# ifndef PAGESIZE
54# define PAGESIZE pagesize 63# define PAGESIZE pagesize
55# define BOOT_PAGESIZE pagesize = sysconf (_SC_PAGESIZE) 64# define BOOT_PAGESIZE pagesize = sysconf (_SC_PAGESIZE)
56static long pagesize; 65static long pagesize;
57# else 66# else
58# define BOOT_PAGESIZE 67# define BOOT_PAGESIZE (void)0
59# endif 68# endif
69#else
70# define PAGESIZE 0
71# define BOOT_PAGESIZE (void)0
60#endif 72#endif
61
62#define SUB_INIT "Coro::State::initialize"
63 73
64/* The next macro should declare a variable stacklevel that contains and approximation 74/* The next macro should declare a variable stacklevel that contains and approximation
65 * to the current C stack pointer. Its property is that it changes with each call 75 * to the current C stack pointer. Its property is that it changes with each call
66 * and should be unique. */ 76 * and should be unique. */
77#define dSTACKLEVEL int stacklevel
67#define dSTACKLEVEL void *stacklevel = &stacklevel 78#define STACKLEVEL ((void *)&stacklevel)
68 79
69#define IN_DESTRUCT (PL_main_cv == Nullcv) 80#define IN_DESTRUCT (PL_main_cv == Nullcv)
70 81
71#define labs(l) ((l) >= 0 ? (l) : -(l)) 82#if __GNUC__ >= 3
83# define attribute(x) __attribute__(x)
84#else
85# define attribute(x)
86#endif
87
88#define NOINLINE attribute ((noinline))
72 89
73#include "CoroAPI.h" 90#include "CoroAPI.h"
91
92#define TRANSFER_SET_STACKLEVEL 0x8bfbfbfb /* magic cookie */
74 93
75#ifdef USE_ITHREADS 94#ifdef USE_ITHREADS
76static perl_mutex coro_mutex; 95static perl_mutex coro_mutex;
77# define LOCK do { MUTEX_LOCK (&coro_mutex); } while (0) 96# define LOCK do { MUTEX_LOCK (&coro_mutex); } while (0)
78# define UNLOCK do { MUTEX_UNLOCK (&coro_mutex); } while (0) 97# define UNLOCK do { MUTEX_UNLOCK (&coro_mutex); } while (0)
84static struct CoroAPI coroapi; 103static struct CoroAPI coroapi;
85static AV *main_mainstack; /* used to differentiate between $main and others */ 104static AV *main_mainstack; /* used to differentiate between $main and others */
86static HV *coro_state_stash, *coro_stash; 105static HV *coro_state_stash, *coro_stash;
87static SV *coro_mortal; /* will be freed after next transfer */ 106static SV *coro_mortal; /* will be freed after next transfer */
88 107
89/* this is actually not just the c stack but also c registers etc... */ 108/* this is a structure representing a c-level coroutine */
90typedef struct coro_stack { 109typedef struct coro_cctx {
91 struct coro_stack *next; 110 struct coro_cctx *next;
92 111
93 void *idle_sp; 112 /* the stack */
94 void *sptr; 113 void *sptr;
95 long ssize; /* positive == mmap, otherwise malloc */ 114 long ssize; /* positive == mmap, otherwise malloc */
96 115
97 /* cpu state */ 116 /* cpu state */
117 void *idle_sp; /* sp of top-level transfer/schedule/cede call */
118 JMPENV *top_env;
98 coro_context cctx; 119 coro_context cctx;
99} coro_stack;
100 120
101static coro_stack *main_stack; 121#if USE_VALGRIND
122 int valgrind_id;
123#endif
124} coro_cctx;
102 125
126/* this is a structure representing a perl-level coroutine */
103struct coro { 127struct coro {
128 /* the c coroutine allocated to this perl coroutine, if any */
129 coro_cctx *cctx;
130
131 /* data associated with this coroutine (initial args) */
132 AV *args;
133 int refcnt;
134
104 /* optionally saved, might be zero */ 135 /* optionally saved, might be zero */
105 AV *defav; 136 AV *defav;
106 SV *defsv; 137 SV *defsv;
107 SV *errsv; 138 SV *errsv;
108 139
109 /* saved global state not related to stacks */ 140 /* saved global state not related to stacks */
110 U8 dowarn; 141 U8 dowarn;
111 I32 in_eval; 142 I32 in_eval;
112
113 /* the c stack, if any */
114 coro_stack *stack;
115 143
116 /* the stacks and related info (callchain etc..) */ 144 /* the stacks and related info (callchain etc..) */
117 PERL_SI *curstackinfo; 145 PERL_SI *curstackinfo;
118 AV *curstack; 146 AV *curstack;
119 AV *mainstack; 147 AV *mainstack;
140 OP **retstack; 168 OP **retstack;
141 I32 retstack_ix; 169 I32 retstack_ix;
142 I32 retstack_max; 170 I32 retstack_max;
143 PMOP *curpm; 171 PMOP *curpm;
144 COP *curcop; 172 COP *curcop;
145 JMPENV *top_env;
146 173
147 /* coro process data */ 174 /* coro process data */
148 int prio; 175 int prio;
149
150 /* data associated with this coroutine (initial args) */
151 AV *args;
152 int refcnt;
153}; 176};
154 177
155typedef struct coro *Coro__State; 178typedef struct coro *Coro__State;
156typedef struct coro *Coro__State_or_hashref; 179typedef struct coro *Coro__State_or_hashref;
157 180
158static AV * 181static AV *
159coro_clone_padlist (pTHX_ CV *cv) 182coro_clone_padlist (CV *cv)
160{ 183{
161 AV *padlist = CvPADLIST (cv); 184 AV *padlist = CvPADLIST (cv);
162 AV *newpadlist, *newpad; 185 AV *newpadlist, *newpad;
163 186
164 newpadlist = newAV (); 187 newpadlist = newAV ();
165 AvREAL_off (newpadlist); 188 AvREAL_off (newpadlist);
166#if PERL_VERSION < 9 189#if PERL_VERSION_ATLEAST (5,9,0)
190 Perl_pad_push (aTHX_ padlist, AvFILLp (padlist) + 1);
191#else
167 Perl_pad_push (aTHX_ padlist, AvFILLp (padlist) + 1, 1); 192 Perl_pad_push (aTHX_ padlist, AvFILLp (padlist) + 1, 1);
168#else
169 Perl_pad_push (aTHX_ padlist, AvFILLp (padlist) + 1);
170#endif 193#endif
171 newpad = (AV *)AvARRAY (padlist)[AvFILLp (padlist)]; 194 newpad = (AV *)AvARRAY (padlist)[AvFILLp (padlist)];
172 --AvFILLp (padlist); 195 --AvFILLp (padlist);
173 196
174 av_store (newpadlist, 0, SvREFCNT_inc (*av_fetch (padlist, 0, FALSE))); 197 av_store (newpadlist, 0, SvREFCNT_inc (*av_fetch (padlist, 0, FALSE)));
176 199
177 return newpadlist; 200 return newpadlist;
178} 201}
179 202
180static void 203static void
181free_padlist (pTHX_ AV *padlist) 204free_padlist (AV *padlist)
182{ 205{
183 /* may be during global destruction */ 206 /* may be during global destruction */
184 if (SvREFCNT (padlist)) 207 if (SvREFCNT (padlist))
185 { 208 {
186 I32 i = AvFILLp (padlist); 209 I32 i = AvFILLp (padlist);
207 AV *padlist; 230 AV *padlist;
208 AV *av = (AV *)mg->mg_obj; 231 AV *av = (AV *)mg->mg_obj;
209 232
210 /* casting is fun. */ 233 /* casting is fun. */
211 while (&PL_sv_undef != (SV *)(padlist = (AV *)av_pop (av))) 234 while (&PL_sv_undef != (SV *)(padlist = (AV *)av_pop (av)))
212 free_padlist (aTHX_ padlist); 235 free_padlist (padlist);
213 236
214 SvREFCNT_dec (av); 237 SvREFCNT_dec (av);
215 238
216 return 0; 239 return 0;
217} 240}
220 243
221static MGVTBL vtbl_coro = {0, 0, 0, 0, coro_cv_free}; 244static MGVTBL vtbl_coro = {0, 0, 0, 0, coro_cv_free};
222 245
223/* the next two functions merely cache the padlists */ 246/* the next two functions merely cache the padlists */
224static void 247static void
225get_padlist (pTHX_ CV *cv) 248get_padlist (CV *cv)
226{ 249{
227 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro); 250 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro);
228 251
229 if (mg && AvFILLp ((AV *)mg->mg_obj) >= 0) 252 if (mg && AvFILLp ((AV *)mg->mg_obj) >= 0)
230 CvPADLIST (cv) = (AV *)av_pop ((AV *)mg->mg_obj); 253 CvPADLIST (cv) = (AV *)av_pop ((AV *)mg->mg_obj);
231 else 254 else
232 { 255 {
233#if 0 256#if 0
234 /* this should work - but it doesn't :( */ 257 /* this is probably cleaner, but also slower? */
235 CV *cp = Perl_cv_clone (aTHX_ cv); 258 CV *cp = Perl_cv_clone (cv);
236 CvPADLIST (cv) = CvPADLIST (cp); 259 CvPADLIST (cv) = CvPADLIST (cp);
237 CvPADLIST (cp) = 0; 260 CvPADLIST (cp) = 0;
238 SvREFCNT_dec (cp); 261 SvREFCNT_dec (cp);
239#else 262#else
240 CvPADLIST (cv) = coro_clone_padlist (aTHX_ cv); 263 CvPADLIST (cv) = coro_clone_padlist (cv);
241#endif 264#endif
242 } 265 }
243} 266}
244 267
245static void 268static void
246put_padlist (pTHX_ CV *cv) 269put_padlist (CV *cv)
247{ 270{
248 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro); 271 MAGIC *mg = mg_find ((SV *)cv, PERL_MAGIC_coro);
249 272
250 if (!mg) 273 if (!mg)
251 { 274 {
259} 282}
260 283
261#define SB do { 284#define SB do {
262#define SE } while (0) 285#define SE } while (0)
263 286
264#define LOAD(state) load_state(aTHX_ (state)); 287#define LOAD(state) load_state((state));
265#define SAVE(state,flags) save_state(aTHX_ (state),(flags)); 288#define SAVE(state,flags) save_state((state),(flags));
266 289
267#define REPLACE_SV(sv,val) SB SvREFCNT_dec(sv); (sv) = (val); (val) = 0; SE 290#define REPLACE_SV(sv,val) SB SvREFCNT_dec(sv); (sv) = (val); (val) = 0; SE
268 291
269static void 292static void
270load_state(pTHX_ Coro__State c) 293load_state(Coro__State c)
271{ 294{
272 PL_dowarn = c->dowarn; 295 PL_dowarn = c->dowarn;
273 PL_in_eval = c->in_eval; 296 PL_in_eval = c->in_eval;
274 297
275 PL_curstackinfo = c->curstackinfo; 298 PL_curstackinfo = c->curstackinfo;
293 PL_scopestack_ix = c->scopestack_ix; 316 PL_scopestack_ix = c->scopestack_ix;
294 PL_scopestack_max = c->scopestack_max; 317 PL_scopestack_max = c->scopestack_max;
295 PL_savestack = c->savestack; 318 PL_savestack = c->savestack;
296 PL_savestack_ix = c->savestack_ix; 319 PL_savestack_ix = c->savestack_ix;
297 PL_savestack_max = c->savestack_max; 320 PL_savestack_max = c->savestack_max;
298#if PERL_VERSION < 9 321#if !PERL_VERSION_ATLEAST (5,9,0)
299 PL_retstack = c->retstack; 322 PL_retstack = c->retstack;
300 PL_retstack_ix = c->retstack_ix; 323 PL_retstack_ix = c->retstack_ix;
301 PL_retstack_max = c->retstack_max; 324 PL_retstack_max = c->retstack_max;
302#endif 325#endif
303 PL_curpm = c->curpm; 326 PL_curpm = c->curpm;
304 PL_curcop = c->curcop; 327 PL_curcop = c->curcop;
305 PL_top_env = c->top_env;
306 328
307 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav); 329 if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav);
308 if (c->defsv) REPLACE_SV (DEFSV , c->defsv); 330 if (c->defsv) REPLACE_SV (DEFSV , c->defsv);
309 if (c->errsv) REPLACE_SV (ERRSV , c->errsv); 331 if (c->errsv) REPLACE_SV (ERRSV , c->errsv);
310 332
317 { 339 {
318 AV *padlist = (AV *)POPs; 340 AV *padlist = (AV *)POPs;
319 341
320 if (padlist) 342 if (padlist)
321 { 343 {
322 put_padlist (aTHX_ cv); /* mark this padlist as available */ 344 put_padlist (cv); /* mark this padlist as available */
323 CvPADLIST(cv) = padlist; 345 CvPADLIST(cv) = padlist;
324 } 346 }
325 347
326 ++CvDEPTH(cv); 348 ++CvDEPTH(cv);
327 } 349 }
329 PUTBACK; 351 PUTBACK;
330 } 352 }
331} 353}
332 354
333static void 355static void
334save_state(pTHX_ Coro__State c, int flags) 356save_state(Coro__State c, int flags)
335{ 357{
336 { 358 {
337 dSP; 359 dSP;
338 I32 cxix = cxstack_ix; 360 I32 cxix = cxstack_ix;
339 PERL_CONTEXT *ccstk = cxstack; 361 PERL_CONTEXT *ccstk = cxstack;
367 } 389 }
368 390
369 PUSHs ((SV *)CvPADLIST(cv)); 391 PUSHs ((SV *)CvPADLIST(cv));
370 PUSHs ((SV *)cv); 392 PUSHs ((SV *)cv);
371 393
372 get_padlist (aTHX_ cv); 394 get_padlist (cv);
373 } 395 }
374 } 396 }
375#ifdef CXt_FORMAT 397#ifdef CXt_FORMAT
376 else if (CxTYPE(cx) == CXt_FORMAT) 398 else if (CxTYPE(cx) == CXt_FORMAT)
377 { 399 {
421 c->scopestack_ix = PL_scopestack_ix; 443 c->scopestack_ix = PL_scopestack_ix;
422 c->scopestack_max = PL_scopestack_max; 444 c->scopestack_max = PL_scopestack_max;
423 c->savestack = PL_savestack; 445 c->savestack = PL_savestack;
424 c->savestack_ix = PL_savestack_ix; 446 c->savestack_ix = PL_savestack_ix;
425 c->savestack_max = PL_savestack_max; 447 c->savestack_max = PL_savestack_max;
426#if PERL_VERSION < 9 448#if !PERL_VERSION_ATLEAST (5,9,0)
427 c->retstack = PL_retstack; 449 c->retstack = PL_retstack;
428 c->retstack_ix = PL_retstack_ix; 450 c->retstack_ix = PL_retstack_ix;
429 c->retstack_max = PL_retstack_max; 451 c->retstack_max = PL_retstack_max;
430#endif 452#endif
431 c->curpm = PL_curpm; 453 c->curpm = PL_curpm;
432 c->curcop = PL_curcop; 454 c->curcop = PL_curcop;
433 c->top_env = PL_top_env;
434} 455}
435 456
436/* 457/*
437 * allocate various perl stacks. This is an exact copy 458 * allocate various perl stacks. This is an exact copy
438 * of perl.c:init_stacks, except that it uses less memory 459 * of perl.c:init_stacks, except that it uses less memory
439 * on the (sometimes correct) assumption that coroutines do 460 * on the (sometimes correct) assumption that coroutines do
440 * not usually need a lot of stackspace. 461 * not usually need a lot of stackspace.
441 */ 462 */
442static void 463static void
443coro_init_stacks (pTHX) 464coro_init_stacks ()
444{ 465{
445 LOCK;
446
447 PL_curstackinfo = new_stackinfo(96, 1024/sizeof(PERL_CONTEXT) - 1); 466 PL_curstackinfo = new_stackinfo(96, 1024/sizeof(PERL_CONTEXT) - 1);
448 PL_curstackinfo->si_type = PERLSI_MAIN; 467 PL_curstackinfo->si_type = PERLSI_MAIN;
449 PL_curstack = PL_curstackinfo->si_stack; 468 PL_curstack = PL_curstackinfo->si_stack;
450 PL_mainstack = PL_curstack; /* remember in case we switch stacks */ 469 PL_mainstack = PL_curstack; /* remember in case we switch stacks */
451 470
472 491
473 New(54,PL_savestack,96,ANY); 492 New(54,PL_savestack,96,ANY);
474 PL_savestack_ix = 0; 493 PL_savestack_ix = 0;
475 PL_savestack_max = 96; 494 PL_savestack_max = 96;
476 495
477#if PERL_VERSION < 9 496#if !PERL_VERSION_ATLEAST (5,9,0)
478 New(54,PL_retstack,8,OP*); 497 New(54,PL_retstack,8,OP*);
479 PL_retstack_ix = 0; 498 PL_retstack_ix = 0;
480 PL_retstack_max = 8; 499 PL_retstack_max = 8;
481#endif 500#endif
482
483 UNLOCK;
484} 501}
485 502
486/* 503/*
487 * destroy the stacks, the callchain etc... 504 * destroy the stacks, the callchain etc...
488 */ 505 */
489static void 506static void
490destroy_stacks(pTHX) 507coro_destroy_stacks ()
491{ 508{
492 if (!IN_DESTRUCT) 509 if (!IN_DESTRUCT)
493 { 510 {
494 /* is this ugly, I ask? */ 511 /* is this ugly, I ask? */
495 LEAVE_SCOPE (0); 512 LEAVE_SCOPE (0);
526 543
527 Safefree (PL_tmps_stack); 544 Safefree (PL_tmps_stack);
528 Safefree (PL_markstack); 545 Safefree (PL_markstack);
529 Safefree (PL_scopestack); 546 Safefree (PL_scopestack);
530 Safefree (PL_savestack); 547 Safefree (PL_savestack);
531#if PERL_VERSION < 9 548#if !PERL_VERSION_ATLEAST (5,9,0)
532 Safefree (PL_retstack); 549 Safefree (PL_retstack);
533#endif 550#endif
534} 551}
535 552
536static void 553static void
537setup_coro (struct coro *coro) 554setup_coro (struct coro *coro)
538{ 555{
539 /* 556 /*
540 * emulate part of the perl startup here. 557 * emulate part of the perl startup here.
541 */ 558 */
542 dTHX;
543 dSP;
544 UNOP myop;
545 SV *sub_init = (SV *)get_cv (SUB_INIT, FALSE);
546 559
547 coro_init_stacks (aTHX); 560 coro_init_stacks ();
561
548 /*PL_curcop = 0;*/ 562 PL_curcop = 0;
549 /*PL_in_eval = PL_in_eval;*/ /* inherit */ 563 PL_in_eval = 0;
564 PL_curpm = 0;
565
566 {
567 dSP;
568 LOGOP myop;
569
570 /* I have no idea why this is needed, but it is */
571 PUSHMARK (SP);
572
550 SvREFCNT_dec (GvAV (PL_defgv)); 573 SvREFCNT_dec (GvAV (PL_defgv));
551 GvAV (PL_defgv) = coro->args; coro->args = 0; 574 GvAV (PL_defgv) = coro->args; coro->args = 0;
552 575
553 SPAGAIN;
554
555 Zero (&myop, 1, UNOP); 576 Zero (&myop, 1, LOGOP);
556 myop.op_next = Nullop; 577 myop.op_next = Nullop;
557 myop.op_flags = OPf_WANT_VOID; 578 myop.op_flags = OPf_WANT_VOID;
558 579
559 PL_op = (OP *)&myop; 580 PL_op = (OP *)&myop;
560 581
561 PUSHMARK(SP); 582 PUSHMARK (SP);
562 XPUSHs (sub_init); 583 XPUSHs ((SV *)get_cv ("Coro::State::coro_init", FALSE));
563 PUTBACK; 584 PUTBACK;
564 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX); 585 PL_op = PL_ppaddr[OP_ENTERSUB](aTHX);
565 SPAGAIN; 586 SPAGAIN;
566 587
567 ENTER; /* necessary e.g. for dounwind */ 588 ENTER; /* necessary e.g. for dounwind */
589 }
568} 590}
569 591
570static void 592static void
571transfer_tail () 593free_coro_mortal ()
572{ 594{
573 if (coro_mortal) 595 if (coro_mortal)
574 { 596 {
575 SvREFCNT_dec (coro_mortal); 597 SvREFCNT_dec (coro_mortal);
576 coro_mortal = 0; 598 coro_mortal = 0;
577 } 599 }
600}
578 601
602static void NOINLINE
603prepare_cctx (coro_cctx *cctx)
604{
605 dSP;
606 LOGOP myop;
607
608 Zero (&myop, 1, LOGOP);
609 myop.op_next = PL_op;
610 myop.op_flags = OPf_WANT_VOID;
611
612 sv_setiv (get_sv ("Coro::State::cctx", FALSE), PTR2IV (cctx));
613
614 PUSHMARK (SP);
615 XPUSHs ((SV *)get_cv ("Coro::State::cctx_init", FALSE));
616 PUTBACK;
617 PL_restartop = PL_ppaddr[OP_ENTERSUB](aTHX);
618 SPAGAIN;
619}
620
621static void
622coro_run (void *arg)
623{
624 /* coro_run is the alternative epilogue of transfer() */
579 UNLOCK; 625 UNLOCK;
580}
581 626
582static void
583coro_run (void *arg)
584{
585 /* 627 /*
586 * this is a _very_ stripped down perl interpreter ;) 628 * this is a _very_ stripped down perl interpreter ;)
587 */ 629 */
588 dTHX;
589
590 transfer_tail ();
591
592 PL_top_env = &PL_start_env; 630 PL_top_env = &PL_start_env;
593 PL_restartop = PL_op->op_next; 631 /* inject call to cctx_init */
632 prepare_cctx ((coro_cctx *)arg);
633
594 /* somebody will hit me for both perl_run and PL_restart_top */ 634 /* somebody will hit me for both perl_run and PL_restartop */
595 perl_run (aTHX_ PERL_GET_CONTEXT); 635 perl_run (PL_curinterp);
596 636
637 fputs ("FATAL: C coroutine fell over the edge of the world, aborting. Did you call exit in a coroutine?\n", stderr);
597 abort (); 638 abort ();
598} 639}
599 640
600static coro_stack * 641static coro_cctx *
601stack_new () 642cctx_new ()
602{ 643{
603 coro_stack *stack; 644 coro_cctx *cctx;
604 645
605 New (0, stack, 1, coro_stack); 646 New (0, cctx, 1, coro_cctx);
606 647
607#if HAVE_MMAP 648#if HAVE_MMAP
608 649
609 stack->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; /* mmap should do allocate-on-write for us */ 650 cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE;
651 /* mmap suppsedly does allocate-on-write for us */
610 stack->sptr = mmap (0, stack->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); 652 cctx->sptr = mmap (0, cctx->ssize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
611 653
612 if (stack->sptr == (void *)-1) 654 if (cctx->sptr == (void *)-1)
613 { 655 {
614 fprintf (stderr, "FATAL: unable to mmap stack for coroutine\n"); 656 perror ("FATAL: unable to mmap stack for coroutine");
615 _exit (EXIT_FAILURE); 657 _exit (EXIT_FAILURE);
616 } 658 }
617 659
660# if STACKGUARD
618 mprotect (stack->sptr, STACKGUARD * PAGESIZE, PROT_NONE); 661 mprotect (cctx->sptr, STACKGUARD * PAGESIZE, PROT_NONE);
662# endif
619 663
620#else 664#else
621 665
622 stack->ssize = STACKSIZE * (long)sizeof (long); 666 cctx->ssize = STACKSIZE * (long)sizeof (long);
623 New (0, stack->sptr, STACKSIZE, long); 667 New (0, cctx->sptr, STACKSIZE, long);
624 668
625 if (!stack->sptr) 669 if (!cctx->sptr)
626 { 670 {
627 fprintf (stderr, "FATAL: unable to malloc stack for coroutine\n"); 671 perror ("FATAL: unable to malloc stack for coroutine");
628 _exit (EXIT_FAILURE); 672 _exit (EXIT_FAILURE);
629 } 673 }
630 674
631#endif 675#endif
632 676
677#if USE_VALGRIND
678 cctx->valgrind_id = VALGRIND_STACK_REGISTER (
679 STACKGUARD * PAGESIZE + (char *)cctx->sptr,
680 cctx->ssize + (char *)cctx->sptr
681 );
682#endif
683
633 coro_create (&stack->cctx, coro_run, 0, stack->sptr, stack->ssize); 684 coro_create (&cctx->cctx, coro_run, (void *)cctx, cctx->sptr, cctx->ssize);
634 685
635 return stack; 686 return cctx;
636} 687}
637 688
638static void 689static void
639stack_free (coro_stack *stack) 690cctx_free (coro_cctx *cctx)
640{ 691{
641 if (!stack || stack == main_stack) 692 if (!cctx)
642 return; 693 return;
643 694
695#if USE_VALGRIND
696 VALGRIND_STACK_DEREGISTER (cctx->valgrind_id);
697#endif
698
644#if HAVE_MMAP 699#if HAVE_MMAP
645 munmap (stack->sptr, stack->ssize); 700 munmap (cctx->sptr, cctx->ssize);
646#else 701#else
647 Safefree (stack->sptr); 702 Safefree (cctx->sptr);
648#endif 703#endif
649 704
650 Safefree (stack); 705 Safefree (cctx);
651} 706}
652 707
653static coro_stack *stack_first; 708static coro_cctx *cctx_first;
709static int cctx_count, cctx_idle;
654 710
655static void 711static coro_cctx *
656stack_get (struct coro *coro) 712cctx_get ()
657{ 713{
714 coro_cctx *cctx;
715
658 if (stack_first) 716 if (cctx_first)
659 { 717 {
660 coro->stack = stack_first; 718 --cctx_idle;
661 stack_first = stack_first->next; 719 cctx = cctx_first;
720 cctx_first = cctx->next;
662 } 721 }
663 else 722 else
664 coro->stack = stack_new (); 723 {
665} 724 ++cctx_count;
725 cctx = cctx_new ();
726 PL_op = PL_op->op_next;
727 }
666 728
729 return cctx;
730}
731
667static void 732static void
668stack_put (coro_stack *stack) 733cctx_put (coro_cctx *cctx)
669{ 734{
670 stack->next = stack_first; 735 ++cctx_idle;
671 stack_first = stack; 736 cctx->next = cctx_first;
737 cctx_first = cctx;
672} 738}
673 739
674/* never call directly, always through the coro_state_transfer global variable */ 740/* never call directly, always through the coro_state_transfer global variable */
675static void 741static void NOINLINE
676transfer_impl (pTHX_ struct coro *prev, struct coro *next, int flags) 742transfer (struct coro *prev, struct coro *next, int flags)
677{ 743{
678 dSTACKLEVEL; 744 dSTACKLEVEL;
679 745
680 /* sometimes transfer is only called to set idle_sp */ 746 /* sometimes transfer is only called to set idle_sp */
681 if (!prev->stack->idle_sp) 747 if (flags == TRANSFER_SET_STACKLEVEL)
682 prev->stack->idle_sp = stacklevel; 748 ((coro_cctx *)prev)->idle_sp = STACKLEVEL;
683
684 LOCK;
685
686 if (prev != next) 749 else if (prev != next)
687 { 750 {
688 coro_stack *prev_stack = prev->stack; 751 coro_cctx *prev__cctx;
689 752
690 /* possibly "free" the stack */ 753 LOCK;
691 if (prev_stack->idle_sp == stacklevel) 754
755 if (next->mainstack)
692 { 756 {
693 stack_put (prev_stack); 757 /* coroutine already started */
694 prev->stack = 0; 758 SAVE (prev, flags);
759 LOAD (next);
695 } 760 }
696 761 else
697 if (!next->mainstack)
698 { 762 {
763 /* need to start coroutine */
699 /* first get rid of the old state */ 764 /* first get rid of the old state */
700 SAVE (prev, -1); 765 SAVE (prev, -1);
701 /* setup coroutine call */ 766 /* setup coroutine call */
702 setup_coro (next); 767 setup_coro (next);
768 /* need a stack */
703 next->stack = 0; 769 next->cctx = 0;
704 } 770 }
705 else 771
772 if (!prev->cctx)
773 /* create a new empty context */
774 Newz (0, prev->cctx, 1, coro_cctx);
775
776 prev__cctx = prev->cctx;
777
778 /* possibly "free" the cctx */
779 if (prev__cctx->idle_sp == STACKLEVEL)
706 { 780 {
707 SAVE (prev, flags); 781 cctx_put (prev__cctx);
708 LOAD (next); 782 prev->cctx = 0;
709 } 783 }
710 784
711 if (!next->stack) 785 if (!next->cctx)
712 stack_get (next); 786 next->cctx = cctx_get ();
713 787
714 if (prev_stack != next->stack) 788 if (prev__cctx != next->cctx)
789 {
790 prev__cctx->top_env = PL_top_env;
791 PL_top_env = next->cctx->top_env;
715 coro_transfer (&prev_stack->cctx, &next->stack->cctx); 792 coro_transfer (&prev__cctx->cctx, &next->cctx->cctx);
793 }
794
795 free_coro_mortal ();
796
797 UNLOCK;
716 } 798 }
717
718 transfer_tail ();
719} 799}
720 800
721/* use this function pointer to call the above function */ 801struct transfer_args
722/* this is done to increase chances of the compiler not inlining the call */ 802{
723void (*coro_state_transfer)(pTHX_ struct coro *prev, struct coro *next, int flags) = transfer_impl; 803 struct coro *prev, *next;
804 int flags;
805};
806
807#define TRANSFER(ta) transfer ((ta).prev, (ta).next, (ta).flags)
724 808
725static void 809static void
726coro_state_destroy (struct coro *coro) 810coro_state_destroy (struct coro *coro)
727{ 811{
728 if (coro->refcnt--) 812 if (coro->refcnt--)
730 814
731 if (coro->mainstack && coro->mainstack != main_mainstack) 815 if (coro->mainstack && coro->mainstack != main_mainstack)
732 { 816 {
733 struct coro temp; 817 struct coro temp;
734 818
735 SAVE (aTHX_ (&temp), TRANSFER_SAVE_ALL); 819 SAVE ((&temp), TRANSFER_SAVE_ALL);
736 LOAD (aTHX_ coro); 820 LOAD (coro);
737 821
738 destroy_stacks (aTHX); 822 coro_destroy_stacks ();
739 823
740 LOAD ((&temp)); /* this will get rid of defsv etc.. */ 824 LOAD ((&temp)); /* this will get rid of defsv etc.. */
741 825
742 coro->mainstack = 0; 826 coro->mainstack = 0;
743 } 827 }
744 828
745 stack_free (coro->stack); 829 cctx_free (coro->cctx);
746 SvREFCNT_dec (coro->args); 830 SvREFCNT_dec (coro->args);
747 Safefree (coro); 831 Safefree (coro);
748} 832}
749 833
750static int 834static int
751coro_state_clear (SV *sv, MAGIC *mg) 835coro_state_clear (pTHX_ SV *sv, MAGIC *mg)
752{ 836{
753 struct coro *coro = (struct coro *)mg->mg_ptr; 837 struct coro *coro = (struct coro *)mg->mg_ptr;
754 mg->mg_ptr = 0; 838 mg->mg_ptr = 0;
755 839
756 coro_state_destroy (coro); 840 coro_state_destroy (coro);
757 841
758 return 0; 842 return 0;
759} 843}
760 844
761static int 845static int
762coro_state_dup (MAGIC *mg, CLONE_PARAMS *params) 846coro_state_dup (pTHX_ MAGIC *mg, CLONE_PARAMS *params)
763{ 847{
764 struct coro *coro = (struct coro *)mg->mg_ptr; 848 struct coro *coro = (struct coro *)mg->mg_ptr;
765 849
766 ++coro->refcnt; 850 ++coro->refcnt;
767 851
768 return 0; 852 return 0;
769} 853}
770 854
771static MGVTBL coro_state_vtbl = { 0, 0, 0, 0, coro_state_clear, 0, coro_state_dup, 0 }; 855static MGVTBL coro_state_vtbl = {
856 0, 0, 0, 0,
857 coro_state_clear,
858 0,
859#ifdef MGf_DUP
860 coro_state_dup,
861#else
862# define MGf_DUP 0
863#endif
864};
772 865
773static struct coro * 866static struct coro *
774SvSTATE (SV *coro) 867SvSTATE (SV *coro)
775{ 868{
776 HV *stash; 869 HV *stash;
791 assert (mg->mg_type == PERL_MAGIC_ext); 884 assert (mg->mg_type == PERL_MAGIC_ext);
792 return (struct coro *)mg->mg_ptr; 885 return (struct coro *)mg->mg_ptr;
793} 886}
794 887
795static void 888static void
889prepare_transfer (struct transfer_args *ta, SV *prev, SV *next, int flags)
890{
891 ta->prev = SvSTATE (prev);
892 ta->next = SvSTATE (next);
893 ta->flags = flags;
894}
895
896static void
796api_transfer (pTHX_ SV *prev, SV *next, int flags) 897api_transfer (SV *prev, SV *next, int flags)
797{ 898{
798 coro_state_transfer (aTHX_ SvSTATE (prev), SvSTATE (next), flags); 899 dTHX;
900 struct transfer_args ta;
901
902 prepare_transfer (&ta, prev, next, flags);
903 TRANSFER (ta);
799} 904}
800 905
801/** Coro ********************************************************************/ 906/** Coro ********************************************************************/
802 907
803#define PRIO_MAX 3 908#define PRIO_MAX 3
811static GV *coro_current, *coro_idle; 916static GV *coro_current, *coro_idle;
812static AV *coro_ready [PRIO_MAX-PRIO_MIN+1]; 917static AV *coro_ready [PRIO_MAX-PRIO_MIN+1];
813static int coro_nready; 918static int coro_nready;
814 919
815static void 920static void
816coro_enq (pTHX_ SV *sv) 921coro_enq (SV *sv)
817{ 922{
818 int prio; 923 int prio;
819 924
820 if (SvTYPE (sv) != SVt_PVHV) 925 if (SvTYPE (sv) != SVt_PVHV)
821 croak ("Coro::ready tried to enqueue something that is not a coroutine"); 926 croak ("Coro::ready tried to enqueue something that is not a coroutine");
825 av_push (coro_ready [prio - PRIO_MIN], sv); 930 av_push (coro_ready [prio - PRIO_MIN], sv);
826 coro_nready++; 931 coro_nready++;
827} 932}
828 933
829static SV * 934static SV *
830coro_deq (pTHX_ int min_prio) 935coro_deq (int min_prio)
831{ 936{
832 int prio = PRIO_MAX - PRIO_MIN; 937 int prio = PRIO_MAX - PRIO_MIN;
833 938
834 min_prio -= PRIO_MIN; 939 min_prio -= PRIO_MIN;
835 if (min_prio < 0) 940 if (min_prio < 0)
852 957
853 if (SvROK (coro)) 958 if (SvROK (coro))
854 coro = SvRV (coro); 959 coro = SvRV (coro);
855 960
856 LOCK; 961 LOCK;
857 coro_enq (aTHX_ SvREFCNT_inc (coro)); 962 coro_enq (SvREFCNT_inc (coro));
858 UNLOCK; 963 UNLOCK;
859} 964}
860 965
861static void 966static void
862api_schedule (void) 967prepare_schedule (struct transfer_args *ta)
863{ 968{
864 dTHX;
865
866 SV *prev, *next; 969 SV *current, *prev, *next;
970
867 SV *current = GvSV (coro_current); 971 current = GvSV (coro_current);
868 972
869 for (;;) 973 for (;;)
870 { 974 {
871 LOCK; 975 LOCK;
872
873 next = coro_deq (aTHX_ PRIO_MIN); 976 next = coro_deq (PRIO_MIN);
977 UNLOCK;
874 978
875 if (next) 979 if (next)
876 break; 980 break;
877
878 UNLOCK;
879 981
880 { 982 {
881 dSP; 983 dSP;
882 984
883 ENTER; 985 ENTER;
894 996
895 prev = SvRV (current); 997 prev = SvRV (current);
896 SvRV (current) = next; 998 SvRV (current) = next;
897 999
898 /* free this only after the transfer */ 1000 /* free this only after the transfer */
1001 LOCK;
1002 free_coro_mortal ();
1003 UNLOCK;
899 coro_mortal = prev; 1004 coro_mortal = prev;
900 1005
1006 ta->prev = SvSTATE (prev);
1007 ta->next = SvSTATE (next);
1008 ta->flags = TRANSFER_SAVE_ALL;
1009}
1010
1011static void
1012prepare_cede (struct transfer_args *ta)
1013{
1014 LOCK;
1015 coro_enq (SvREFCNT_inc (SvRV (GvSV (coro_current))));
901 UNLOCK; 1016 UNLOCK;
902 1017
903 coro_state_transfer (aTHX_ SvSTATE (prev), SvSTATE (next), TRANSFER_SAVE_ALL); 1018 prepare_schedule (ta);
904} 1019}
905 1020
906static int coro_cede_self; 1021static void
1022api_schedule (void)
1023{
1024 dTHX;
1025 struct transfer_args ta;
1026
1027 prepare_schedule (&ta);
1028 TRANSFER (ta);
1029}
907 1030
908static void 1031static void
909api_cede (void) 1032api_cede (void)
910{ 1033{
911 dTHX; 1034 dTHX;
912 SV *current = SvREFCNT_inc (SvRV (GvSV (coro_current))); 1035 struct transfer_args ta;
913 1036
914 LOCK; 1037 prepare_cede (&ta);
915 1038 TRANSFER (ta);
916 if (coro_cede_self)
917 {
918 AV *runqueue = coro_ready [PRIO_MAX - PRIO_MIN];
919 av_unshift (runqueue, 1);
920 av_store (runqueue, 0, current);
921 coro_nready++;
922 coro_cede_self = 0;
923 }
924 else
925 coro_enq (aTHX_ current);
926
927 UNLOCK;
928
929 api_schedule ();
930} 1039}
931 1040
932MODULE = Coro::State PACKAGE = Coro::State 1041MODULE = Coro::State PACKAGE = Coro::State
933 1042
934PROTOTYPES: DISABLE 1043PROTOTYPES: DISABLE
949 main_mainstack = PL_mainstack; 1058 main_mainstack = PL_mainstack;
950 1059
951 coroapi.ver = CORO_API_VERSION; 1060 coroapi.ver = CORO_API_VERSION;
952 coroapi.transfer = api_transfer; 1061 coroapi.transfer = api_transfer;
953 1062
954 Newz (0, main_stack, 1, coro_stack);
955 main_stack->idle_sp = (void *)-1;
956
957 assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL)); 1063 assert (("PRIO_NORMAL must be 0", !PRIO_NORMAL));
958} 1064}
959 1065
960SV * 1066SV *
961new (char *klass, ...) 1067new (char *klass, ...)
970 1076
971 hv = newHV (); 1077 hv = newHV ();
972 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP; 1078 sv_magicext ((SV *)hv, 0, PERL_MAGIC_ext, &coro_state_vtbl, (char *)coro, 0)->mg_flags |= MGf_DUP;
973 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); 1079 RETVAL = sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1));
974 1080
975 av_push (coro->args, newSVsv (RETVAL));
976 for (i = 1; i < items; i++) 1081 for (i = 1; i < items; i++)
977 av_push (coro->args, newSVsv (ST (i))); 1082 av_push (coro->args, newSVsv (ST (i)));
978
979 coro->stack = main_stack;
980 /*coro->mainstack = 0; *//*actual work is done inside transfer */
981 /*coro->stack = 0;*/
982} 1083}
983 OUTPUT: 1084 OUTPUT:
984 RETVAL 1085 RETVAL
985 1086
986void 1087void
987transfer (prev, next, flags) 1088_set_stacklevel (...)
988 SV *prev 1089 ALIAS:
989 SV *next 1090 Coro::State::transfer = 1
990 int flags 1091 Coro::schedule = 2
1092 Coro::cede = 3
1093 Coro::Cont::yield = 4
991 CODE: 1094 CODE:
992 PUTBACK;
993 coro_state_transfer (aTHX_ SvSTATE (prev), SvSTATE (next), flags);
994 SPAGAIN;
995
996int
997prio (Coro::State coro, int newprio = 0)
998 ALIAS:
999 nice = 1
1000 CODE:
1001{ 1095{
1002 RETVAL = coro->prio; 1096 struct transfer_args ta;
1003 1097
1004 if (items > 1) 1098 switch (ix)
1005 { 1099 {
1100 case 0:
1101 ta.prev = (struct coro *)INT2PTR (coro_cctx *, SvIV (ST (0)));
1102 ta.next = 0;
1103 ta.flags = TRANSFER_SET_STACKLEVEL;
1104 break;
1105
1106 case 1:
1006 if (ix) 1107 if (items != 3)
1007 newprio += coro->prio; 1108 croak ("Coro::State::transfer(prev,next,flags) expects three arguments, not %d", items);
1008 1109
1009 if (newprio < PRIO_MIN) newprio = PRIO_MIN; 1110 prepare_transfer (&ta, ST (0), ST (1), SvIV (ST (2)));
1010 if (newprio > PRIO_MAX) newprio = PRIO_MAX; 1111 break;
1011 1112
1012 coro->prio = newprio; 1113 case 2:
1114 prepare_schedule (&ta);
1115 break;
1116
1117 case 3:
1118 prepare_cede (&ta);
1119 break;
1120
1121 case 4:
1122 {
1123 SV *yieldstack;
1124 SV *sv;
1125 AV *defav = GvAV (PL_defgv);
1126
1127 yieldstack = *hv_fetch (
1128 (HV *)SvRV (GvSV (coro_current)),
1129 "yieldstack", sizeof ("yieldstack") - 1,
1130 0
1131 );
1132
1133 /* set up @_ -- ugly */
1134 av_clear (defav);
1135 av_fill (defav, items - 1);
1136 while (items--)
1137 av_store (defav, items, SvREFCNT_inc (ST(items)));
1138
1139 sv = av_pop ((AV *)SvRV (yieldstack));
1140 ta.prev = SvSTATE (*av_fetch ((AV *)SvRV (sv), 0, 0));
1141 ta.next = SvSTATE (*av_fetch ((AV *)SvRV (sv), 1, 0));
1142 ta.flags = 0;
1143 SvREFCNT_dec (sv);
1144 }
1145 break;
1146
1013 } 1147 }
1014}
1015 1148
1016void 1149 TRANSFER (ta);
1017_clear_idle_sp (Coro::State self) 1150}
1018 CODE:
1019 self->stack->idle_sp = 0;
1020 1151
1021void 1152void
1022_clone_state_from (SV *dst, SV *src) 1153_clone_state_from (SV *dst, SV *src)
1023 CODE: 1154 CODE:
1024{ 1155{
1035 int code 1166 int code
1036 PROTOTYPE: $ 1167 PROTOTYPE: $
1037 CODE: 1168 CODE:
1038 _exit (code); 1169 _exit (code);
1039 1170
1040MODULE = Coro::State PACKAGE = Coro::Cont 1171int
1172cctx_count ()
1173 CODE:
1174 RETVAL = cctx_count;
1175 OUTPUT:
1176 RETVAL
1041 1177
1042void 1178int
1043yield (...) 1179cctx_idle ()
1044 PROTOTYPE: @ 1180 CODE:
1045 CODE: 1181 RETVAL = cctx_idle;
1046{ 1182 OUTPUT:
1047 SV *yieldstack; 1183 RETVAL
1048 SV *sv;
1049 AV *defav = GvAV (PL_defgv);
1050 struct coro *prev, *next;
1051
1052 yieldstack = *hv_fetch (
1053 (HV *)SvRV (GvSV (coro_current)),
1054 "yieldstack", sizeof ("yieldstack") - 1,
1055 0
1056 );
1057
1058 /* set up @_ -- ugly */
1059 av_clear (defav);
1060 av_fill (defav, items - 1);
1061 while (items--)
1062 av_store (defav, items, SvREFCNT_inc (ST(items)));
1063
1064 sv = av_pop ((AV *)SvRV (yieldstack));
1065 prev = SvSTATE (*av_fetch ((AV *)SvRV (sv), 0, 0));
1066 next = SvSTATE (*av_fetch ((AV *)SvRV (sv), 1, 0));
1067 SvREFCNT_dec (sv);
1068
1069 coro_state_transfer (aTHX_ prev, next, 0);
1070}
1071 1184
1072MODULE = Coro::State PACKAGE = Coro 1185MODULE = Coro::State PACKAGE = Coro
1073 1186
1074BOOT: 1187BOOT:
1075{ 1188{
1101 1214
1102 GCoroAPI = &coroapi; 1215 GCoroAPI = &coroapi;
1103 sv_setiv (sv, (IV)&coroapi); 1216 sv_setiv (sv, (IV)&coroapi);
1104 SvREADONLY_on (sv); 1217 SvREADONLY_on (sv);
1105 } 1218 }
1219}
1220
1221int
1222prio (Coro::State coro, int newprio = 0)
1223 ALIAS:
1224 nice = 1
1225 CODE:
1226{
1227 RETVAL = coro->prio;
1228
1229 if (items > 1)
1230 {
1231 if (ix)
1232 newprio += coro->prio;
1233
1234 if (newprio < PRIO_MIN) newprio = PRIO_MIN;
1235 if (newprio > PRIO_MAX) newprio = PRIO_MAX;
1236
1237 coro->prio = newprio;
1238 }
1106} 1239}
1107 1240
1108void 1241void
1109ready (SV *self) 1242ready (SV *self)
1110 PROTOTYPE: $ 1243 PROTOTYPE: $
1117 CODE: 1250 CODE:
1118 RETVAL = coro_nready; 1251 RETVAL = coro_nready;
1119 OUTPUT: 1252 OUTPUT:
1120 RETVAL 1253 RETVAL
1121 1254
1122void
1123schedule (...)
1124 PROTOTYPE:
1125 CODE:
1126 api_schedule ();
1127
1128void
1129_set_cede_self ()
1130 CODE:
1131 coro_cede_self = 1;
1132
1133void
1134cede (...)
1135 PROTOTYPE:
1136 CODE:
1137 api_cede ();
1138
1139MODULE = Coro::State PACKAGE = Coro::AIO 1255MODULE = Coro::State PACKAGE = Coro::AIO
1140 1256
1141SV * 1257SV *
1142_get_state () 1258_get_state ()
1143 CODE: 1259 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines