… | |
… | |
1416 | /* try to exit the same way perl's main function would do */ |
1416 | /* try to exit the same way perl's main function would do */ |
1417 | /* we do not bother resetting the environment or other things *7 |
1417 | /* we do not bother resetting the environment or other things *7 |
1418 | /* that are not, uhm, essential */ |
1418 | /* that are not, uhm, essential */ |
1419 | /* this obviously also doesn't work when perl is embedded */ |
1419 | /* this obviously also doesn't work when perl is embedded */ |
1420 | static void ecb_noinline ecb_cold |
1420 | static void ecb_noinline ecb_cold |
1421 | perlish_exit (void) |
1421 | perlish_exit (pTHX) |
1422 | { |
1422 | { |
1423 | int exitstatus = perl_destruct (PL_curinterp); |
1423 | int exitstatus = perl_destruct (PL_curinterp); |
1424 | perl_free (PL_curinterp); |
1424 | perl_free (PL_curinterp); |
1425 | exit (exitstatus); |
1425 | exit (exitstatus); |
1426 | } |
1426 | } |
… | |
… | |
1462 | * If perl-run returns we assume exit() was being called or the coro |
1462 | * If perl-run returns we assume exit() was being called or the coro |
1463 | * fell off the end, which seems to be the only valid (non-bug) |
1463 | * fell off the end, which seems to be the only valid (non-bug) |
1464 | * reason for perl_run to return. We try to mimic whatever perl is normally |
1464 | * reason for perl_run to return. We try to mimic whatever perl is normally |
1465 | * doing in that case. YMMV. |
1465 | * doing in that case. YMMV. |
1466 | */ |
1466 | */ |
1467 | perlish_exit (); |
1467 | perlish_exit (aTHX); |
1468 | } |
1468 | } |
1469 | } |
1469 | } |
1470 | |
1470 | |
1471 | static coro_cctx * |
1471 | static coro_cctx * |
1472 | cctx_new (void) |
1472 | cctx_new (void) |
… | |
… | |
1504 | size_t stack_size; |
1504 | size_t stack_size; |
1505 | |
1505 | |
1506 | #if HAVE_MMAP |
1506 | #if HAVE_MMAP |
1507 | cctx->ssize = ((cctx_stacksize * sizeof (long) + PAGESIZE - 1) / PAGESIZE + CORO_STACKGUARD) * PAGESIZE; |
1507 | cctx->ssize = ((cctx_stacksize * sizeof (long) + PAGESIZE - 1) / PAGESIZE + CORO_STACKGUARD) * PAGESIZE; |
1508 | /* mmap supposedly does allocate-on-write for us */ |
1508 | /* mmap supposedly does allocate-on-write for us */ |
1509 | cctx->sptr = mmap (0, cctx->ssize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS, 0, 0); |
1509 | cctx->sptr = mmap (0, cctx->ssize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS, -1, 0); |
1510 | |
1510 | |
1511 | if (cctx->sptr != (void *)-1) |
1511 | if (cctx->sptr != (void *)-1) |
1512 | { |
1512 | { |
1513 | #if CORO_STACKGUARD |
1513 | #if CORO_STACKGUARD |
1514 | mprotect (cctx->sptr, CORO_STACKGUARD * PAGESIZE, PROT_NONE); |
1514 | mprotect (cctx->sptr, CORO_STACKGUARD * PAGESIZE, PROT_NONE); |
… | |
… | |
3663 | RETVAL = boolSV (coro->flags & ix); |
3663 | RETVAL = boolSV (coro->flags & ix); |
3664 | OUTPUT: |
3664 | OUTPUT: |
3665 | RETVAL |
3665 | RETVAL |
3666 | |
3666 | |
3667 | void |
3667 | void |
3668 | throw (Coro::State self, SV *exception = &PL_sv_undef) |
3668 | throw (SV *self, SV *exception = &PL_sv_undef) |
3669 | PROTOTYPE: $;$ |
3669 | PROTOTYPE: $;$ |
3670 | CODE: |
3670 | CODE: |
3671 | { |
3671 | { |
|
|
3672 | struct coro *coro = SvSTATE (self); |
3672 | struct coro *current = SvSTATE_current; |
3673 | struct coro *current = SvSTATE_current; |
3673 | SV **exceptionp = self == current ? &CORO_THROW : &self->except; |
3674 | SV **exceptionp = coro == current ? &CORO_THROW : &coro->except; |
3674 | SvREFCNT_dec (*exceptionp); |
3675 | SvREFCNT_dec (*exceptionp); |
3675 | SvGETMAGIC (exception); |
3676 | SvGETMAGIC (exception); |
3676 | *exceptionp = SvOK (exception) ? newSVsv (exception) : 0; |
3677 | *exceptionp = SvOK (exception) ? newSVsv (exception) : 0; |
|
|
3678 | |
|
|
3679 | api_ready (aTHX_ self); |
3677 | } |
3680 | } |
3678 | |
3681 | |
3679 | void |
3682 | void |
3680 | api_trace (SV *coro, int flags = CC_TRACE | CC_TRACE_SUB) |
3683 | api_trace (SV *coro, int flags = CC_TRACE | CC_TRACE_SUB) |
3681 | PROTOTYPE: $;$ |
3684 | PROTOTYPE: $;$ |