Don't generate stub files when -fno-code is given.
[ghc-hetmet.git] / ghc / compiler / parser / hschooks.c
index 5f848fe..f3e7447 100644 (file)
@@ -3,83 +3,53 @@ These routines customise the error messages
 for various bits of the RTS.  They are linked
 in instead of the defaults.
 */
-#include <stdio.h>
 
-/* Included so as to bring the right prototypes into scope */
-#include "rtsdefs.h"
-
-#define W_ unsigned long int
-#define I_ long int
-
-#if __GLASGOW_HASKELL__ >= 303
-void
-ErrorHdrHook (long fd)
-{
-    char msg[]="\n";
-    write(fd,msg,1);
-}
+/* For GHC 4.08, we are relying on the fact that RtsFlags has
+ * compatible 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
-void
-ErrorHdrHook (FILE *where)
-{
-    fprintf(where, "\n"); /* no "Fail: " */
-}
+#include "Rts.h"
+#include "RtsFlags.h"
 #endif
 
-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<size>' option to increase the total heap size.\n",
-       request_size,
-       heap_size);
-}
+#include "HsFFI.h"
 
-void
-StackOverflowHook (I_ stack_size)    /* in bytes */
-{
-    fprintf(stderr, "GHC stack-space overflow: current size %ld bytes.\nUse the `-K<size>' option to increase it.\n", stack_size);
-}
+#include <string.h>
 
-#if __GLASGOW_HASKELL__ >= 303
-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);
-}
-
-void
-PreTraceHook (long fd)
-{
-    const char msg[]="\n";
-    write(fd,msg,sizeof(msg)-1);
-}
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 
 void
-PostTraceHook (long fd)
+defaultsHook (void)
 {
-#if 0
-    const char msg[]="\n";
-    write(fd,msg,sizeof(msg)-1);
+    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
 }
 
-#else
 void
-PatErrorHdrHook (FILE *where)
+OutOfHeapHook (unsigned long request_size/* always zero these days */,
+              unsigned long heap_size)
+    /* both in bytes */
 {
-    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: ");
+    fprintf(stderr, "GHC's heap exhausted: current limit is %lu bytes;\nUse the `-M<size>' option to increase the total heap size.\n",
+       heap_size);
 }
 
 void
-PreTraceHook (FILE *where)
+StackOverflowHook (unsigned long stack_size)    /* in bytes */
 {
-    fprintf(where, "\n"); /* not "Trace On" */
+    fprintf(stderr, "GHC stack-space overflow: current limit is %ld bytes.\nUse the `-K<size>' option to increase it.\n", stack_size);
 }
 
-void
-PostTraceHook (FILE *where)
-{
-    fprintf(where, "\n"); /* not "Trace Off" */
-}
-#endif