root/rts/win32/ConsoleHandler.h

Revision a2a67cd520b9841114d69a87a423dabcb3b4368e, 1.8 KB (checked in by Simon Marlow <marlowsd@…>, 3 years ago)

RTS tidyup sweep, first phase

The first phase of this tidyup is focussed on the header files, and in
particular making sure we are exposinng publicly exactly what we need
to, and no more.

  • Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it.
  • Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h.
  • All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory.
  • I left MachDeps?.h where it is, because it is so widely used in Haskell code.


  • I left a deprecated stub for RtsFlags?.h in place. The flag structures are now exposed by Rts.h.
  • Various internal APIs are no longer exposed by public header files.
  • Various bits of dead code and declarations have been removed
  • More gcc warnings are turned on, and the RTS code is more warning-clean.
  • More source files #include "PosixSource?.h", and hence only use standard POSIX (1003.1c-1995) interfaces.

There is a lot more tidying up still to do, this is just the first
pass. I also intend to standardise the names for external RTS APIs
(e.g use the rts_ prefix consistently), and declare the internal APIs
as hidden for shared libraries.

  • Property mode set to 100644
Line 
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 */
32extern 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 */
52extern 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 */
60extern int rts_waitConsoleHandlerCompletion(void);
61
62#endif /* THREADED_RTS */
63
64#endif /* Win32_CONSOLEHANDLER_H */
Note: See TracBrowser for help on using the browser.