… | |
… | |
1410 | |
1410 | |
1411 | slf_frame.prepare = slf_prepare_set_stacklevel; |
1411 | slf_frame.prepare = slf_prepare_set_stacklevel; |
1412 | slf_frame.check = slf_check_set_stacklevel; |
1412 | slf_frame.check = slf_check_set_stacklevel; |
1413 | } |
1413 | } |
1414 | |
1414 | |
|
|
1415 | /* try to exit the same way perl's main function would do */ |
|
|
1416 | /* we do not bother resetting the environment or other things *7 |
|
|
1417 | /* that are not, uhm, essential */ |
|
|
1418 | /* this obviously also doesn't work when perl is embedded */ |
|
|
1419 | static void ecb_noinline ecb_cold |
|
|
1420 | perlish_exit (void) |
|
|
1421 | { |
|
|
1422 | int exitstatus = perl_destruct (PL_curinterp); |
|
|
1423 | perl_free (PL_curinterp); |
|
|
1424 | exit (exitstatus); |
|
|
1425 | } |
|
|
1426 | |
1415 | /* the tail of transfer: execute stuff we can only do after a transfer */ |
1427 | /* the tail of transfer: execute stuff we can only do after a transfer */ |
1416 | ecb_inline void |
1428 | ecb_inline void |
1417 | transfer_tail (pTHX) |
1429 | transfer_tail (pTHX) |
1418 | { |
1430 | { |
1419 | free_coro_mortal (aTHX); |
1431 | free_coro_mortal (aTHX); |
… | |
… | |
1453 | */ |
1465 | */ |
1454 | |
1466 | |
1455 | /* |
1467 | /* |
1456 | * If perl-run returns we assume exit() was being called or the coro |
1468 | * If perl-run returns we assume exit() was being called or the coro |
1457 | * fell off the end, which seems to be the only valid (non-bug) |
1469 | * fell off the end, which seems to be the only valid (non-bug) |
1458 | * reason for perl_run to return. We try to exit by jumping to the |
1470 | * reason for perl_run to return. We try to mimic whatever perl is normally |
1459 | * bootstrap-time "top" top_env, as we cannot restore the "main" |
1471 | * doing in that case. YMMV. |
1460 | * coroutine as Coro has no such concept. |
|
|
1461 | * This actually isn't valid with the pthread backend, but OSes requiring |
|
|
1462 | * that backend are too broken to do it in a standards-compliant way. |
|
|
1463 | */ |
1472 | */ |
1464 | PL_top_env = main_top_env; |
1473 | perlish_exit (); |
1465 | JMPENV_JUMP (2); /* I do not feel well about the hardcoded 2 at all */ |
|
|
1466 | } |
1474 | } |
1467 | } |
1475 | } |
1468 | |
1476 | |
1469 | static coro_cctx * |
1477 | static coro_cctx * |
1470 | cctx_new (void) |
1478 | cctx_new (void) |