… | |
… | |
75 | /* 5.8.7 */ |
75 | /* 5.8.7 */ |
76 | #ifndef SvRV_set |
76 | #ifndef SvRV_set |
77 | # define SvRV_set(s,v) SvRV(s) = (v) |
77 | # define SvRV_set(s,v) SvRV(s) = (v) |
78 | #endif |
78 | #endif |
79 | |
79 | |
|
|
80 | /* 5.8.8 */ |
|
|
81 | #ifndef GV_NOTQUAL |
|
|
82 | # define GV_NOTQUAL 0 |
|
|
83 | #endif |
|
|
84 | |
80 | #if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64 |
85 | #if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64 |
81 | # undef CORO_STACKGUARD |
86 | # undef CORO_STACKGUARD |
82 | #endif |
87 | #endif |
83 | |
88 | |
84 | #ifndef CORO_STACKGUARD |
89 | #ifndef CORO_STACKGUARD |
… | |
… | |
132 | static AV *main_mainstack; /* used to differentiate between $main and others */ |
137 | static AV *main_mainstack; /* used to differentiate between $main and others */ |
133 | static JMPENV *main_top_env; |
138 | static JMPENV *main_top_env; |
134 | static HV *coro_state_stash, *coro_stash; |
139 | static HV *coro_state_stash, *coro_stash; |
135 | static SV *coro_mortal; /* will be freed after next transfer */ |
140 | static SV *coro_mortal; /* will be freed after next transfer */ |
136 | |
141 | |
137 | static GV *irsgv; /* $/ */ |
142 | static GV *irsgv; /* $/ */ |
|
|
143 | static GV *stdoutgv; /* *STDOUT */ |
138 | |
144 | |
139 | /* async_pool helper stuff */ |
145 | /* async_pool helper stuff */ |
140 | static SV *sv_pool_rss; |
146 | static SV *sv_pool_rss; |
141 | static SV *sv_pool_size; |
147 | static SV *sv_pool_size; |
142 | static AV *av_async_pool; |
148 | static AV *av_async_pool; |
… | |
… | |
563 | # include "state.h" |
569 | # include "state.h" |
564 | #undef VAR |
570 | #undef VAR |
565 | } |
571 | } |
566 | |
572 | |
567 | rss += sizeof (coro->curstackinfo); |
573 | rss += sizeof (coro->curstackinfo); |
568 | rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *); |
574 | rss += sizeof (SV) + sizeof (struct xpvav) + (1 + AvFILL (coro->curstackinfo->si_stack)) * sizeof (SV *); |
569 | rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT); |
575 | rss += (coro->curstackinfo->si_cxmax + 1) * sizeof (PERL_CONTEXT); |
570 | rss += sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *); |
576 | rss += sizeof (SV) + sizeof (struct xpvav) + (1 + AvFILL (coro->curstack)) * sizeof (SV *); |
571 | rss += coro->tmps_max * sizeof (SV *); |
577 | rss += coro->tmps_max * sizeof (SV *); |
572 | rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32); |
578 | rss += (coro->markstack_max - coro->markstack_ptr) * sizeof (I32); |
573 | rss += coro->scopestack_max * sizeof (I32); |
579 | rss += coro->scopestack_max * sizeof (I32); |
574 | rss += coro->savestack_max * sizeof (ANY); |
580 | rss += coro->savestack_max * sizeof (ANY); |
575 | |
581 | |
… | |
… | |
603 | GvSV (PL_defgv) = NEWSV (0, 0); |
609 | GvSV (PL_defgv) = NEWSV (0, 0); |
604 | GvAV (PL_defgv) = coro->args; coro->args = 0; |
610 | GvAV (PL_defgv) = coro->args; coro->args = 0; |
605 | GvSV (PL_errgv) = NEWSV (0, 0); |
611 | GvSV (PL_errgv) = NEWSV (0, 0); |
606 | GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0); |
612 | GvSV (irsgv) = newSVpvn ("\n", 1); sv_magic (GvSV (irsgv), (SV *)irsgv, PERL_MAGIC_sv, "/", 0); |
607 | PL_rs = newSVsv (GvSV (irsgv)); |
613 | PL_rs = newSVsv (GvSV (irsgv)); |
608 | |
614 | PL_defoutgv = SvREFCNT_inc (stdoutgv); |
609 | { |
|
|
610 | IO *io = newIO (); |
|
|
611 | PL_defoutgv = newGVgen ("Coro"); |
|
|
612 | GvIOp(PL_defoutgv) = io; |
|
|
613 | IoTYPE (io) = IoTYPE_WRONLY; |
|
|
614 | IoOFP (io) = IoIFP (io) = PerlIO_stdout (); |
|
|
615 | IoFLAGS (io) |= IOf_FLUSH; |
|
|
616 | } |
|
|
617 | |
615 | |
618 | { |
616 | { |
619 | dSP; |
617 | dSP; |
620 | LOGOP myop; |
618 | LOGOP myop; |
621 | |
619 | |
… | |
… | |
1385 | #ifdef USE_ITHREADS |
1383 | #ifdef USE_ITHREADS |
1386 | MUTEX_INIT (&coro_mutex); |
1384 | MUTEX_INIT (&coro_mutex); |
1387 | #endif |
1385 | #endif |
1388 | BOOT_PAGESIZE; |
1386 | BOOT_PAGESIZE; |
1389 | |
1387 | |
1390 | irsgv = gv_fetchpv ("/", 1, SVt_PV); |
1388 | irsgv = gv_fetchpv ("/" , GV_ADD|GV_NOTQUAL, SVt_PV); |
|
|
1389 | stdoutgv = gv_fetchpv ("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); |
1391 | |
1390 | |
1392 | coro_state_stash = gv_stashpv ("Coro::State", TRUE); |
1391 | coro_state_stash = gv_stashpv ("Coro::State", TRUE); |
1393 | |
1392 | |
1394 | newCONSTSUB (coro_state_stash, "CC_TRACE" , newSViv (CC_TRACE)); |
1393 | newCONSTSUB (coro_state_stash, "CC_TRACE" , newSViv (CC_TRACE)); |
1395 | newCONSTSUB (coro_state_stash, "CC_TRACE_SUB" , newSViv (CC_TRACE_SUB)); |
1394 | newCONSTSUB (coro_state_stash, "CC_TRACE_SUB" , newSViv (CC_TRACE_SUB)); |