Added a workaround for format specifier mismatch
[ghc-hetmet.git] / rts / Hpc.c
index 8e67ffc..50730ea 100644 (file)
--- a/rts/Hpc.c
+++ b/rts/Hpc.c
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <assert.h>
 #include "HsFFI.h"
+#include "Rts.h"
 #include "Hpc.h"
 
 /* This is the runtime support for the Haskell Program Coverage (hpc) toolkit,
@@ -31,6 +32,13 @@ typedef struct _Info {
   struct _Info *next;
 } Info;
 
+// This is a cruel hack, we should completely redesign the format specifier handling in the RTS.
+#if SIZEOF_LONG == 8
+#define PRIuWORD64 "lu"
+#else
+#define PRIuWORD64 "llu"
+#endif
+
 Info *modules = 0;
 Info *nextModule = 0;
 StgWord64 *tixBoxes = 0;       // local copy of tixBoxes array, from file.
@@ -38,7 +46,7 @@ int totalTixes = 0;           // total number of tix boxes.
 
 
 
-static char *tixFilename = "Main.tix";
+static char *tixFilename;
 
 static void failure(char *msg) {
   printf("Hpc failure: %s\n",msg);
@@ -104,6 +112,10 @@ static void hpc_init(void) {
   }
   hpc_inited = 1;
   
+
+  tixFilename = (char *) malloc(strlen(prog_name) + 6);
+  sprintf(tixFilename, "%s.tix", prog_name);
+
   if (init_open(tixFilename)) { 
     totalTixes = 0;
 
@@ -309,7 +321,7 @@ exitHpc(void) {
       }
 
       if (tmpModule->tixArr) {
-       fprintf(f,"%lld",tmpModule->tixArr[i]);
+       fprintf(f,"%" PRIuWORD64,tmpModule->tixArr[i]);
       } else {
        fprintf(f,"0");
       }