Merge branch 'master' of http://darcs.haskell.org/ghc
[ghc.git] / ghc / hschooks.c
1 /*
2 These routines customise the error messages
3 for various bits of the RTS. They are linked
4 in instead of the defaults.
5 */
6
7 #include "../rts/PosixSource.h"
8 #include "Rts.h"
9
10 #include "HsFFI.h"
11
12 #include <string.h>
13
14 #ifdef HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif
17
18 void
19 defaultsHook (void)
20 {
21 #if __GLASGOW_HASKELL__ >= 707
22 // This helps particularly with large compiles, but didn't work
23 // very well with earlier GHCs because it caused large amounts of
24 // fragmentation. See rts/sm/BlockAlloc.c:allocLargeChunk().
25 RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue;
26 #else
27 RtsFlags.GcFlags.heapSizeSuggestion = 6*1024*1024 / BLOCK_SIZE;
28 #endif
29
30 RtsFlags.GcFlags.maxStkSize = 512*1024*1024 / sizeof(W_);
31 RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS;
32
33 // See #3408: the default idle GC time of 0.3s is too short on
34 // Windows where we receive console events once per second or so.
35 #if __GLASGOW_HASKELL__ >= 703
36 RtsFlags.GcFlags.idleGCDelayTime = SecondsToTime(5);
37 #else
38 RtsFlags.GcFlags.idleGCDelayTime = 5*1000;
39 #endif
40 }
41
42 void
43 StackOverflowHook (StgWord stack_size) /* in bytes */
44 {
45 fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K<size>' option to increase it.\n", (size_t)stack_size);
46 }
47