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