14 #ifndef LLVM_SUPPORT_TIMEVALUE_H
15 #define LLVM_SUPPORT_TIMEVALUE_H
17 #include "llvm/Support/DataTypes.h"
64 return TimeValue ( PosixZeroTimeSeconds,0 );
71 return TimeValue ( Win32ZeroTimeSeconds,0 );
101 : seconds_( seconds ), nanos_( nanos ) { this->normalize(); }
107 : seconds_( 0 ) , nanos_ ( 0 ) {
109 seconds_ = integer_part;
128 this->seconds_ += that.seconds_ ;
129 this->nanos_ += that.nanos_ ;
138 this->seconds_ -= that.seconds_ ;
139 this->nanos_ -= that.nanos_ ;
153 if ( this->seconds_ > that.seconds_ ) {
155 }
else if ( this->seconds_ == that.seconds_ ) {
156 if ( this->nanos_ > that.nanos_ )
return 1;
169 if ( this->seconds_ > that.seconds_ ) {
171 }
else if ( this->seconds_ == that.seconds_ ) {
172 if ( this->nanos_ >= that.nanos_ )
return 1;
180 return (this->seconds_ == that.seconds_) &&
181 (this->nanos_ == that.nanos_);
251 return seconds_ - PosixZeroTimeSeconds;
259 uint64_t result = (uint64_t)10000000 * (seconds_ - Win32ZeroTimeSeconds);
268 seconds = seconds_ - PosixZeroTimeSeconds;
275 std::string
str()
const;
286 this->seconds_ = sec;
297 this->nanos_ = nanos;
335 seconds_ = seconds + PosixZeroTimeSeconds;
344 this->seconds_ = win32Time / 10000000 + Win32ZeroTimeSeconds;
372 TimeValue sum (tv1.seconds_ + tv2.seconds_, tv1.nanos_ + tv2.nanos_);
378 TimeValue difference (tv1.seconds_ - tv2.seconds_, tv1.nanos_ - tv2.nanos_ );
379 difference.normalize ();
std::string str() const
Provides conversion of the TimeValue into a readable time & date.
TimeValue()
Default construct a time value, initializing to ZeroTime.
static TimeValue now()
This is a static constructor that returns a TimeValue that represents the current time...
static TimeValue MinTime()
A constant TimeValue representing the smallest time value permissible by the class.
TimeValue(SecondsType seconds, NanoSecondsType nanos=0)
Caller provides the exact value in seconds and nanoseconds.
void microseconds(int32_t micros)
The seconds component remains unchanged.
void seconds(SecondsType sec)
The seconds component of the TimeValue is set to sec without modifying the nanoseconds part...
int32_t NanoSecondsType
Type used for representing nanoseconds.
TimeValue operator-(const TimeValue &tv1, const TimeValue &tv2)
static TimeValue MaxTime()
A constant TimeValue representing the largest time value permissible by the class.
SecondsType seconds() const
Returns only the seconds component of the TimeValue.
uint64_t usec() const
Returns the TimeValue as a number of microseconds.
NanoSecondsType nanoseconds() const
Returns only the nanoseconds component of the TimeValue.
void msec(int64_t milliseconds)
Converts from millisecond format to TimeValue format.
void milliseconds(int32_t millis)
The seconds component remains unchanged.
int operator<=(const TimeValue &that) const
Determine if this is less than or equal to that.
static TimeValue ZeroTime()
A constant TimeValue representing the base time, or zero time of 00:00:00 (midnight) January 1st...
TimeValue(double new_time)
Caller provides the exact value as a double in seconds with the fractional part representing nanoseco...
TimeValue & operator+=(const TimeValue &that)
Add that to this.
uint64_t toEpochTime() const
Converts the TimeValue into the corresponding number of seconds since the epoch (00:00:00 Jan 1...
int operator<(const TimeValue &that) const
Determine if this is less than that.
uint64_t msec() const
Returns the TimeValue as a number of milliseconds.
void fromWin32Time(uint64_t win32Time)
Converts the win32Time argument from Windows FILETIME to the corresponding TimeValue and assigns that...
int operator==(const TimeValue &that) const
Determines if two TimeValue objects represent the same moment in time.
int operator!=(const TimeValue &that) const
Determines if two TimeValue objects represent times that are not the same.
TimeValue operator+(const TimeValue &tv1, const TimeValue &tv2)
int64_t SecondsType
Type used for representing seconds.
static TimeValue Win32ZeroTime()
A constant TimeValue for the Win32 base time which is 00:00:00 (midnight) January 1st...
int operator>=(const TimeValue &that) const
Determine if this is greater than or equal to that.
uint32_t milliseconds() const
Returns only the fractional portion of the TimeValue rounded down to the nearest millisecond (divide ...
void fromEpochTime(SecondsType seconds)
Converts the seconds argument from PosixTime to the corresponding TimeValue and assigns that value to...
void usec(int64_t microseconds)
Converts from microsecond format to TimeValue format.
int operator>(const TimeValue &that) const
Determine if this is greather than that.
friend TimeValue operator+(const TimeValue &tv1, const TimeValue &tv2)
Adds two TimeValue objects together.
Win32 tick is 10^7 Hz (10ns)
void getTimespecTime(uint64_t &seconds, uint32_t &nanos) const
Provides the seconds and nanoseconds as results in its arguments after correction for the Posix zero ...
This class is used where a precise fixed point in time is required.
uint32_t microseconds() const
Returns only the fractional portion of the TimeValue rounded down to the nearest microsecond (divide ...
static TimeValue PosixZeroTime()
A constant TimeValue for the Posix base time which is 00:00:00 (midnight) January 1st...
friend TimeValue operator-(const TimeValue &tv1, const TimeValue &tv2)
Subtracts two TimeValue objects.
TimeValue & operator-=(const TimeValue &that)
Subtract that from this.
uint64_t toWin32Time() const
Converts the TimeValue into the corresponding number of "ticks" for Win32 platforms, correcting for the difference in Win32 zero time.
void nanoseconds(NanoSecondsType nanos)
The nanoseconds component of the TimeValue is set to nanos without modifying the seconds part...