From e60863045b4bc5b7c09d54f745d5d7ecc215f477 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 2 Apr 2007 13:40:48 +0000 Subject: [PATCH] 1.0.4.17: interrupt handler spring cleaning * interrupt_handle_now was always called with the real context, not a void context: remove the useless cast. Also fix FOREIGN_FUNCTION_CALL_FLAG usage there. * low_level_interrupt_handle_now was also always called with the real context, not a void context: useless cast is now gone. It also needs no FP control restoration or Darwin context fixage. * maybe_now_maybe_later and low_level_maybe_now_maybe_later were missing the Darwin context fix on one codepath. * interrupt_handle_now_handler was missing the FP control fixage. --- src/runtime/interrupt.c | 62 +++++++++++++++++------------------------------ src/runtime/interrupt.h | 2 +- src/runtime/ppc-arch.c | 4 +-- version.lisp-expr | 2 +- 4 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/runtime/interrupt.c b/src/runtime/interrupt.c index 7e278d1..8cdb01f 100644 --- a/src/runtime/interrupt.c +++ b/src/runtime/interrupt.c @@ -494,17 +494,15 @@ interrupt_handle_pending(os_context_t *context) */ void -interrupt_handle_now(int signal, siginfo_t *info, void *void_context) +interrupt_handle_now(int signal, siginfo_t *info, os_context_t *context) { - os_context_t *context = (os_context_t*)void_context; -#ifndef LISP_FEATURE_SB_THREAD +#ifdef FOREIGN_FUNCTION_CALL_FLAG boolean were_in_lisp; #endif union interrupt_handler handler; check_blockables_blocked_or_lose(); - #ifndef LISP_FEATURE_WIN32 if (sigismember(&deferrable_sigset,signal)) check_interrupts_enabled_or_lose(context); @@ -517,7 +515,6 @@ interrupt_handle_now(int signal, siginfo_t *info, void *void_context) os_restore_fp_control(context); #endif - handler = interrupt_handlers[signal]; if (ARE_SAME_HANDLER(handler.c, SIG_IGN)) { @@ -589,11 +586,10 @@ interrupt_handle_now(int signal, siginfo_t *info, void *void_context) /* Allow signals again. */ thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); #endif - - (*handler.c)(signal, info, void_context); + (*handler.c)(signal, info, context); } -#if !defined(LISP_FEATURE_X86) && !defined(LISP_FEATURE_X86_64) +#ifdef FOREIGN_FUNCTION_CALL_FLAG if (were_in_lisp) #endif { @@ -707,64 +703,47 @@ static void maybe_now_maybe_later(int signal, siginfo_t *info, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); - - struct thread *thread; - struct interrupt_data *data; - - thread=arch_os_get_current_thread(); - data=thread->interrupt_data; + struct thread *thread = arch_os_get_current_thread(); + struct interrupt_data *data = thread->interrupt_data; #if defined(LISP_FEATURE_LINUX) || defined(RESTORE_FP_CONTROL_FROM_CONTEXT) os_restore_fp_control(context); #endif - if(maybe_defer_handler(interrupt_handle_now,data,signal,info,context)) - return; - interrupt_handle_now(signal, info, context); + if(!maybe_defer_handler(interrupt_handle_now,data,signal,info,context)) + interrupt_handle_now(signal, info, context); + #ifdef LISP_FEATURE_DARWIN - /* Work around G5 bug */ DARWIN_FIX_CONTEXT(context); #endif } static void -low_level_interrupt_handle_now(int signal, siginfo_t *info, void *void_context) +low_level_interrupt_handle_now(int signal, siginfo_t *info, os_context_t *context) { - os_context_t *context = (os_context_t*)void_context; - -#if defined(LISP_FEATURE_LINUX) || defined(RESTORE_FP_CONTROL_FROM_CONTEXT) - os_restore_fp_control(context); -#endif - + /* No FP control fixage needed, caller has done that. */ check_blockables_blocked_or_lose(); check_interrupts_enabled_or_lose(context); - interrupt_low_level_handlers[signal](signal, info, void_context); -#ifdef LISP_FEATURE_DARWIN - /* Work around G5 bug */ - DARWIN_FIX_CONTEXT(context); -#endif + interrupt_low_level_handlers[signal](signal, info, context); + /* No Darwin context fixage needed, caller does that. */ } static void low_level_maybe_now_maybe_later(int signal, siginfo_t *info, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); - struct thread *thread; - struct interrupt_data *data; - - thread=arch_os_get_current_thread(); - data=thread->interrupt_data; + struct thread *thread = arch_os_get_current_thread(); + struct interrupt_data *data = thread->interrupt_data; #if defined(LISP_FEATURE_LINUX) || defined(RESTORE_FP_CONTROL_FROM_CONTEXT) os_restore_fp_control(context); #endif - if(maybe_defer_handler(low_level_interrupt_handle_now,data, - signal,info,context)) - return; - low_level_interrupt_handle_now(signal, info, context); + if(!maybe_defer_handler(low_level_interrupt_handle_now,data, + signal,info,context)) + low_level_interrupt_handle_now(signal, info, context); + #ifdef LISP_FEATURE_DARWIN - /* Work around G5 bug */ DARWIN_FIX_CONTEXT(context); #endif } @@ -834,6 +813,9 @@ void interrupt_handle_now_handler(int signal, siginfo_t *info, void *void_context) { os_context_t *context = arch_os_get_context(&void_context); +#if defined(LISP_FEATURE_LINUX) || defined(RESTORE_FP_CONTROL_FROM_CONTEXT) + os_restore_fp_control(context); +#endif interrupt_handle_now(signal, info, context); #ifdef LISP_FEATURE_DARWIN DARWIN_FIX_CONTEXT(context); diff --git a/src/runtime/interrupt.h b/src/runtime/interrupt.h index 405b354..e8a23b6 100644 --- a/src/runtime/interrupt.h +++ b/src/runtime/interrupt.h @@ -64,7 +64,7 @@ extern void interrupt_init(); extern void fake_foreign_function_call(os_context_t* context); extern void undo_fake_foreign_function_call(os_context_t* context); extern void arrange_return_to_lisp_function(os_context_t *, lispobj); -extern void interrupt_handle_now(int, siginfo_t*, void*); +extern void interrupt_handle_now(int, siginfo_t*, os_context_t*); extern void interrupt_handle_pending(os_context_t*); extern void interrupt_internal_error(os_context_t*, boolean continuable); extern boolean handle_guard_page_triggered(os_context_t *,os_vm_address_t); diff --git a/src/runtime/ppc-arch.c b/src/runtime/ppc-arch.c index 28c364b..55bc375 100644 --- a/src/runtime/ppc-arch.c +++ b/src/runtime/ppc-arch.c @@ -99,7 +99,7 @@ arch_clear_pseudo_atomic_interrupted(os_context_t *context) *os_context_register_addr(context,reg_ALLOC) &= ~1; } -unsigned int +unsigned int arch_install_breakpoint(void *pc) { unsigned int *ptr = (unsigned int *)pc; @@ -139,7 +139,7 @@ static sigset_t orig_sigmask; void arch_do_displaced_inst(os_context_t *context, unsigned int orig_inst) { - /* not sure how we ensure that we get the breakpoint reinstalled + /* not sure how we ensure that we get the breakpoint reinstalled * after doing this -dan */ unsigned int *pc = (unsigned int *)(*os_context_pc_addr(context)); diff --git a/version.lisp-expr b/version.lisp-expr index 4b8e5c5..9fe3ba6 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.4.16" +"1.0.4.17" -- 1.7.10.4