[project @ 1998-12-02 13:17:09 by simonm]
[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
7 #if __GLASGOW_HASKELL__ >= 400
8 #include "Rts.h"
9 #else
10 #include "rtsdefs.h"
11 #endif
12
13 #if __GLASGOW_HASKELL__ >= 303
14
15 void
16 ErrorHdrHook (long fd)
17 {
18     char msg[]="\n";
19     write(fd,msg,1);
20 }
21
22 void
23 PatErrorHdrHook (long fd)
24 {
25     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:";
26     write(fd,msg,sizeof(msg)-1);
27 }
28
29 void
30 PreTraceHook (long fd)
31 {
32     const char msg[]="\n";
33     write(fd,msg,sizeof(msg)-1);
34 }
35
36 void
37 PostTraceHook (long fd)
38 {
39 #if 0
40     const char msg[]="\n";
41     write(fd,msg,sizeof(msg)-1);
42 #endif
43 }
44
45 #else /* pre-3.03 GHC with old IO system */
46
47 void
48 ErrorHdrHook (FILE *where)
49 {
50     fprintf(where, "\n"); /* no "Fail: " */
51 }
52
53 void
54 PatErrorHdrHook (FILE *where)
55 {
56     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: ");
57 }
58
59 void
60 PreTraceHook (FILE *where)
61 {
62     fprintf(where, "\n"); /* not "Trace On" */
63 }
64
65 void
66 PostTraceHook (FILE *where)
67 {
68     fprintf(where, "\n"); /* not "Trace Off" */
69 }
70
71 #endif
72
73 #if __GLASGOW_HASKELL__ >= 400
74 void
75 OutOfHeapHook (unsigned long request_size, unsigned long heap_size)
76   /* both in bytes */
77 {
78     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",
79         request_size,
80         heap_size);
81 }
82
83 void
84 StackOverflowHook (unsigned long stack_size)    /* in bytes */
85 {
86     fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K<size>' option to increase it.\n", stack_size);
87 }
88
89 #else /* GHC < 4.00 */
90
91 void
92 OutOfHeapHook (W_ request_size, W_ heap_size)  /* both in bytes */
93 {
94     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",
95         request_size,
96         heap_size);
97 }
98
99 void
100 StackOverflowHook (I_ stack_size)    /* in bytes */
101 {
102     fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K<size>' option to increase it.\n", stack_size);
103 }
104
105 #endif