39 #include "config/use_posix_clock.hh"
49 ::clock_gettime(monotonic ? CLOCK_MONOTONIC : CLOCK_REALTIME, &_time);
52 ::gettimeofday(&tv, NULL);
61 set(nsecs / NSEC_PER_SEC, nsecs % NSEC_PER_SEC);
73 time_t sec = this->sec();
78 ctime_r(&sec, buf,
sizeof(buf));
86 struct tm *tm = localtime(&sec);
87 strftime(buf,
sizeof(buf), format.c_str(), tm);
94 double time = double(*
this);
95 double secs = fmod(time, 60.0);
96 double all_mins = floor(time / 60.0);
97 double mins = fmod(all_mins, 60.0);
98 double hours = floor(all_mins / 60.0);
114 if (secs < 10.0 && !str.str().empty())
125 paramOut(cp, base +
".nsec", nsec());
133 paramIn(cp, base +
".sec", secs);
134 paramIn(cp, base +
".nsec", nsecs);
145 clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
147 nanosleep(&ts, NULL);
155 char *tz = getenv(
"TZ");
162 fatal(
"Failed to reserve memory for UTC time conversion\n");
169 time_t ret = mktime(time);
std::string date(const std::string &format="") const
void serialize(const std::string &base, CheckpointOut &cp) const
void _set(bool monotonic)
Internal time set function.
uint64_t Tick
Tick count type.
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
void unserialize(const std::string &base, CheckpointIn &cp)
std::ostream CheckpointOut
Bitfield< 31, 29 > format
time_t mkutctime(struct tm *time)
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
Tick getTick() const
Get the current time from a value measured in Ticks.
void setTick(Tick ticks)
Set the current time from a value measured in Ticks.
void sleep(const Time &time)