5f7c99b05b47812dce440bcdc9fd82b18280afab
[ghc-hetmet.git] / ghc / rts / RtsSignals.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2005
4  *
5  * Signal processing / handling.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef RTS_SIGNALS_H
10 #define RTS_SIGNALS_H
11
12 #if !defined(PAR) && !defined(mingw32_HOST_OS)
13
14 #define RTS_USER_SIGNALS 1
15 #include "posix/Signals.h"
16
17 #elif defined(mingw32_HOST_OS)
18
19 #define RTS_USER_SIGNALS 1
20 #include "win32/ConsoleHandler.h"
21
22 #else /* PAR */
23
24 #define signals_pending() (rtsFalse)
25
26 #endif /* PAR */
27
28
29 #if RTS_USER_SIGNALS
30
31 /*
32  * Function: initUserSignals()
33  *
34  * Initialize the console handling substrate.
35  */
36 extern void initUserSignals(void);
37
38 /*
39  * Function: initDefaultHandlers()
40  *
41  * Install any default signal/console handlers. Currently we install a
42  * Ctrl+C handler that shuts down the RTS in an orderly manner.
43  */
44 extern void initDefaultHandlers(void);
45
46 /*
47  * Function: blockUserSignals()
48  *
49  * Temporarily block the delivery of further console events. Needed to
50  * avoid race conditions when GCing the queue of outstanding handlers or
51  * when emptying the queue by running the handlers.
52  * 
53  */
54 extern void blockUserSignals(void);
55
56 /*
57  * Function: unblockUserSignals()
58  *
59  * The inverse of blockUserSignals(); re-enable the deliver of console events.
60  */
61 extern void unblockUserSignals(void);
62
63 /*
64  * Function: awaitUserSignals()
65  *
66  * Wait for the next console event. Currently a NOP (returns immediately.)
67  */
68 extern void awaitUserSignals(void);
69
70 /*
71  * Function: markSignalHandlers()
72  *
73  * Evacuate the handler queue. _Assumes_ that console event delivery
74  * has already been blocked.
75  */
76 extern void markSignalHandlers (evac_fn evac);
77
78 #endif /* RTS_USER_SIGNALS */
79
80 #endif /* RTS_SIGNALS_H */