+/* Called at the end of execution, to write out the Hpc *.tix file
+ * for this exection. Safe to call, even if coverage is not used.
+ */
+void
+exitHpc(void) {
+ debugTrace(DEBUG_hpc,"exitHpc");
+
+ if (hpc_inited == 0) {
+ return;
+ }
+
+ FILE *f = fopen(tixFilename,"w");
+ writeTix(f);
+}
+
+void hs_hpc_read(char *filename) {
+ HpcModuleInfo *orig_modules = 0, *tmpModule, *tmpOrigModule;
+ int i;
+
+ orig_modules = modules;
+ modules = 0;
+ if (init_open(fopen(filename,"r"))) {
+ readTix();
+ // Now we copy across the arrays. O(n^2), but works
+ for(tmpModule = modules;
+ tmpModule != 0;
+ tmpModule = tmpModule->next) {
+
+ for(tmpOrigModule = orig_modules;
+ tmpOrigModule != 0;
+ tmpOrigModule = tmpOrigModule->next) {
+ if (!strcmp(tmpModule->modName,tmpOrigModule->modName)) {
+ assert(tmpModule->tixArr != 0);
+ assert(tmpOrigModule->tixArr != 0);
+ assert(tmpModule->tickCount == tmpOrigModule->tickCount);
+ for(i=0;i < tmpModule->tickCount;i++) {
+ tmpOrigModule->tixArr[i] = tmpModule->tixArr[i];
+ }
+ tmpModule->tixArr = tmpOrigModule->tixArr;
+ break;
+ }
+ }
+ }
+ }
+}
+
+void hs_hpc_write(char *filename) {
+ writeTix(fopen(filename,"w"));
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// This is the API into Hpc RTS from Haskell, allowing the tixs boxes
+// to be first class.
+
+HpcModuleInfo *hs_hpc_rootModule(void) {
+ return modules;
+}