… | |
… | |
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 | |
… | |
… | |
593 | { |
594 | { |
594 | coro_cctx *cctx; |
595 | coro_cctx *cctx; |
595 | |
596 | |
596 | ++cctx_count; |
597 | ++cctx_count; |
597 | |
598 | |
598 | New (0, cctx, 1, coro_cctx); |
599 | Newz (0, cctx, 1, coro_cctx); |
599 | |
600 | |
600 | #if HAVE_MMAP |
601 | #if HAVE_MMAP |
601 | |
602 | |
602 | cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; |
603 | cctx->ssize = ((STACKSIZE * sizeof (long) + PAGESIZE - 1) / PAGESIZE + STACKGUARD) * PAGESIZE; |
603 | /* mmap supposedly does allocate-on-write for us */ |
604 | /* mmap supposedly does allocate-on-write for us */ |
… | |
… | |
704 | { |
705 | { |
705 | dSTACKLEVEL; |
706 | dSTACKLEVEL; |
706 | |
707 | |
707 | /* sometimes transfer is only called to set idle_sp */ |
708 | /* sometimes transfer is only called to set idle_sp */ |
708 | if (!next) |
709 | if (!next) |
|
|
710 | { |
709 | ((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 | } |
710 | else if (prev != next) |
714 | else if (prev != next) |
711 | { |
715 | { |
712 | coro_cctx *prev__cctx; |
716 | coro_cctx *prev__cctx; |
713 | |
717 | |
714 | if (prev->flags & CF_NEW) |
718 | if (prev->flags & CF_NEW) |
… | |
… | |
739 | /* first get rid of the old state */ |
743 | /* first get rid of the old state */ |
740 | save_perl (prev); |
744 | save_perl (prev); |
741 | /* setup coroutine call */ |
745 | /* setup coroutine call */ |
742 | setup_coro (next); |
746 | setup_coro (next); |
743 | /* need a new stack */ |
747 | /* need a new stack */ |
744 | assert (!next->stack); |
748 | assert (!next->cctx); |
745 | } |
749 | } |
746 | else |
750 | else |
747 | { |
751 | { |
748 | /* coroutine already started */ |
752 | /* coroutine already started */ |
749 | save_perl (prev); |
753 | save_perl (prev); |