[project @ 1998-11-12 13:23:45 by sof]
[ghc-hetmet.git] / ghc / runtime / storage / SMstats.lc
index b10db26..5383ce2 100644 (file)
@@ -25,6 +25,10 @@ stat_exit
 #define _INCLUDE_HPUX_SOURCE
 #endif
 
+#ifdef solaris2_TARGET_OS
+#define __EXTENSIONS__
+#endif
+
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -67,7 +71,6 @@ stat_exit
  from getrusage() for Solaris   -- SOF
 */
 #if solaris2_TARGET_OS
-#undef __STRICT_ANSI__  /* oh, dear */
 #include <sys/fcntl.h>
 #include <sys/signal.h>
 #include <sys/procfs.h>
@@ -456,6 +459,11 @@ stat_exit(I_ alloc)
        StgDouble time = usertime();
        StgDouble etime = elapsedtime();
 
+       /* avoid divide by zero if time is measured as 0.00 seconds -- SDM */
+       if (time  == 0.0)  time = 0.0001;
+       if (etime == 0.0) etime = 0.0001;
+       
+
        if (RTSflags.GcFlags.giveStats) {
            fprintf(sf, "%8ld\n\n", alloc*sizeof(W_));
        }
@@ -512,7 +520,12 @@ stat_exit(I_ alloc)
        fprintf(sf, "  %%GC time     %5.1f%%  (%.1f%% elapsed)\n\n",
                GC_tot_time*100./time, GCe_tot_time*100./etime);
 
-       ullong_format_string((ullong)(GC_tot_alloc*sizeof(W_)/(time - GC_tot_time)), temp, rtsTrue/*commas*/);
+       if (time - GC_tot_time == 0.0)
+               ullong_format_string((ullong)0, temp, rtsTrue/*commas*/);
+       else
+               ullong_format_string((ullong)(GC_tot_alloc*sizeof(W_)/(time - GC_tot_time)),
+                        temp, rtsTrue/*commas*/);
+
        fprintf(sf, "  Alloc rate    %s bytes per MUT second\n\n", temp);
 
        fprintf(sf, "  Productivity %5.1f%% of total user, %.1f%% of total elapsed\n\n",