5f848fee6995304c2eb846ea891c8970222206ff
[ghc-hetmet.git] / ghc / compiler / parser / 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 #include <stdio.h>
7
8 /* Included so as to bring the right prototypes into scope */
9 #include "rtsdefs.h"
10
11 #define W_ unsigned long int
12 #define I_ long int
13
14 #if __GLASGOW_HASKELL__ >= 303
15 void
16 ErrorHdrHook (long fd)
17 {
18     char msg[]="\n";
19     write(fd,msg,1);
20 }
21 #else
22 void
23 ErrorHdrHook (FILE *where)
24 {
25     fprintf(where, "\n"); /* no "Fail: " */
26 }
27 #endif
28
29 void
30 OutOfHeapHook (W_ request_size, W_ heap_size)  /* both in bytes */
31 {
32     fprintf(stderr, "GHC's heap exhausted;\nwhile trying to allocate %lu bytes in a %lu-byte heap;\nuse the `-H<size>' option to increase the total heap size.\n",
33         request_size,
34         heap_size);
35 }
36
37 void
38 StackOverflowHook (I_ stack_size)    /* in bytes */
39 {
40     fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K<size>' option to increase it.\n", stack_size);
41 }
42
43 #if __GLASGOW_HASKELL__ >= 303
44 void
45 PatErrorHdrHook (long fd)
46 {
47     const char msg[]="\n*** Pattern-matching error within GHC!\n\nThis is a compiler bug; please report it to glasgow-haskell-bugs@dcs.gla.ac.uk.\n\nFail:";
48     write(fd,msg,sizeof(msg)-1);
49 }
50
51 void
52 PreTraceHook (long fd)
53 {
54     const char msg[]="\n";
55     write(fd,msg,sizeof(msg)-1);
56 }
57
58 void
59 PostTraceHook (long fd)
60 {
61 #if 0
62     const char msg[]="\n";
63     write(fd,msg,sizeof(msg)-1);
64 #endif
65 }
66
67 #else
68 void
69 PatErrorHdrHook (FILE *where)
70 {
71     fprintf(where, "\n*** Pattern-matching error within GHC!\n\nThis is a compiler bug; please report it to glasgow-haskell-bugs@dcs.gla.ac.uk.\n\nFail: ");
72 }
73
74 void
75 PreTraceHook (FILE *where)
76 {
77     fprintf(where, "\n"); /* not "Trace On" */
78 }
79
80 void
81 PostTraceHook (FILE *where)
82 {
83     fprintf(where, "\n"); /* not "Trace Off" */
84 }
85 #endif