… | |
… | |
469 | } |
469 | } |
470 | |
470 | |
471 | /* |
471 | /* |
472 | * allocate various perl stacks. This is an exact copy |
472 | * allocate various perl stacks. This is an exact copy |
473 | * of perl.c:init_stacks, except that it uses less memory |
473 | * of perl.c:init_stacks, except that it uses less memory |
474 | * on the assumption that coroutines do not usually need |
474 | * on the (sometimes correct) assumption that coroutines do |
475 | * a lot of stackspace. |
475 | * not usually need a lot of stackspace. |
476 | */ |
476 | */ |
477 | STATIC void |
477 | STATIC void |
478 | coro_init_stacks (pTHX) |
478 | coro_init_stacks (pTHX) |
479 | { |
479 | { |
480 | PL_curstackinfo = new_stackinfo(96, 1024/sizeof(PERL_CONTEXT) - 1); |
480 | PL_curstackinfo = new_stackinfo(96, 1024/sizeof(PERL_CONTEXT) - 1); |
… | |
… | |
519 | destroy_stacks(pTHX) |
519 | destroy_stacks(pTHX) |
520 | { |
520 | { |
521 | if (!IN_DESTRUCT) |
521 | if (!IN_DESTRUCT) |
522 | { |
522 | { |
523 | /* is this ugly, I ask? */ |
523 | /* is this ugly, I ask? */ |
524 | while (PL_scopestack_ix) |
524 | LEAVE_SCOPE (0); |
525 | LEAVE; |
|
|
526 | |
525 | |
527 | /* sure it is, but more important: is it correct?? :/ */ |
526 | /* sure it is, but more important: is it correct?? :/ */ |
528 | while (PL_tmps_ix > PL_tmps_floor) /* should only ever be one iteration */ |
|
|
529 | FREETMPS; |
527 | FREETMPS; |
530 | } |
528 | } |
531 | |
529 | |
532 | while (PL_curstackinfo->si_next) |
530 | while (PL_curstackinfo->si_next) |
533 | PL_curstackinfo = PL_curstackinfo->si_next; |
531 | PL_curstackinfo = PL_curstackinfo->si_next; |
534 | |
532 | |
… | |
… | |
620 | /* |
618 | /* |
621 | * emulate part of the perl startup here. |
619 | * emulate part of the perl startup here. |
622 | */ |
620 | */ |
623 | dSP; |
621 | dSP; |
624 | Coro__State ctx = (Coro__State)arg; |
622 | Coro__State ctx = (Coro__State)arg; |
625 | SV *sub_init = (SV*)get_cv(SUB_INIT, FALSE); |
623 | SV *sub_init = (SV *)get_cv (SUB_INIT, FALSE); |
626 | |
624 | |
627 | coro_init_stacks (aTHX); |
625 | coro_init_stacks (aTHX); |
628 | /*PL_curcop = 0;*/ |
626 | /*PL_curcop = 0;*/ |
629 | /*PL_in_eval = PL_in_eval;*/ /* inherit */ |
627 | /*PL_in_eval = PL_in_eval;*/ /* inherit */ |
630 | SvREFCNT_dec (GvAV (PL_defgv)); |
628 | SvREFCNT_dec (GvAV (PL_defgv)); |
… | |
… | |
1006 | void |
1004 | void |
1007 | _exit(code) |
1005 | _exit(code) |
1008 | int code |
1006 | int code |
1009 | PROTOTYPE: $ |
1007 | PROTOTYPE: $ |
1010 | CODE: |
1008 | CODE: |
1011 | #if defined(__GLIBC__) || _POSIX_C_SOURCE |
|
|
1012 | _exit (code); |
1009 | _exit (code); |
1013 | #else |
|
|
1014 | signal (SIGTERM, SIG_DFL); |
|
|
1015 | raise (SIGTERM); |
|
|
1016 | exit (code); |
|
|
1017 | #endif |
|
|
1018 | |
1010 | |
1019 | MODULE = Coro::State PACKAGE = Coro::Cont |
1011 | MODULE = Coro::State PACKAGE = Coro::Cont |
1020 | |
1012 | |
1021 | # this is slightly dirty (should expose a c-level api) |
1013 | # this is slightly dirty (should expose a c-level api) |
1022 | |
1014 | |