2 * This software is part of the SBCL system. See the README file for
5 * This software is derived from the CMU CL system, which was
6 * written at Carnegie Mellon University and released into the
7 * public domain. The software is in the public domain and is
8 * provided with absolutely no warranty. See the COPYING and CREDITS
9 * files for more information.
12 #if !defined(_INCLUDE_INTERRUPT_H_)
13 #define _INCLUDE_INTERRUPT_H_
17 /* maximum signal nesting depth
19 * Note: In CMU CL, this was 4096, but there was no explanation given,
20 * and it's hard to see why we'd need that many nested interrupts, so
21 * I've scaled it back (to 256) to see what happens. -- WHN 20000730
23 * Nothing happened, so let's creep it back a bit further -- dan 20030411 */
24 #define MAX_INTERRUPTS 32
26 union interrupt_handler {
28 void (*c)(int, siginfo_t*, void*);
31 struct interrupt_data {
32 void (*interrupt_low_level_handlers[NSIG]) (int, siginfo_t*, void*) ;
33 union interrupt_handler interrupt_handlers[NSIG];
35 /* signal information for pending signal. pending_signal=0 when there
36 * is no pending signal. */
37 void (*pending_handler) (int, siginfo_t*, void*) ;
39 siginfo_t pending_info;
40 sigset_t pending_mask;
44 extern void interrupt_init();
45 extern void fake_foreign_function_call(os_context_t* context);
46 extern void undo_fake_foreign_function_call(os_context_t* context);
47 extern void arrange_return_to_lisp_function(os_context_t *, lispobj);
48 extern void interrupt_handle_now(int, siginfo_t*, void*);
49 extern void interrupt_handle_pending(os_context_t*);
50 extern void interrupt_internal_error(int, siginfo_t*, os_context_t*,
52 extern boolean handle_guard_page_triggered(os_context_t *,void *);
53 extern boolean interrupt_maybe_gc(int, siginfo_t*, void*);
54 #ifdef LISP_FEATURE_SB_THREAD
55 extern void interrupt_thread_handler(int, siginfo_t*, void*);
56 extern void sig_stop_for_gc_handler(int, siginfo_t*, void*);
57 extern void thread_exit_handler(int, siginfo_t*, void*);
59 extern void undoably_install_low_level_interrupt_handler (int signal,
64 extern unsigned long install_handler(int signal,
65 void handler(int, siginfo_t*, void*));
67 extern union interrupt_handler interrupt_handlers[NSIG];
69 /* Set all blockable signals into *s. */
70 void sigaddset_blockable(sigset_t *s);
72 /* The void* casting here avoids having to mess with the various types
73 * of function argument lists possible for signal handlers:
74 * SA_SIGACTION handlers have one signature, and the default old-style
75 * signal(..) handlers have another, and attempting to represent them
76 * "cleanly" with union types is in fact a mess. */
77 #define ARE_SAME_HANDLER(x, y) ((void*)(x) == (void*)(y))