Fix warnings in CgTailCall
[ghc-hetmet.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 void throwToSingleThreaded (Capability *cap,
17                             StgTSO *tso,
18                             StgClosure *exception);
19
20 void throwToSingleThreaded_ (Capability *cap, 
21                              StgTSO *tso, 
22                              StgClosure *exception, 
23                              rtsBool stop_at_atomically);
24
25 void suspendComputation (Capability *cap, 
26                          StgTSO *tso, 
27                          StgUpdateFrame *stop_here);
28
29 nat throwTo (Capability *cap,            // the Capability we hold 
30              StgTSO *source,             // the TSO sending the exception
31              StgTSO *target,             // the TSO receiving the exception
32              StgClosure *exception,      // the exception closure
33              /*[out]*/ void **out   // pass to throwToReleaseTarget()
34     );
35
36 #ifdef THREADED_RTS
37 void throwToReleaseTarget (void *tso);
38 #endif
39
40 int  maybePerformBlockedException (Capability *cap, StgTSO *tso);
41 void awakenBlockedExceptionQueue  (Capability *cap, StgTSO *tso);
42
43 /* Determine whether a thread is interruptible (ie. blocked
44  * indefinitely).  Interruptible threads can be sent an exception with
45  * killThread# even if they have async exceptions blocked.
46  */
47 INLINE_HEADER int
48 interruptible(StgTSO *t)
49 {
50   switch (t->why_blocked) {
51   case BlockedOnMVar:
52   case BlockedOnException:
53   case BlockedOnRead:
54   case BlockedOnWrite:
55 #if defined(mingw32_HOST_OS)
56   case BlockedOnDoProc:
57 #endif
58   case BlockedOnDelay:
59     return 1;
60   // NB. Threaded blocked on foreign calls (BlockedOnCCall) are
61   // *not* interruptible.  We can't send these threads an exception.
62   default:
63     return 0;
64   }
65 }
66
67 #endif /* CMINUSMINUS */
68
69 #endif /* RAISEASYNC_H */
70