>From 37d0324ad2e4b0ad7f2b5ca470c3fdc9057680e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20F=2E=20Wittenberger?= Date: Mon, 30 Nov 2015 12:57:46 +0100 Subject: [PATCH] allow signal handlers to be called from any thread --- runtime.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/runtime.c b/runtime.c index 9d93476..7292204 100644 --- a/runtime.c +++ b/runtime.c @@ -386,7 +386,7 @@ static C_TLS C_word **collectibles, **collectibles_top, **collectibles_limit, - *saved_stack_limit, + *saved_stack_limit = NULL, **mutation_stack_bottom, **mutation_stack_limit, **mutation_stack_top, @@ -3684,6 +3684,7 @@ void handle_interrupt(void *trampoline) /* Restore state to the one at the time of the interrupt: */ C_temporary_stack = C_temporary_stack_bottom; C_stack_limit = saved_stack_limit; + saved_stack_limit = NULL; /* Invoke high-level interrupt handler: */ reason = C_fix(pending_interrupts[ --pending_interrupts_count ]); @@ -4395,17 +4396,12 @@ C_regparm void C_fcall C_paranoid_check_for_interrupt(void) C_regparm void C_fcall C_raise_interrupt(int reason) { if(C_interrupts_enabled) { - if(pending_interrupts_count == 0 && !handling_interrupts) { + if(pending_interrupts_count == 0 && saved_stack_limit == NULL && !handling_interrupts) { /* Force the next stack check to fail by faking a "full" stack. That causes save_and_reclaim() to be called, which will invoke handle_interrupt() (which restores the stack limit). */ saved_stack_limit = C_stack_limit; - -#if C_STACK_GROWS_DOWNWARD - C_stack_limit = C_stack_pointer + 1000; -#else - C_stack_limit = C_stack_pointer - 1000; -#endif + C_stack_limit = stack_bottom; interrupt_time = C_cpu_milliseconds(); pending_interrupts[ pending_interrupts_count++ ] = reason; } else if(pending_interrupts_count < MAX_PENDING_INTERRUPTS) { -- 2.6.2