Time: Add serialization functions to the Time class.
[gem5.git] / src / base / time.cc
index 0fab938a4adc6dc494882320a5f47f53d115d03a..8ce2e21375fb9c9560a668ea5c9c200bc9d09a32 100644 (file)
@@ -34,6 +34,7 @@
 #include "base/time.hh"
 #include "config/use_posix_clock.hh"
 #include "sim/core.hh"
+#include "sim/serialize.hh"
 
 using namespace std;
 
@@ -113,6 +114,25 @@ Time::time() const
     return str.str();
 }
 
+void
+Time::serialize(const std::string &base, ostream &os)
+{
+    paramOut(os, base + ".sec", sec());
+    paramOut(os, base + ".nsec", nsec());
+}
+
+void
+Time::unserialize(const std::string &base, Checkpoint *cp,
+                  const string &section)
+{
+    time_t secs;
+    time_t nsecs;
+    paramIn(cp, section, base + ".sec", secs);
+    paramIn(cp, section, base + ".nsec", nsecs);
+    sec(secs);
+    nsec(nsecs);
+}
+
 void
 sleep(const Time &time)
 {