f71a177f6b25fb8cc08dd0d98aebbf525f799d98
[sbcl.git] / src / runtime / interrupt.h
1 /*
2  * This software is part of the SBCL system. See the README file for
3  * more information.
4  *
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.
10  */
11
12 /*
13  * $Header$
14  */
15
16 #if !defined(_INCLUDE_INTERRUPT_H_)
17 #define _INCLUDE_INTERRUPT_H_
18
19 #include <signal.h>
20
21 /* maximum signal nesting depth
22  *
23  * Note: In CMU CL, this was 4096, but there was no explanation given,
24  * and it's hard to see why we'd need that many nested interrupts, so
25  * I've scaled it back to see what happens. -- WHN 20000730 */
26 #define MAX_INTERRUPTS 256
27
28 extern os_context_t *lisp_interrupt_contexts[MAX_INTERRUPTS];
29
30 union interrupt_handler {
31         lispobj lisp;
32         void (*c)(int, siginfo_t*, void*);
33 };
34
35 extern void interrupt_init(void);
36 extern void fake_foreign_function_call(os_context_t* context);
37 extern void undo_fake_foreign_function_call(os_context_t* context);
38 extern void interrupt_handle_now(int, siginfo_t*, void*);
39 extern void interrupt_handle_pending(os_context_t*);
40 extern void interrupt_internal_error(int, siginfo_t*, os_context_t*,
41                                      boolean continuable);
42 extern boolean interrupt_maybe_gc(int, siginfo_t*, void*);
43 extern void interrupt_install_low_level_handler (int signal,
44                                                  void handler(int,
45                                                               siginfo_t*,
46                                                               void*));
47 extern unsigned long install_handler(int signal,
48                                      void handler(int, siginfo_t*, void*));
49
50 extern union interrupt_handler interrupt_handlers[NSIG];
51
52 /* Set all blockable signals into *s. */
53 void sigaddset_blockable(sigset_t *s);
54
55 /* The void* casting here avoids having to mess with the various types
56  * of function argument lists possible for signal handlers:
57  * SA_SIGACTION handlers have one signature, and the default old-style
58  * signal(..) handlers have another, and attempting to represent them
59  * "cleanly" with union types is in fact a mess. */
60 #define ARE_SAME_HANDLER(x, y) ((void*)(x) == (void*)(y))
61 #endif