Ensure runhaskell is rebuild in stage2
[ghc-hetmet.git] / rts / win32 / ConsoleHandler.h
1 /*
2  * Console control handler support.
3  *
4  */
5 #ifndef __CONSOLEHANDLER_H__
6 #define __CONSOLEHANDLER_H__
7
8 /*
9  * Console control handlers lets an application handle Ctrl+C, Ctrl+Break etc.
10  * in Haskell under Win32. Akin to the Unix signal SIGINT.
11  *
12  * The API offered by ConsoleHandler.h is identical to that of the
13  * signal handling code (which isn't supported under win32.)
14  * Unsurprisingly, the underlying impl is derived from the signal
15  * handling code also.
16  */
17
18 #if !defined(THREADED_RTS)
19 /* 
20  * under THREADED_RTS, console events are passed to the IO manager
21  * thread, which starts up the handler.  See ThrIOManager.c.
22  */
23
24 /*
25  * Function: signals_pending() 
26  * 
27  * Used by the RTS to check whether new signals have been 'recently' reported.
28  * If so, the RTS arranges for the delivered signals to be handled by 
29  * de-queueing them from their table, running the associated Haskell 
30  * signal handler.
31  */
32 extern StgInt stg_pending_events;
33
34 #define signals_pending() ( stg_pending_events > 0)
35
36 /* 
37  * Function: anyUserHandlers()
38  *
39  * Used by the Scheduler to decide whether its worth its while to stick
40  * around waiting for an external signal when there are no threads
41  * runnable. A console handler is used to handle termination events (Ctrl+C)
42  * and isn't considered a 'user handler'.
43  */
44 #define anyUserHandlers() (rtsFalse)
45
46 /*
47  * Function: startSignalHandlers()
48  *
49  * Run the handlers associated with the queued up console events. Console
50  * event delivery is blocked for the duration of this call.
51  */
52 extern void startSignalHandlers(Capability *cap);
53
54 /*
55  * Function: handleSignalsInThisThread()
56  * 
57  * Have current (OS) thread assume responsibility of handling console events/signals.
58  * Currently not used (by the console event handling code.)
59  */
60 extern void handleSignalsInThisThread(void);
61
62 /*
63  * Function: rts_waitConsoleHandlerCompletion()
64  *
65  * Esoteric entry point used by worker thread that got woken
66  * up as part Ctrl-C delivery.
67  */
68 extern int rts_waitConsoleHandlerCompletion(void);
69
70 #endif /* THREADED_RTS */
71
72 #endif /* __CONSOLEHANDLER_H__ */