Revert "rts: add Emacs 'Local Variables' to every .c file"
[ghc.git] / rts / win32 / ConsoleHandler.h
1 /*
2 * Console control handler support.
3 *
4 */
5 #ifndef WIN32_CONSOLEHANDLER_H
6 #define WIN32_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: rts_waitConsoleHandlerCompletion()
56 *
57 * Esoteric entry point used by worker thread that got woken
58 * up as part Ctrl-C delivery.
59 */
60 extern int rts_waitConsoleHandlerCompletion(void);
61
62 #endif /* THREADED_RTS */
63
64 #endif /* Win32_CONSOLEHANDLER_H */