X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Finterrupt.h;h=4f2b0978f6f5625bc4f9858903710c4c4e7bc4ec;hb=cf507f95509a855a752b6f1771aa06877b8a3b30;hp=d26df2855c43510310922a23ad449ccbfd5eba8d;hpb=584bfdc4e1093e43e4eb328a418b012745935a29;p=sbcl.git diff --git a/src/runtime/interrupt.h b/src/runtime/interrupt.h index d26df28..4f2b097 100644 --- a/src/runtime/interrupt.h +++ b/src/runtime/interrupt.h @@ -26,28 +26,77 @@ /* FIXME: do not rely on NSIG being a multiple of 8 */ #define REAL_SIGSET_SIZE_BYTES ((NSIG/8)) -extern void check_blockables_blocked_or_lose(void); -extern void check_gc_signals_unblocked_or_lose(void); -extern void unblock_gc_signals(void); - static inline void sigcopyset(sigset_t *new, sigset_t *old) { memcpy(new, old, REAL_SIGSET_SIZE_BYTES); } +extern void get_current_sigmask(sigset_t *sigset); + +/* Set all deferrable signals into *s. */ +extern void sigaddset_deferrable(sigset_t *s); +/* Set all blockable signals into *s. */ +extern void sigaddset_blockable(sigset_t *s); +/* Set all gc signals into *s. */ +extern void sigaddset_gc(sigset_t *s); + +extern sigset_t deferrable_sigset; +extern sigset_t blockable_sigset; +extern sigset_t gc_sigset; + +extern boolean deferrables_blocked_p(sigset_t *sigset); +extern boolean blockables_blocked_p(sigset_t *sigset); +extern boolean gc_signals_blocked_p(sigset_t *sigset); + +extern void check_deferrables_blocked_or_lose(sigset_t *sigset); +extern void check_blockables_blocked_or_lose(sigset_t *sigset); +extern void check_gc_signals_blocked_or_lose(sigset_t *sigset); + +extern void check_deferrables_unblocked_or_lose(sigset_t *sigset); +extern void check_blockables_unblocked_or_lose(sigset_t *sigset); +extern void check_gc_signals_unblocked_or_lose(sigset_t *sigset); + +extern void block_deferrable_signals(sigset_t *where, sigset_t *old); +extern void block_blockable_signals(sigset_t *where, sigset_t *old); +extern void block_gc_signals(sigset_t *where, sigset_t *old); + +extern void unblock_deferrable_signals(sigset_t *where, sigset_t *old); +extern void unblock_blockable_signals(sigset_t *where, sigset_t *old); +extern void unblock_gc_signals(sigset_t *where, sigset_t *old); + +extern void maybe_save_gc_mask_and_block_deferrables(sigset_t *sigset); + /* maximum signal nesting depth * - * Note: In CMU CL, this was 4096, but there was no explanation given, - * and it's hard to see why we'd need that many nested interrupts, so - * I've scaled it back (to 256) to see what happens. -- WHN 20000730 - - * Nothing happened, so let's creep it back a bit further -- dan 20030411 */ -#define MAX_INTERRUPTS 32 + * FIXME: In CMUCL this was 4096, and it was first scaled down to 256 + * and then 32, until finally Stumpwm broke: it is possible to receive + * interrupts in sufficiently quick succession that handler nesting + * can become preposterous. Scaling this back up to 1024 is a bandaid: + * for a real fix we should consider the following things: + * + * We should almost certainly always use + * arrange_return_to_lisp_function, though it needs to be thought + * about arguments, and it needs to be able to pass a frobbable + * context to the callee... + * + * There are cases when nesting handlers is exactly what we want: + * eg. SIGINT. + * + * There are cases when we probably want to drop duplicate signals + * on the floor if they arrive before the previous one has been handled. + * Eg. SIGPROF. + * + * There are cases when we probably want to handle duplicate signals + * after the previous handler has returned, not before. Eg. SIGALARM. + * + * -- NS 2007-01-29 + */ +#define MAX_INTERRUPTS 1024 union interrupt_handler { lispobj lisp; - void (*c)(int, siginfo_t*, void*); + void (*c)(int, siginfo_t*, os_context_t*); }; extern union interrupt_handler interrupt_handlers[NSIG]; @@ -55,13 +104,18 @@ extern union interrupt_handler interrupt_handlers[NSIG]; struct interrupt_data { /* signal information for pending signal. pending_signal=0 when there * is no pending signal. */ - void (*pending_handler) (int, siginfo_t*, void*) ; + void (*pending_handler) (int, siginfo_t*, os_context_t*) ; int pending_signal; siginfo_t pending_info; sigset_t pending_mask; + /* Was pending mask saved for gc request? True if GC_PENDING or + * SIG_STOP_FOR_GC happened in a pseudo atomic with no GC_INHIBIT + * NIL. Both deferrable interrupt handlers and gc are careful not + * to clobber each other's pending_mask. */ + boolean gc_blocked_deferrables; }; - +extern boolean interrupt_handler_pending_p(void); extern void interrupt_init(void); extern void fake_foreign_function_call(os_context_t* context); extern void undo_fake_foreign_function_call(os_context_t* context); @@ -79,10 +133,9 @@ extern void do_pending_interrupt(void); #endif #ifdef LISP_FEATURE_SB_THREAD -extern void interrupt_thread_handler(int, siginfo_t*, void*); -extern void sig_stop_for_gc_handler(int, siginfo_t*, void*); +extern void sig_stop_for_gc_handler(int, siginfo_t*, os_context_t*); #endif -typedef void (*interrupt_handler_t)(int, siginfo_t *, void *); +typedef void (*interrupt_handler_t)(int, siginfo_t *, os_context_t *); extern void undoably_install_low_level_interrupt_handler ( int signal, interrupt_handler_t handler); @@ -91,13 +144,6 @@ extern unsigned long install_handler(int signal, extern union interrupt_handler interrupt_handlers[NSIG]; -/* Set all deferrable signals into *s. */ -extern void sigaddset_deferrable(sigset_t *s); -/* Set all blockable signals into *s. */ -extern void sigaddset_blockable(sigset_t *s); - -extern void block_blockable_signals(void); - /* The void* casting here avoids having to mess with the various types * of function argument lists possible for signal handlers: * SA_SIGACTION handlers have one signature, and the default old-style @@ -108,7 +154,8 @@ extern void block_blockable_signals(void); extern void handle_trap(os_context_t *context, int trap); #ifndef LISP_FEATURE_WIN32 -extern void lisp_memory_fault_error(os_context_t *context, os_vm_address_t addr); +extern void lisp_memory_fault_error(os_context_t *context, + os_vm_address_t addr); #endif #endif