[project @ 2005-10-21 14:02:17 by simonmar]
[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 #define handleSignalsInThisThread() /* nothing */
26
27 #endif /* PAR */
28
29
30 #if RTS_USER_SIGNALS
31
32 /*
33  * Function: initUserSignals()
34  *
35  * Initialize the console handling substrate.
36  */
37 extern void initUserSignals(void);
38
39 /*
40  * Function: initDefaultHandlers()
41  *
42  * Install any default signal/console handlers. Currently we install a
43  * Ctrl+C handler that shuts down the RTS in an orderly manner.
44  */
45 extern void initDefaultHandlers(void);
46
47 /*
48  * Function: blockUserSignals()
49  *
50  * Temporarily block the delivery of further console events. Needed to
51  * avoid race conditions when GCing the queue of outstanding handlers or
52  * when emptying the queue by running the handlers.
53  * 
54  */
55 extern void blockUserSignals(void);
56
57 /*
58  * Function: unblockUserSignals()
59  *
60  * The inverse of blockUserSignals(); re-enable the deliver of console events.
61  */
62 extern void unblockUserSignals(void);
63
64 /*
65  * Function: awaitUserSignals()
66  *
67  * Wait for the next console event. Currently a NOP (returns immediately.)
68  */
69 extern void awaitUserSignals(void);
70
71 /*
72  * Function: markSignalHandlers()
73  *
74  * Evacuate the handler queue. _Assumes_ that console event delivery
75  * has already been blocked.
76  */
77 extern void markSignalHandlers (evac_fn evac);
78
79 #endif /* RTS_USER_SIGNALS */
80
81 #endif /* RTS_SIGNALS_H */