… | |
… | |
40 | # endif |
40 | # endif |
41 | #endif |
41 | #endif |
42 | |
42 | |
43 | #include <stdio.h> |
43 | #include <stdio.h> |
44 | #include <errno.h> |
44 | #include <errno.h> |
|
|
45 | #include <assert.h> |
45 | |
46 | |
46 | #if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64 |
47 | #if !__i386 && !__x86_64 && !__powerpc && !__m68k && !__alpha && !__mips && !__sparc64 |
47 | # undef STACKGUARD |
48 | # undef STACKGUARD |
48 | #endif |
49 | #endif |
49 | |
50 | |
… | |
… | |
157 | /* optionally saved, might be zero */ |
158 | /* optionally saved, might be zero */ |
158 | AV *defav; /* @_ */ |
159 | AV *defav; /* @_ */ |
159 | SV *defsv; /* $_ */ |
160 | SV *defsv; /* $_ */ |
160 | SV *errsv; /* $@ */ |
161 | SV *errsv; /* $@ */ |
161 | SV *irssv; /* $/ */ |
162 | SV *irssv; /* $/ */ |
|
|
163 | SV *irssv_sv; /* real $/ cache */ |
162 | |
164 | |
163 | #define VAR(name,type) type name; |
165 | #define VAR(name,type) type name; |
164 | # include "state.h" |
166 | # include "state.h" |
165 | #undef VAR |
167 | #undef VAR |
166 | |
168 | |
… | |
… | |
301 | #undef VAR |
303 | #undef VAR |
302 | |
304 | |
303 | if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav); |
305 | if (c->defav) REPLACE_SV (GvAV (PL_defgv), c->defav); |
304 | if (c->defsv) REPLACE_SV (DEFSV , c->defsv); |
306 | if (c->defsv) REPLACE_SV (DEFSV , c->defsv); |
305 | if (c->errsv) REPLACE_SV (ERRSV , c->errsv); |
307 | if (c->errsv) REPLACE_SV (ERRSV , c->errsv); |
306 | if (c->irssv) REPLACE_SV (PL_rs , c->irssv); |
308 | if (c->irssv) |
|
|
309 | { |
|
|
310 | if (c->irssv == PL_rs || sv_eq (PL_rs, c->irssv)) |
|
|
311 | SvREFCNT_dec (c->irssv); |
|
|
312 | else |
|
|
313 | { |
|
|
314 | REPLACE_SV (PL_rs, c->irssv); |
|
|
315 | if (!c->irssv_sv) c->irssv_sv = get_sv ("/", 0); |
|
|
316 | sv_setsv (c->irssv_sv, PL_rs); |
|
|
317 | } |
|
|
318 | } |
307 | |
319 | |
308 | { |
320 | { |
309 | dSP; |
321 | dSP; |
310 | CV *cv; |
322 | CV *cv; |
311 | |
323 | |
… | |
… | |
582 | { |
594 | { |
583 | coro_cctx *cctx; |
595 | coro_cctx *cctx; |
584 | |
596 | |
585 | ++cctx_count; |
597 | ++cctx_count; |
586 | |
598 | |
587 | New (0, cctx, 1, coro_cctx); |
599 | Newz (0, cctx, 1, coro_cctx); |
588 | |
600 | |
589 | #if HAVE_MMAP |
601 | #if HAVE_MMAP |
590 | |
602 | |
591 | cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; |
603 | cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; |
592 | /* mmap supposedly does allocate-on-write for us */ |
604 | /* mmap supposedly does allocate-on-write for us */ |
… | |
… | |
693 | { |
705 | { |
694 | dSTACKLEVEL; |
706 | dSTACKLEVEL; |
695 | |
707 | |
696 | /* sometimes transfer is only called to set idle_sp */ |
708 | /* sometimes transfer is only called to set idle_sp */ |
697 | if (!next) |
709 | if (!next) |
|
|
710 | { |
698 | ((coro_cctx *)prev)->idle_sp = STACKLEVEL; |
711 | ((coro_cctx *)prev)->idle_sp = STACKLEVEL; |
|
|
712 | assert (((coro_cctx *)prev)->top_env = PL_top_env); /* just for the side effetc when assert is enabled */ |
|
|
713 | } |
699 | else if (prev != next) |
714 | else if (prev != next) |
700 | { |
715 | { |
701 | coro_cctx *prev__cctx; |
716 | coro_cctx *prev__cctx; |
702 | |
717 | |
703 | if (prev->flags & CF_NEW) |
718 | if (prev->flags & CF_NEW) |
… | |
… | |
728 | /* first get rid of the old state */ |
743 | /* first get rid of the old state */ |
729 | save_perl (prev); |
744 | save_perl (prev); |
730 | /* setup coroutine call */ |
745 | /* setup coroutine call */ |
731 | setup_coro (next); |
746 | setup_coro (next); |
732 | /* need a new stack */ |
747 | /* need a new stack */ |
733 | assert (!next->stack); |
748 | assert (!next->cctx); |
734 | } |
749 | } |
735 | else |
750 | else |
736 | { |
751 | { |
737 | /* coroutine already started */ |
752 | /* coroutine already started */ |
738 | save_perl (prev); |
753 | save_perl (prev); |