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