… | |
… | |
90 | |
90 | |
91 | /* this is a structure representing a c-level coroutine */ |
91 | /* this is a structure representing a c-level coroutine */ |
92 | typedef struct coro_stack { |
92 | typedef struct coro_stack { |
93 | struct coro_stack *next; |
93 | struct coro_stack *next; |
94 | |
94 | |
95 | void *idle_sp; /* original stacklevel when coroutine was created */ |
95 | /* the stack */ |
96 | void *sptr; |
96 | void *sptr; |
97 | long ssize; /* positive == mmap, otherwise malloc */ |
97 | long ssize; /* positive == mmap, otherwise malloc */ |
98 | |
98 | |
99 | /* cpu state */ |
99 | /* cpu state */ |
|
|
100 | void *idle_sp; /* original stacklevel when coroutine was created */ |
|
|
101 | JMPENV *top_env; |
100 | coro_context cctx; |
102 | coro_context cctx; |
101 | JMPENV *top_env; |
|
|
102 | } coro_stack; |
103 | } coro_stack; |
103 | |
104 | |
104 | /* the (fake) coro_stack representing the main program */ |
105 | /* the (fake) coro_stack representing the main program */ |
105 | static coro_stack *main_stack; |
106 | static coro_stack *main_stack; |
106 | |
107 | |
… | |
… | |
584 | { |
585 | { |
585 | /* |
586 | /* |
586 | * this is a _very_ stripped down perl interpreter ;) |
587 | * this is a _very_ stripped down perl interpreter ;) |
587 | */ |
588 | */ |
588 | dTHX; |
589 | dTHX; |
|
|
590 | |
|
|
591 | UNLOCK; |
|
|
592 | |
589 | PL_top_env = &PL_start_env; |
593 | PL_top_env = &PL_start_env; |
590 | |
|
|
591 | UNLOCK; |
|
|
592 | |
594 | |
593 | sv_setiv (get_sv ("Coro::State::cctx_stack", FALSE), PTR2IV ((coro_stack *)arg)); |
595 | sv_setiv (get_sv ("Coro::State::cctx_stack", FALSE), PTR2IV ((coro_stack *)arg)); |
594 | sv_setiv (get_sv ("Coro::State::cctx_restartop", FALSE), PTR2IV (PL_op)); |
596 | sv_setiv (get_sv ("Coro::State::cctx_restartop", FALSE), PTR2IV (PL_op)); |
|
|
597 | |
|
|
598 | /* continue at cctx_init, without entersub */ |
595 | PL_restartop = CvSTART (get_cv ("Coro::State::cctx_init", FALSE)); |
599 | PL_restartop = CvSTART (get_cv ("Coro::State::cctx_init", FALSE)); |
596 | |
600 | |
597 | /* somebody will hit me for both perl_run and PL_restart_op */ |
601 | /* somebody will hit me for both perl_run and PL_restart_op */ |
598 | perl_run (aTHX_ PERL_GET_CONTEXT); |
602 | perl_run (aTHX_ PERL_GET_CONTEXT); |
599 | |
603 | |