stats: cleanup static stats to make startup work.
authorNathan Binkert <nate@binkert.org>
Mon, 23 Feb 2009 20:03:06 +0000 (12:03 -0800)
committerNathan Binkert <nate@binkert.org>
Mon, 23 Feb 2009 20:03:06 +0000 (12:03 -0800)
This is mainly to allow the unit test to run without requiring the standard
M5 stats from being initialized (e.g. sim_seconds, sim_ticks, host_seconds)

src/sim/stat_control.cc
src/sim/stats.hh

index 25c5be1040a8f149bb99638dc0612a956882dc87..2dcf4798d95e60f866abfc10d10726bf7b7fa34d 100644 (file)
 
 using namespace std;
 
-Stats::Formula hostInstRate;
-Stats::Formula hostTickRate;
-Stats::Value hostMemory;
-Stats::Value hostSeconds;
-
-Stats::Value simTicks;
-Stats::Value simInsts;
-Stats::Value simFreq;
 Stats::Formula simSeconds;
 
 namespace Stats {
@@ -84,8 +76,21 @@ statElapsedTicks()
 
 SimTicksReset simTicksReset;
 
-void
-initSimStats()
+struct Global
+{
+    Stats::Formula hostInstRate;
+    Stats::Formula hostTickRate;
+    Stats::Value hostMemory;
+    Stats::Value hostSeconds;
+
+    Stats::Value simTicks;
+    Stats::Value simInsts;
+    Stats::Value simFreq;
+
+    Global();
+};
+
+Global::Global()
 {
     simInsts
         .functor(BaseCPU::numSimulatedInstructions)
@@ -146,6 +151,12 @@ initSimStats()
     registerResetCallback(&simTicksReset);
 }
 
+void
+initSimStats()
+{
+    static Global global;
+}
+
 class _StatEvent : public Event
 {
   private:
index 97251283ddd0011055a767375db7bc1ad68c0bfe..481c36cf6f7c06b8f78384c87e7d52c4a4bc8235 100644 (file)
@@ -34,6 +34,5 @@
 #include "base/statistics.hh"
 
 extern Stats::Formula simSeconds;
-extern Stats::Value simTicks;
 
 #endif // __SIM_SIM_STATS_HH__