cpp: Use #pragma once instead of #ifndef guards
[ghc.git] / includes / rts / Threads.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2009
4 *
5 * External API for the scheduler. For most uses, the functions in
6 * RtsAPI.h should be enough.
7 *
8 * Do not #include this file directly: #include "Rts.h" instead.
9 *
10 * To understand the structure of the RTS headers, see the wiki:
11 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
12 *
13 * ---------------------------------------------------------------------------*/
14
15 #pragma once
16
17 #ifdef HAVE_SYS_TYPES_H
18 #include <sys/types.h>
19 #endif
20
21 //
22 // Creating threads
23 //
24 StgTSO *createThread (Capability *cap, W_ stack_size);
25
26 void scheduleWaitThread (/* in */ StgTSO *tso,
27 /* out */ HaskellObj* ret,
28 /* inout */ Capability **cap);
29
30 StgTSO *createGenThread (Capability *cap, W_ stack_size,
31 StgClosure *closure);
32 StgTSO *createIOThread (Capability *cap, W_ stack_size,
33 StgClosure *closure);
34 StgTSO *createStrictIOThread (Capability *cap, W_ stack_size,
35 StgClosure *closure);
36
37 // Suspending/resuming threads around foreign calls
38 void * suspendThread (StgRegTable *, bool interruptible);
39 StgRegTable * resumeThread (void *);
40
41 //
42 // Thread operations from Threads.c
43 //
44 int cmp_thread (StgPtr tso1, StgPtr tso2);
45 int rts_getThreadId (StgPtr tso);
46 HsInt64 rts_getThreadAllocationCounter (StgPtr tso);
47 void rts_setThreadAllocationCounter (StgPtr tso, HsInt64 i);
48 void rts_enableThreadAllocationLimit (StgPtr tso);
49 void rts_disableThreadAllocationLimit (StgPtr tso);
50
51 #if !defined(mingw32_HOST_OS)
52 pid_t forkProcess (HsStablePtr *entry);
53 #else
54 pid_t forkProcess (HsStablePtr *entry)
55 GNU_ATTRIBUTE(__noreturn__);
56 #endif
57
58 HsBool rtsSupportsBoundThreads (void);
59
60 // The number of Capabilities.
61 // ToDo: I would like this to be private to the RTS and instead expose a
62 // function getNumCapabilities(), but it is used in compiler/cbits/genSym.c
63 extern unsigned int n_capabilities;
64
65 // The number of Capabilities that are not disabled
66 extern uint32_t enabled_capabilities;
67
68 #if !IN_STG_CODE
69 extern Capability MainCapability;
70 #endif
71
72 //
73 // Change the number of capabilities (only supports increasing the
74 // current value at the moment).
75 //
76 extern void setNumCapabilities (uint32_t new_);