Omit visibility pragmas on Windows (fixes warnings/validate failures)
[ghc.git] / rts / RaiseAsync.h
1 /* ---------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2006
4 *
5 * Asynchronous exceptions
6 *
7 * --------------------------------------------------------------------------*/
8
9 #ifndef RAISEASYNC_H
10 #define RAISEASYNC_H
11
12 #define THROWTO_SUCCESS 0
13 #define THROWTO_BLOCKED 1
14
15 #ifndef CMINUSMINUS
16
17 BEGIN_RTS_PRIVATE
18
19 void throwToSingleThreaded (Capability *cap,
20 StgTSO *tso,
21 StgClosure *exception);
22
23 void throwToSingleThreaded_ (Capability *cap,
24 StgTSO *tso,
25 StgClosure *exception,
26 rtsBool stop_at_atomically);
27
28 void suspendComputation (Capability *cap,
29 StgTSO *tso,
30 StgUpdateFrame *stop_here);
31
32 nat throwTo (Capability *cap, // the Capability we hold
33 StgTSO *source, // the TSO sending the exception
34 StgTSO *target, // the TSO receiving the exception
35 StgClosure *exception, // the exception closure
36 /*[out]*/ void **out // pass to throwToReleaseTarget()
37 );
38
39 #ifdef THREADED_RTS
40 void throwToReleaseTarget (void *tso);
41 #endif
42
43 int maybePerformBlockedException (Capability *cap, StgTSO *tso);
44 void awakenBlockedExceptionQueue (Capability *cap, StgTSO *tso);
45
46 /* Determine whether a thread is interruptible (ie. blocked
47 * indefinitely). Interruptible threads can be sent an exception with
48 * killThread# even if they have async exceptions blocked.
49 */
50 INLINE_HEADER int
51 interruptible(StgTSO *t)
52 {
53 switch (t->why_blocked) {
54 case BlockedOnMVar:
55 case BlockedOnException:
56 case BlockedOnRead:
57 case BlockedOnWrite:
58 #if defined(mingw32_HOST_OS)
59 case BlockedOnDoProc:
60 #endif
61 case BlockedOnDelay:
62 return 1;
63 // NB. Threaded blocked on foreign calls (BlockedOnCCall) are
64 // *not* interruptible. We can't send these threads an exception.
65 default:
66 return 0;
67 }
68 }
69
70 END_RTS_PRIVATE
71
72 #endif /* CMINUSMINUS */
73
74 #endif /* RAISEASYNC_H */
75