rts: Fix build
[ghc.git] / includes / rts / Flags.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2009
4 *
5 * Datatypes that holds the command-line flag settings.
6 *
7 * Do not #include this file directly: #include "Rts.h" instead.
8 *
9 * To understand the structure of the RTS headers, see the wiki:
10 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
11 *
12 * ---------------------------------------------------------------------------*/
13
14 #ifndef RTS_FLAGS_H
15 #define RTS_FLAGS_H
16
17 #include <stdio.h>
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include "stg/Types.h"
21 #include "Time.h"
22
23 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
24
25 /* Note [Synchronization of flags and base APIs]
26 *
27 * We provide accessors to RTS flags in base. (GHC.RTS module)
28 * The API should be updated whenever RTS flags are modified.
29 */
30
31 /* See Note [Synchronization of flags and base APIs] */
32 typedef struct _GC_FLAGS {
33 FILE *statsFile;
34 uint32_t giveStats;
35 #define NO_GC_STATS 0
36 #define COLLECT_GC_STATS 1
37 #define ONELINE_GC_STATS 2
38 #define SUMMARY_GC_STATS 3
39 #define VERBOSE_GC_STATS 4
40
41 uint32_t maxStkSize; /* in *words* */
42 uint32_t initialStkSize; /* in *words* */
43 uint32_t stkChunkSize; /* in *words* */
44 uint32_t stkChunkBufferSize; /* in *words* */
45
46 uint32_t maxHeapSize; /* in *blocks* */
47 uint32_t minAllocAreaSize; /* in *blocks* */
48 uint32_t largeAllocLim; /* in *blocks* */
49 uint32_t nurseryChunkSize; /* in *blocks* */
50 uint32_t minOldGenSize; /* in *blocks* */
51 uint32_t heapSizeSuggestion; /* in *blocks* */
52 bool heapSizeSuggestionAuto;
53 double oldGenFactor;
54 double pcFreeHeap;
55
56 uint32_t generations;
57 bool squeezeUpdFrames;
58
59 bool compact; /* True <=> "compact all the time" */
60 double compactThreshold;
61
62 bool sweep; /* use "mostly mark-sweep" instead of copying
63 * for the oldest generation */
64 bool ringBell;
65
66 Time idleGCDelayTime; /* units: TIME_RESOLUTION */
67 bool doIdleGC;
68
69 StgWord heapBase; /* address to ask the OS for memory */
70
71 StgWord allocLimitGrace; /* units: *blocks*
72 * After an AllocationLimitExceeded
73 * exception has been raised, how much
74 * extra space is given to the thread
75 * to handle the exception before we
76 * raise it again.
77 */
78 StgWord heapLimitGrace; /* units: *blocks*
79 * After a HeapOverflow exception has
80 * been raised, how much extra space is
81 * given to the thread to handle the
82 * exception before we raise it again.
83 */
84
85 bool numa; /* Use NUMA */
86 StgWord numaMask;
87 } GC_FLAGS;
88
89 /* See Note [Synchronization of flags and base APIs] */
90 typedef struct _DEBUG_FLAGS {
91 /* flags to control debugging output & extra checking in various subsystems */
92 bool scheduler; /* 's' */
93 bool interpreter; /* 'i' */
94 bool weak; /* 'w' */
95 bool gccafs; /* 'G' */
96 bool gc; /* 'g' */
97 bool block_alloc; /* 'b' */
98 bool sanity; /* 'S' warning: might be expensive! */
99 bool stable; /* 't' */
100 bool prof; /* 'p' */
101 bool linker; /* 'l' the object linker */
102 bool apply; /* 'a' */
103 bool stm; /* 'm' */
104 bool squeeze; /* 'z' stack squeezing & lazy blackholing */
105 bool hpc; /* 'c' coverage */
106 bool sparks; /* 'r' */
107 bool numa; /* '--debug-numa' */
108 bool compact; /* 'C' */
109 } DEBUG_FLAGS;
110
111 /* See Note [Synchronization of flags and base APIs] */
112 typedef struct _COST_CENTRE_FLAGS {
113 uint32_t doCostCentres;
114 # define COST_CENTRES_NONE 0
115 # define COST_CENTRES_SUMMARY 1
116 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
117 # define COST_CENTRES_ALL 3
118 # define COST_CENTRES_JSON 4
119
120 int profilerTicks; /* derived */
121 int msecsPerTick; /* derived */
122 char const *outputFileNameStem;
123 } COST_CENTRE_FLAGS;
124
125 /* See Note [Synchronization of flags and base APIs] */
126 typedef struct _PROFILING_FLAGS {
127 uint32_t doHeapProfile;
128 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
129 # define HEAP_BY_CCS 1
130 # define HEAP_BY_MOD 2
131 # define HEAP_BY_DESCR 4
132 # define HEAP_BY_TYPE 5
133 # define HEAP_BY_RETAINER 6
134 # define HEAP_BY_LDV 7
135
136 # define HEAP_BY_CLOSURE_TYPE 8
137
138 Time heapProfileInterval; /* time between samples */
139 uint32_t heapProfileIntervalTicks; /* ticks between samples (derived) */
140 bool includeTSOs;
141
142
143 bool showCCSOnException;
144
145 uint32_t maxRetainerSetSize;
146
147 uint32_t ccsLength;
148
149 const char* modSelector;
150 const char* descrSelector;
151 const char* typeSelector;
152 const char* ccSelector;
153 const char* ccsSelector;
154 const char* retainerSelector;
155 const char* bioSelector;
156
157 } PROFILING_FLAGS;
158
159 #define TRACE_NONE 0
160 #define TRACE_EVENTLOG 1
161 #define TRACE_STDERR 2
162
163 /* See Note [Synchronization of flags and base APIs] */
164 typedef struct _TRACE_FLAGS {
165 int tracing;
166 bool timestamp; /* show timestamp in stderr output */
167 bool scheduler; /* trace scheduler events */
168 bool gc; /* trace GC events */
169 bool sparks_sampled; /* trace spark events by a sampled method */
170 bool sparks_full; /* trace spark events 100% accurately */
171 bool user; /* trace user events (emitted from Haskell code) */
172 } TRACE_FLAGS;
173
174 /* See Note [Synchronization of flags and base APIs] */
175 typedef struct _CONCURRENT_FLAGS {
176 Time ctxtSwitchTime; /* units: TIME_RESOLUTION */
177 int ctxtSwitchTicks; /* derived */
178 } CONCURRENT_FLAGS;
179
180 /*
181 * The tickInterval is the time interval between "ticks", ie.
182 * timer signals (see Timer.{c,h}). It is the frequency at
183 * which we sample CCCS for profiling.
184 *
185 * It is changed by the +RTS -V<secs> flag.
186 */
187 #define DEFAULT_TICK_INTERVAL USToTime(10000)
188
189 /* See Note [Synchronization of flags and base APIs] */
190 typedef struct _MISC_FLAGS {
191 Time tickInterval; /* units: TIME_RESOLUTION */
192 bool install_signal_handlers;
193 bool machineReadable;
194 StgWord linkerMemBase; /* address to ask the OS for memory
195 * for the linker, NULL ==> off */
196 } MISC_FLAGS;
197
198 /* See Note [Synchronization of flags and base APIs] */
199 typedef struct _PAR_FLAGS {
200 uint32_t nCapabilities; /* number of threads to run simultaneously */
201 bool migrate; /* migrate threads between capabilities */
202 uint32_t maxLocalSparks;
203 bool parGcEnabled; /* enable parallel GC */
204 uint32_t parGcGen; /* do parallel GC in this generation
205 * and higher only */
206 bool parGcLoadBalancingEnabled;
207 /* enable load-balancing in the
208 * parallel GC */
209 uint32_t parGcLoadBalancingGen;
210 /* do load-balancing in this
211 * generation and higher only */
212
213 uint32_t parGcNoSyncWithIdle;
214 /* if a Capability has been idle for
215 * this many GCs, do not try to wake
216 * it up when doing a
217 * non-load-balancing parallel GC.
218 * (zero disables) */
219
220 uint32_t parGcThreads;
221 /* Use this many threads for parallel
222 * GC (default: use all nNodes). */
223
224 bool setAffinity; /* force thread affinity with CPUs */
225 } PAR_FLAGS;
226
227 /* See Note [Synchronization of flags and base APIs] */
228 typedef struct _TICKY_FLAGS {
229 bool showTickyStats;
230 FILE *tickyFile;
231 } TICKY_FLAGS;
232
233 /* Put them together: */
234
235 /* See Note [Synchronization of flags and base APIs] */
236 typedef struct _RTS_FLAGS {
237 /* The first portion of RTS_FLAGS is invariant. */
238 GC_FLAGS GcFlags;
239 CONCURRENT_FLAGS ConcFlags;
240 MISC_FLAGS MiscFlags;
241 DEBUG_FLAGS DebugFlags;
242 COST_CENTRE_FLAGS CcFlags;
243 PROFILING_FLAGS ProfFlags;
244 TRACE_FLAGS TraceFlags;
245 TICKY_FLAGS TickyFlags;
246 PAR_FLAGS ParFlags;
247 } RTS_FLAGS;
248
249 #ifdef COMPILING_RTS_MAIN
250 extern DLLIMPORT RTS_FLAGS RtsFlags;
251 #elif IN_STG_CODE
252 /* Hack because the C code generator can't generate '&label'. */
253 extern RTS_FLAGS RtsFlags[];
254 #else
255 extern RTS_FLAGS RtsFlags;
256 #endif
257
258 /*
259 * The printf formats are here, so we are less likely to make
260 * overly-long filenames (with disastrous results). No more than 128
261 * chars, please!
262 */
263
264 #define STATS_FILENAME_MAXLEN 128
265
266 #define GR_FILENAME_FMT "%0.124s.gr"
267 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
268 #define HP_FILENAME_FMT "%0.124s.hp"
269 #define LIFE_FILENAME_FMT "%0.122s.life"
270 #define PROF_FILENAME_FMT "%0.122s.prof"
271 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
272 #define QP_FILENAME_FMT "%0.124s.qp"
273 #define STAT_FILENAME_FMT "%0.122s.stat"
274 #define TICKY_FILENAME_FMT "%0.121s.ticky"
275 #define TIME_FILENAME_FMT "%0.122s.time"
276 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
277
278 /* an "int" so as to match normal "argc" */
279 /* Now defined in Stg.h (lib/std/cbits need these too.)
280 extern int prog_argc;
281 extern char **prog_argv;
282 */
283 extern int rts_argc; /* ditto */
284 extern char **rts_argv;
285
286 #endif /* RTS_FLAGS_H */