LLVM API Documentation
Provides an abstraction for a fixed point in time. More...
#include <TimeValue.h>
Public Types | |
Types | |
enum | TimeConversions { NANOSECONDS_PER_SECOND = 1000000000, MICROSECONDS_PER_SECOND = 1000000, MILLISECONDS_PER_SECOND = 1000, NANOSECONDS_PER_MICROSECOND = 1000, NANOSECONDS_PER_MILLISECOND = 1000000, NANOSECONDS_PER_POSIX_TICK = 100, NANOSECONDS_PER_WIN32_TICK = 100 } |
typedef int64_t | SecondsType |
Type used for representing seconds. More... | |
typedef int32_t | NanoSecondsType |
Type used for representing nanoseconds. More... | |
Public Member Functions | |
Accessors | |
SecondsType | seconds () const |
Retrieve the seconds component. More... | |
NanoSecondsType | nanoseconds () const |
Retrieve the nanoseconds component. More... | |
uint32_t | microseconds () const |
Retrieve the fractional part as microseconds;. More... | |
uint32_t | milliseconds () const |
Retrieve the fractional part as milliseconds;. More... | |
uint64_t | usec () const |
Convert to a number of microseconds (can overflow) More... | |
uint64_t | msec () const |
Convert to a number of milliseconds (can overflow) More... | |
uint64_t | toPosixTime () const |
Convert to unix time (100 nanoseconds since 12:00:00a Jan 1,1970) More... | |
uint64_t | toEpochTime () const |
uint64_t | toWin32Time () const |
Convert to Win32's FILETIME (100ns intervals since 00:00:00 Jan 1, 1601 UTC) More... | |
void | getTimespecTime (uint64_t &seconds, uint32_t &nanos) const |
Convert to timespec time (ala POSIX.1b) More... | |
std::string | str () const |
Convert time to a string. More... | |
Mutators | |
void | seconds (SecondsType sec) |
Set the seconds component. More... | |
void | nanoseconds (NanoSecondsType nanos) |
Set the nanoseconds component using a number of nanoseconds. More... | |
void | microseconds (int32_t micros) |
Set the nanoseconds component using a number of microseconds. More... | |
void | milliseconds (int32_t millis) |
Set the nanoseconds component using a number of milliseconds. More... | |
void | usec (int64_t microseconds) |
Converts from microsecond format to TimeValue format. More... | |
void | msec (int64_t milliseconds) |
Converts from millisecond format to TimeValue format. More... | |
void | fromEpochTime (SecondsType seconds) |
Convert seconds form PosixTime to TimeValue. More... | |
void | fromWin32Time (uint64_t win32Time) |
Convert seconds form Windows FILETIME to TimeValue. More... | |
Static Public Attributes | |
Constants | |
static const TimeValue | MinTime = TimeValue ( INT64_MIN,0 ) |
The smallest possible time value. More... | |
static const TimeValue | MaxTime = TimeValue ( INT64_MAX,0 ) |
The largest possible time value. More... | |
static const TimeValue | ZeroTime = TimeValue ( 0,0 ) |
00:00:00 Jan 1, 2000 UTC. More... | |
static const TimeValue | PosixZeroTime = TimeValue ( PosixZeroTimeSeconds,0 ) |
00:00:00 Jan 1, 1970 UTC. More... | |
static const TimeValue | Win32ZeroTime = TimeValue ( Win32ZeroTimeSeconds,0 ) |
00:00:00 Jan 1, 1601 UTC. More... | |
Constructors | |
TimeValue () | |
Default construct a time value, initializing to ZeroTime. More... | |
TimeValue (SecondsType seconds, NanoSecondsType nanos=0) | |
Explicit constructor. More... | |
TimeValue (double new_time) | |
Double Constructor. More... | |
static TimeValue | now () |
Creates a TimeValue with the current time (UTC). More... | |
Operators | |
TimeValue & | operator+= (const TimeValue &that) |
Incrementing assignment operator. More... | |
TimeValue & | operator-= (const TimeValue &that) |
Decrementing assignment operator. More... | |
int | operator< (const TimeValue &that) const |
True if this < that. More... | |
int | operator> (const TimeValue &that) const |
True if this > that. More... | |
int | operator<= (const TimeValue &that) const |
True if this <= that. More... | |
int | operator>= (const TimeValue &that) const |
int | operator== (const TimeValue &that) const |
int | operator!= (const TimeValue &that) const |
TimeValue | operator+ (const TimeValue &tv1, const TimeValue &tv2) |
Addition operator. More... | |
TimeValue | operator- (const TimeValue &tv1, const TimeValue &tv2) |
Subtraction operator. More... | |
Provides an abstraction for a fixed point in time.
This class is used where a precise fixed point in time is required. The range of TimeValue spans many hundreds of billions of years both past and present. The precision of TimeValue is to the nanosecond. However, the actual precision of its values will be determined by the resolution of the system clock. The TimeValue class is used in conjunction with several other lib/System interfaces to specify the time at which a call should timeout, etc.
Definition at line 31 of file TimeValue.h.
typedef int32_t llvm::sys::TimeValue::NanoSecondsType |
Type used for representing nanoseconds.
Definition at line 69 of file TimeValue.h.
typedef int64_t llvm::sys::TimeValue::SecondsType |
Type used for representing seconds.
Definition at line 68 of file TimeValue.h.
Definition at line 71 of file TimeValue.h.
|
inline |
Default construct a time value, initializing to ZeroTime.
Definition at line 86 of file TimeValue.h.
|
inlineexplicit |
Explicit constructor.
Caller provides the exact value in seconds and nanoseconds. The nanos
argument defaults to zero for convenience.
Definition at line 91 of file TimeValue.h.
|
inlineexplicit |
Double Constructor.
Caller provides the exact value as a double in seconds with the fractional part representing nanoseconds.
Definition at line 97 of file TimeValue.h.
References NANOSECONDS_PER_SECOND.
|
inline |
Convert seconds form PosixTime to TimeValue.
Converts the seconds
argument from PosixTime to the corresponding TimeValue and assigns that value to this
.
Definition at line 334 of file TimeValue.h.
Referenced by llvm::object::ArchiveMemberHeader::getLastModified().
|
inline |
Convert seconds form Windows FILETIME to TimeValue.
Converts the win32Time
argument from Windows FILETIME to the corresponding TimeValue and assigns that value to this
.
Definition at line 343 of file TimeValue.h.
|
inline |
Convert to timespec time (ala POSIX.1b)
Provides the seconds and nanoseconds as results in its arguments after correction for the Posix zero time.
Definition at line 267 of file TimeValue.h.
|
inline |
Retrieve the fractional part as microseconds;.
Returns only the fractional portion of the TimeValue rounded down to the nearest microsecond (divide by one thousand).
Definition at line 208 of file TimeValue.h.
References NANOSECONDS_PER_MICROSECOND.
Referenced by llvm::TimeRecord::getCurrentTime().
|
inline |
Set the nanoseconds component using a number of microseconds.
The seconds component remains unchanged.
Definition at line 303 of file TimeValue.h.
References NANOSECONDS_PER_MICROSECOND.
|
inline |
Retrieve the fractional part as milliseconds;.
Returns only the fractional portion of the TimeValue rounded down to the nearest millisecond (divide by one million).
Definition at line 215 of file TimeValue.h.
References NANOSECONDS_PER_MILLISECOND.
|
inline |
Set the nanoseconds component using a number of milliseconds.
The seconds component remains unchanged.
Definition at line 310 of file TimeValue.h.
References NANOSECONDS_PER_MILLISECOND.
|
inline |
Convert to a number of milliseconds (can overflow)
Returns the TimeValue as a number of milliseconds. Note that the value returned can overflow because the range of a uint64_t is smaller than the range of a TimeValue. Nevertheless, this is useful on some operating systems and is therefore provided.
Definition at line 234 of file TimeValue.h.
References MILLISECONDS_PER_SECOND, and NANOSECONDS_PER_MILLISECOND.
|
inline |
Converts from millisecond format to TimeValue format.
Definition at line 324 of file TimeValue.h.
References MILLISECONDS_PER_SECOND, and NANOSECONDS_PER_MILLISECOND.
|
inline |
Retrieve the nanoseconds component.
Returns only the nanoseconds component of the TimeValue. The seconds portion is ignored.
Definition at line 203 of file TimeValue.h.
|
inline |
Set the nanoseconds component using a number of nanoseconds.
The nanoseconds component of the TimeValue is set to nanos
without modifying the seconds part. This is useful for basic computations involving just the nanoseconds portion. Note that the TimeValue will be normalized after this call so that the fractional (nanoseconds) portion will have the smallest equivalent value.
Definition at line 296 of file TimeValue.h.
|
static |
Creates a TimeValue with the current time (UTC).
This is a static constructor that returns a TimeValue that represents the current time.
Referenced by getElapsedWallTime().
|
inline |
Determines if two TimeValue objects represent times that are not the same.
Definition at line 178 of file TimeValue.h.
Incrementing assignment operator.
Add that
to this
.
Definition at line 118 of file TimeValue.h.
Decrementing assignment operator.
Subtract that
from this
.
Definition at line 128 of file TimeValue.h.
|
inline |
True if this < that.
Determine if this
is less than that
.
Definition at line 138 of file TimeValue.h.
|
inline |
True if this <= that.
Determine if this
is less than or equal to that
.
Definition at line 155 of file TimeValue.h.
|
inline |
Determines if two TimeValue objects represent the same moment in time.
Definition at line 170 of file TimeValue.h.
|
inline |
True if this > that.
Determine if this
is greather than that
.
Definition at line 143 of file TimeValue.h.
|
inline |
Determine if this
is greater than or equal to that
.
Definition at line 159 of file TimeValue.h.
|
inline |
Retrieve the seconds component.
Returns only the seconds component of the TimeValue. The nanoseconds portion is ignored. No rounding is performed.
Definition at line 198 of file TimeValue.h.
Referenced by llvm::TimeRecord::getCurrentTime().
|
inline |
Set the seconds component.
The seconds component of the TimeValue is set to sec
without modifying the nanoseconds part. This is useful for whole second arithmetic.
Definition at line 285 of file TimeValue.h.
std::string llvm::sys::TimeValue::str | ( | ) | const |
Convert time to a string.
Provides conversion of the TimeValue into a readable time & date.
|
inline |
Converts the TimeValue into the corresponding number of seconds since the epoch (00:00:00 Jan 1,1970).
Definition at line 250 of file TimeValue.h.
|
inline |
Convert to unix time (100 nanoseconds since 12:00:00a Jan 1,1970)
Converts the TimeValue into the corresponding number of "ticks" for Posix, correcting for the difference in Posix zero time.
Definition at line 242 of file TimeValue.h.
References NANOSECONDS_PER_POSIX_TICK.
|
inline |
Convert to Win32's FILETIME (100ns intervals since 00:00:00 Jan 1, 1601 UTC)
Converts the TimeValue into the corresponding number of "ticks" for Win32 platforms, correcting for the difference in Win32 zero time.
Definition at line 258 of file TimeValue.h.
References NANOSECONDS_PER_WIN32_TICK.
|
inline |
Convert to a number of microseconds (can overflow)
Returns the TimeValue as a number of microseconds. Note that the value returned can overflow because the range of a uint64_t is smaller than the range of a TimeValue. Nevertheless, this is useful on some operating systems and is therefore provided.
Definition at line 224 of file TimeValue.h.
References MICROSECONDS_PER_SECOND, and NANOSECONDS_PER_MICROSECOND.
|
inline |
Converts from microsecond format to TimeValue format.
Definition at line 316 of file TimeValue.h.
References MICROSECONDS_PER_SECOND, and NANOSECONDS_PER_MICROSECOND.
Addition operator.
Adds two TimeValue objects together.
Definition at line 371 of file TimeValue.h.
Subtraction operator.
Subtracts two TimeValue objects.
Definition at line 377 of file TimeValue.h.
The largest possible time value.
A constant TimeValue representing the largest time value permissible by the class. MaxTime is some point in the distant future, about 300 billion years AD.
Definition at line 47 of file TimeValue.h.
The smallest possible time value.
A constant TimeValue representing the smallest time value permissible by the class. MinTime is some point in the distant past, about 300 billion years BCE.
Definition at line 41 of file TimeValue.h.
00:00:00 Jan 1, 1970 UTC.
A constant TimeValue for the Posix base time which is 00:00:00 (midnight) January 1st, 1970.
Definition at line 57 of file TimeValue.h.
00:00:00 Jan 1, 1601 UTC.
A constant TimeValue for the Win32 base time which is 00:00:00 (midnight) January 1st, 1601.
Definition at line 62 of file TimeValue.h.
00:00:00 Jan 1, 2000 UTC.
A constant TimeValue representing the base time, or zero time of 00:00:00 (midnight) January 1st, 2000.
Definition at line 52 of file TimeValue.h.