X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fparser%2Fhschooks.c;h=b44c04966bb1b8509f45b8ea360f4d962789cdc7;hb=266d38920b7292bd75d959b3c2c263a2b025da17;hp=27008397128d230be19684d972a572110c6dcfe6;hpb=6c381e873e222417d9a67aeec77b9555eca7b7a8;p=ghc-hetmet.git diff --git a/ghc/compiler/parser/hschooks.c b/ghc/compiler/parser/hschooks.c index 2700839..b44c049 100644 --- a/ghc/compiler/parser/hschooks.c +++ b/ghc/compiler/parser/hschooks.c @@ -3,64 +3,103 @@ These routines customise the error messages for various bits of the RTS. They are linked in instead of the defaults. */ -#include -#define W_ unsigned long int -#define I_ long int +#if __GLASGOW_HASKELL__ >= 400 +#include "Rts.h" +#else +#include "rtsdefs.h" +#endif + +#if __GLASGOW_HASKELL__ >= 303 void -ErrorHdrHook (where) - FILE *where; +ErrorHdrHook (long fd) { - fprintf(where, "\n"); /* no "Fail: " */ + char msg[]="\n"; + write(fd,msg,1); } - void -OutOfHeapHook (request_size, heap_size) - W_ request_size; /* in bytes */ - W_ heap_size; /* in bytes */ +PatErrorHdrHook (long fd) { - fprintf(stderr, "GHC's heap exhausted;\nwhile trying to allocate %lu bytes in a %lu-byte heap;\nuse the `-H' option to increase the total heap size.\n", - request_size, - heap_size); + const char msg[]="\n*** Pattern-matching error within GHC!\n\nThis is a compiler bug; please report it to glasgow-haskell-bugs@haskell.org.\n\nFail:"; + write(fd,msg,sizeof(msg)-1); } void -StackOverflowHook (stack_size) - I_ stack_size; /* in bytes */ +PreTraceHook (long fd) { - fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K' option to increase it.\n", stack_size); + const char msg[]="\n"; + write(fd,msg,sizeof(msg)-1); } +void +PostTraceHook (long fd) +{ #if 0 -/* nothing to add here, really */ + const char msg[]="\n"; + write(fd,msg,sizeof(msg)-1); +#endif +} + +#else /* pre-3.03 GHC with old IO system */ + void -MallocFailHook (request_size, msg) - I_ request_size; /* in bytes */ - char *msg; +ErrorHdrHook (FILE *where) { - fprintf(stderr, "malloc: failed on request for %lu bytes\n", request_size); + fprintf(where, "\n"); /* no "Fail: " */ } -#endif /* 0 */ void -PatErrorHdrHook (where) - FILE *where; +PatErrorHdrHook (FILE *where) { - fprintf(where, "\n*** Pattern-matching error within GHC!\n\nThis is a compiler bug; please report it to glasgow-haskell-bugs@dcs.glasgow.ac.uk.\n\nFail: "); + fprintf(where, "\n*** Pattern-matching error within GHC!\n\nThis is a compiler bug; please report it to glasgow-haskell-bugs@haskell.org.\n\nFail: "); } void -PreTraceHook (where) - FILE *where; +PreTraceHook (FILE *where) { fprintf(where, "\n"); /* not "Trace On" */ } void -PostTraceHook (where) - FILE *where; +PostTraceHook (FILE *where) { fprintf(where, "\n"); /* not "Trace Off" */ } + +#endif + +#if __GLASGOW_HASKELL__ >= 400 +void +OutOfHeapHook (unsigned long request_size, unsigned long heap_size) + /* both in bytes */ +{ + fprintf(stderr, "GHC's heap exhausted;\nwhile trying to allocate %lu bytes in a %lu-byte heap;\nuse the `-H' option to increase the total heap size.\n", + request_size, + heap_size); +} + +void +StackOverflowHook (unsigned long stack_size) /* in bytes */ +{ + fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K' option to increase it.\n", stack_size); +} + +#else /* GHC < 4.00 */ + +void +OutOfHeapHook (W_ request_size, W_ heap_size) /* both in bytes */ +{ + fprintf(stderr, "GHC's heap exhausted;\nwhile trying to allocate %lu bytes in a %lu-byte heap;\nuse the `-H' option to increase the total heap size.\n", + request_size, + heap_size); +} + +void +StackOverflowHook (I_ stack_size) /* in bytes */ +{ + fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K' option to increase it.\n", stack_size); +} + +#endif