X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fparser%2Fhschooks.c;h=cca3002fc56201ef7d6a2f864202a77c4c504192;hb=aafc20f801e42f218f2537a97b5609445129254d;hp=a2cc2e4e501a426e3fecd130f78f3df7c1ce2380;hpb=438596897ebbe25a07e1c82085cfbc5bdb00f09e;p=ghc-hetmet.git diff --git a/ghc/compiler/parser/hschooks.c b/ghc/compiler/parser/hschooks.c index a2cc2e4..cca3002 100644 --- a/ghc/compiler/parser/hschooks.c +++ b/ghc/compiler/parser/hschooks.c @@ -4,102 +4,88 @@ for various bits of the RTS. They are linked in instead of the defaults. */ -#if __GLASGOW_HASKELL__ >= 400 -#include "Rts.h" +/* For GHC 4.08, we are relying on the fact that RtsFlags has + * compatibile layout with the current version, because we're + * #including the current version of RtsFlags.h below. 4.08 didn't + * ship with its own RtsFlags.h, unfortunately. For later GHC + * versions, we #include the correct RtsFlags.h. + */ +#if __GLASGOW_HASKELL__ < 502 +#include "../includes/Rts.h" +#include "../includes/RtsFlags.h" #else -#include "rtsdefs.h" +#include "Rts.h" +#include "RtsFlags.h" #endif -#if __GLASGOW_HASKELL__ >= 303 - -void -ErrorHdrHook (long fd) -{ - char msg[]="\n"; - write(fd,msg,1); -} - -void -PatErrorHdrHook (long fd) -{ - 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:"; - write(fd,msg,sizeof(msg)-1); -} +#include "HsFFI.h" -void -PreTraceHook (long fd) -{ - const char msg[]="\n"; - write(fd,msg,sizeof(msg)-1); -} +#include -void -PostTraceHook (long fd) -{ -#if 0 - const char msg[]="\n"; - write(fd,msg,sizeof(msg)-1); +#ifdef HAVE_UNISTD_H +#include #endif -} - -#else /* pre-3.03 GHC with old IO system */ - -void -ErrorHdrHook (FILE *where) -{ - fprintf(where, "\n"); /* no "Fail: " */ -} void -PatErrorHdrHook (FILE *where) +defaultsHook (void) { - 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: "); + RtsFlags.GcFlags.heapSizeSuggestion = 6*1024*1024 / BLOCK_SIZE; + RtsFlags.GcFlags.maxStkSize = 8*1024*1024 / sizeof(W_); +#if __GLASGOW_HASKELL__ >= 411 + /* GHC < 4.11 didn't have these */ + RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS; + RtsFlags.GcFlags.statsFile = stderr; +#endif } void -PreTraceHook (FILE *where) +enableTimingStats( void ) /* called from the driver */ { - fprintf(where, "\n"); /* not "Trace On" */ +#if __GLASGOW_HASKELL__ >= 411 + RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS; +#endif + /* ignored when bootstrapping with an older GHC */ } void -PostTraceHook (FILE *where) +setHeapSize( HsInt size ) { - fprintf(where, "\n"); /* not "Trace Off" */ + RtsFlags.GcFlags.heapSizeSuggestion = size / BLOCK_SIZE; + if (RtsFlags.GcFlags.maxHeapSize != 0 && + RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) { + RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion; + } } -#endif - -#if __GLASGOW_HASKELL__ >= 400 void -OutOfHeapHook (unsigned long request_size, unsigned long heap_size) - /* both in bytes */ +OutOfHeapHook (unsigned long request_size/* always zero these days */, + 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, + fprintf(stderr, "GHC's heap exhausted: current limit is %lu bytes;\nUse the `-M' option to increase the total heap size.\n", 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); + fprintf(stderr, "GHC stack-space overflow: current limit is %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 */ +HsInt +ghc_strlen( HsAddr a ) { - 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); + return (strlen((char *)a)); } -void -StackOverflowHook (I_ stack_size) /* in bytes */ +HsInt +ghc_memcmp( HsAddr a1, HsAddr a2, HsInt len ) { - fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K' option to increase it.\n", stack_size); + return (memcmp((char *)a1, a2, len)); } -#endif +HsInt +ghc_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len ) +{ + return (memcmp((char *)a1 + i, a2, len)); +}