37#include "config/use_posix_clock.hh"
48 ::clock_gettime(monotonic ? CLOCK_MONOTONIC : CLOCK_REALTIME, &
_time);
51 ::gettimeofday(&tv, NULL);
80 ctime_r(&
sec, buf,
sizeof(buf));
88 struct tm *
tm = localtime(&
sec);
89 strftime(buf,
sizeof(buf),
format.c_str(),
tm);
96 double time = double(*
this);
97 double secs = fmod(
time, 60.0);
98 double all_mins = floor(
time / 60.0);
99 double mins = fmod(all_mins, 60.0);
100 double hours = floor(all_mins / 60.0);
102 std::stringstream str;
116 if (secs < 10.0 && !str.str().empty())
147 clock_nanosleep(CLOCK_MONOTONIC, 0, &
ts, NULL);
149 nanosleep(&
ts, NULL);
157 char *
tz = getenv(
"TZ");
164 fatal(
"Failed to reserve memory for UTC time conversion\n");
171 time_t ret = mktime(time);
Tick getTick() const
Get the current time from a value measured in Ticks.
void serialize(const std::string &base, CheckpointOut &cp) const
time_t sec() const
Accessors for getting and setting the current clock.
std::string date(const std::string &format="") const
void unserialize(const std::string &base, CheckpointIn &cp)
const Time & operator=(const Time &other)
void _set(bool monotonic)
Internal time set function.
void setTick(Tick ticks)
Set the current time from a value measured in Ticks.
#define fatal(...)
This implements a cprintf based fatal() function.
Bitfield< 31, 29 > format
Tick Frequency
The simulated frequency of curTick(). (In ticks per second)
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::ostream CheckpointOut
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
time_t mkutctime(struct tm *time)
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
uint64_t Tick
Tick count type.
void sleep(const Time &time)