diff --git a/v/loop.c b/v/loop.c index b1e76dd5e..c6a588d80 100644 --- a/v/loop.c +++ b/v/loop.c @@ -42,6 +42,14 @@ typedef enum { volatile u2_kill Sigcause; // reasons for exception +static void _lo_cont(void *arg1, void *arg2, void *arg3) +{ + (void)(arg1); + (void)(arg2); + (void)(arg3); + siglongjmp(Signal_buf, 1); +} + static void _lo_signal_handle_over(int emergency, stackoverflow_context_t scp) { @@ -60,7 +68,7 @@ _lo_signal_handle_over(int emergency, stackoverflow_context_t scp) #endif { Sigcause = sig_overflow; - longjmp(Signal_buf, 1); + sigsegv_leave_handler(_lo_cont, NULL, NULL, NULL); } } @@ -329,7 +337,7 @@ u2_lo_soft(u2_reck* rec_u, c3_w sec_w, u2_funk fun_f, u2_noun arg) u2_unix_ef_hold(); _lo_signal_deep(sec_w); - if ( 0 != setjmp(Signal_buf) ) { + if ( 0 != sigsetjmp(Signal_buf, 1) ) { u2_noun tax, pre, mok; // return to blank state diff --git a/v/main.c b/v/main.c index 64fb278dd..ec50a5ed5 100644 --- a/v/main.c +++ b/v/main.c @@ -246,6 +246,14 @@ static uint8_t Sigstk[SIGSTKSZ]; volatile enum { sig_none, sig_overflow, sig_interrupt } Sigcause; +static void _main_cont(void *arg1, void *arg2, void *arg3) +{ + (void)(arg1); + (void)(arg2); + (void)(arg3); + siglongjmp(Signal_buf, 1); +} + static void overflow_handler(int emergency, stackoverflow_context_t scp) { @@ -254,7 +262,7 @@ overflow_handler(int emergency, stackoverflow_context_t scp) exit(1); } else { Sigcause = sig_overflow; - longjmp(Signal_buf, 1); + sigsegv_leave_handler(_main_cont, NULL, NULL, NULL); } } @@ -367,7 +375,7 @@ main(c3_i argc, // we get a signal, we force the system back into the just-booted state. // If anything goes wrong during boot (above), it's curtains. { - if ( 0 != setjmp(Signal_buf) ) { + if ( 0 != sigsetjmp(Signal_buf, 1) ) { switch ( Sigcause ) { case sig_overflow: printf("[stack overflow]\r\n"); break; case sig_interrupt: printf("[interrupt]\r\n"); break;