Hoa Nguyen has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/33119 )
Change subject: base: Tag API methods and variables to time.hh
......................................................................
base: Tag API methods and variables to time.hh
Change-Id: I8c472e9d29f9d160afdcf22d74c4be2ae334f406
Signed-off-by: Hoa Nguyen <hoangu...@ucdavis.edu>
---
M src/base/time.hh
1 file changed, 84 insertions(+), 0 deletions(-)
diff --git a/src/base/time.hh b/src/base/time.hh
index 2067080..d369e3f 100644
--- a/src/base/time.hh
+++ b/src/base/time.hh
@@ -53,9 +53,14 @@
void _set(bool monotonic);
public:
+ /**
+ * @ingroup api_time
+ * @{
+ */
static const long NSEC_PER_SEC = 1000 * 1000 * 1000;
static const long NSEC_PER_MSEC = 1000 * 1000;
static const long NSEC_PER_USEC = 1000;
+ /** @} */ // end of api_time
public:
explicit Time() { clear(); }
@@ -67,6 +72,9 @@
/**
* Accessors for getting and setting the current clock
+ *
+ * @ingroup api_time
+ * @{
*/
time_t sec() const { return _time.tv_sec; }
long msec() const { return _time.tv_nsec / NSEC_PER_MSEC; }
@@ -77,40 +85,56 @@
void msec(long msec) { _time.tv_nsec = msec * NSEC_PER_MSEC; }
void usec(long usec) { _time.tv_nsec = usec * NSEC_PER_USEC; }
void nsec(long nsec) { _time.tv_nsec = nsec; }
+ /** @} */ // end of api_time
/**
* Clear the time
+ *
+ * @ingroup api_time
*/
void clear() { memset(&_time, 0, sizeof(_time)); }
/**
* Use this to set time for the purposes of time measurement (use
* a monotonic clock if it is available
+ *
+ * @ingroup api_time
*/
void setTimer() { _set(true); }
/**
* Use this to set the time to the actual current time
+ *
+ * @ingroup api_time
*/
void setWallclock() { _set(false); }
/**
* Set the current time
+ *
+ * @ingroup api_time
*/
void set(time_t _sec, long _nsec) { sec(_sec); nsec(_nsec); }
/**
* Set the current time from a value measured in Ticks
* @param ticks Number of ticks to convert into a time.
+ *
+ * @ingroup api_time
*/
void setTick(Tick ticks);
/**
* Get the current time from a value measured in Ticks
* @return Time value measured in Ticks.
+ *
+ * @ingroup api_time
*/
Tick getTick() const;
+ /**
+ * @ingroup api_time
+ */
const Time &
operator=(const Time &other)
{
@@ -119,6 +143,9 @@
return *this;
}
+ /**
+ * @ingroup api_time
+ */
const Time &
operator=(double new_time)
{
@@ -128,6 +155,9 @@
return *this;
}
+ /**
+ * @ingroup api_time
+ */
const Time &
operator=(const timeval &tv)
{
@@ -136,6 +166,9 @@
return *this;
}
+ /**
+ * @ingroup api_time
+ */
const Time &
operator=(const timespec &ts)
{
@@ -146,6 +179,8 @@
/**
* Get the time in floating point seconds
+ *
+ * @ingroup api_time
*/
operator double() const
{
@@ -154,8 +189,13 @@
/**
* operators for time conversion
+ *
+ * @ingroup api_time
*/
operator timespec() const { return _time; }
+ /**
+ * @ingroup api_time
+ */
operator timeval() const
{
timeval tv;
@@ -164,6 +204,9 @@
return tv;
}
+ /**
+ * @ingroup api_time
+ */
const Time &
operator+=(const Time &other)
{
@@ -178,6 +221,9 @@
return *this;
}
+ /**
+ * @ingroup api_time
+ */
const Time &
operator-=(const Time &other)
{
@@ -191,27 +237,44 @@
return *this;
}
+ /**
+ * @ingroup api_time
+ * @{
+ */
std::string date(const std::string &format = "") const;
std::string time() const;
+ /** @} */ // end of api_time
void serialize(const std::string &base, CheckpointOut &cp) const;
void unserialize(const std::string &base, CheckpointIn &cp);
};
+/**
+ * @ingroup api_time
+ */
void sleep(const Time &time);
+/**
+ * @ingroup api_time
+ */
inline bool
operator==(const Time &l, const Time &r)
{
return l.sec() == r.sec() && l.nsec() == r.nsec();
}
+/**
+ * @ingroup api_time
+ */
inline bool
operator!=(const Time &l, const Time &r)
{
return l.sec() != r.sec() || l.nsec() != r.nsec();
}
+/**
+ * @ingroup api_time
+ */
inline bool
operator<(const Time &l, const Time &r)
{
@@ -219,6 +282,9 @@
(l.sec() == r.sec() && l.nsec() < r.nsec());
}
+/**
+ * @ingroup api_time
+ */
inline bool
operator<=(const Time &l, const Time &r)
{
@@ -226,6 +292,9 @@
(l.sec() == r.sec() && l.nsec() <= r.nsec());
}
+/**
+ * @ingroup api_time
+ */
inline bool
operator>(const Time &l, const Time &r)
{
@@ -233,6 +302,9 @@
(l.sec() == r.sec() && l.nsec() > r.nsec());
}
+/**
+ * @ingroup api_time
+ */
inline bool
operator>=(const Time &l, const Time &r)
{
@@ -240,6 +312,9 @@
(l.sec() == r.sec() && l.nsec() >= r.nsec());
}
+/**
+ * @ingroup api_time
+ */
inline Time
operator+(const Time &l, const Time &r)
{
@@ -248,6 +323,9 @@
return time;
}
+/**
+ * @ingroup api_time
+ */
inline Time
operator-(const Time &l, const Time &r)
{
@@ -256,6 +334,9 @@
return time;
}
+/**
+ * @ingroup api_time
+ */
inline std::ostream &
operator<<(std::ostream &out, const Time &time)
{
@@ -263,6 +344,9 @@
return out;
}
+/**
+ * @ingroup api_time
+ */
time_t mkutctime(struct tm *time);
#endif // __BASE_TIME_HH__
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/33119
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8c472e9d29f9d160afdcf22d74c4be2ae334f406
Gerrit-Change-Number: 33119
Gerrit-PatchSet: 1
Gerrit-Owner: Hoa Nguyen <hoangu...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s