… | |
… | |
563 | |
563 | |
564 | ctx->stack = 0; |
564 | ctx->stack = 0; |
565 | |
565 | |
566 | if (stack) |
566 | if (stack) |
567 | { |
567 | { |
568 | printf ("deallocating stack %p %d\n", stack, stack->refcnt);/*D*/ |
|
|
569 | if (!--stack->refcnt) |
568 | if (!--stack->refcnt) |
570 | { |
569 | { |
571 | #ifdef HAVE_MMAP |
570 | #ifdef HAVE_MMAP |
572 | if (stack->ssize > 0 && stack->sptr) |
571 | if (stack->ssize > 0 && stack->sptr) |
573 | munmap (stack->sptr, stack->ssize); |
572 | munmap (stack->sptr, stack->ssize); |
… | |
… | |
660 | transfer(pTHX_ struct coro *prev, struct coro *next, int flags) |
659 | transfer(pTHX_ struct coro *prev, struct coro *next, int flags) |
661 | { |
660 | { |
662 | dSTACKLEVEL; |
661 | dSTACKLEVEL; |
663 | static struct coro *xnext; |
662 | static struct coro *xnext; |
664 | |
663 | |
665 | printf ("%p => %p\n", prev, next);/*D*/ |
|
|
666 | if (prev != next) |
664 | if (prev != next) |
667 | { |
665 | { |
668 | xnext = next; |
666 | xnext = next; |
669 | |
667 | |
670 | if (next->mainstack) |
668 | if (next->mainstack) |
… | |
… | |
736 | else |
734 | else |
737 | setup_coro (next); |
735 | setup_coro (next); |
738 | } |
736 | } |
739 | } |
737 | } |
740 | |
738 | |
|
|
739 | /* |
|
|
740 | * xnext is now either prev or next, depending on wether |
|
|
741 | * we switched the c stack or not. that's why i use a global |
|
|
742 | * variable, that should become thread-specific at one point. |
|
|
743 | */ |
741 | xnext->cursp = stacklevel; |
744 | xnext->cursp = stacklevel; |
742 | } |
745 | } |
743 | |
746 | |
744 | static struct coro * |
747 | static struct coro * |
745 | sv_to_coro (SV *arg, const char *funcname, const char *varname) |
748 | sv_to_coro (SV *arg, const char *funcname, const char *varname) |