tor
master
|
Portable wrappers for finding out the current time, running timers, etc. More...
Macros | |
#define | COMPAT_TIME_PRIVATE |
#define | ONE_MILLION ((int64_t) (1000 * 1000)) |
#define | ONE_BILLION ((int64_t) (1000 * 1000 * 1000)) |
#define | initialized_at_coarse initialized_at |
Functions | |
MOCK_IMPL (void, tor_gettimeofday,(struct timeval *timeval)) | |
STATIC void | ratchet_timeval (const struct timeval *timeval_raw, struct timeval *out) |
void | monotime_get (monotime_t *out) |
int64_t | monotime_diff_nsec (const monotime_t *start, const monotime_t *end) |
int32_t | monotime_coarse_diff_msec32_ (const monotime_coarse_t *start, const monotime_coarse_t *end) |
uint32_t | monotime_coarse_to_stamp (const monotime_coarse_t *t) |
int | monotime_is_zero (const monotime_t *val) |
void | monotime_add_msec (monotime_t *out, const monotime_t *val, uint32_t msec) |
void | monotime_init (void) |
void | monotime_zero (monotime_t *out) |
int64_t | monotime_diff_usec (const monotime_t *start, const monotime_t *end) |
int64_t | monotime_diff_msec (const monotime_t *start, const monotime_t *end) |
uint64_t | monotime_absolute_nsec (void) |
uint64_t | monotime_absolute_usec (void) |
uint64_t | monotime_absolute_msec (void) |
uint32_t | monotime_coarse_get_stamp (void) |
uint64_t | monotime_coarse_stamp_units_to_approx_msec (uint64_t units) |
uint64_t | monotime_msec_to_approx_coarse_stamp_units (uint64_t msec) |
Portable wrappers for finding out the current time, running timers, etc.
Set *timeval to the current time of day. On error, log and terminate. (Same as gettimeofday(timeval,NULL), but never returns -1.)
uint64_t monotime_absolute_msec | ( | void | ) |
Return the number of milliseconds since the timer system was initialized.
uint64_t monotime_absolute_nsec | ( | void | ) |
Return the number of nanoseconds since the timer system was initialized.
uint64_t monotime_absolute_usec | ( | void | ) |
Return the number of microseconds since the timer system was initialized.
void monotime_add_msec | ( | monotime_t * | out, |
const monotime_t * | val, | ||
uint32_t | msec | ||
) |
Set out to N milliseconds after val.
int32_t monotime_coarse_diff_msec32_ | ( | const monotime_coarse_t * | start, |
const monotime_coarse_t * | end | ||
) |
As monotime_coarse_diff_msec, but avoid 64-bit division.
Requires that the difference fit into an int32_t; not for use with large time differences.
uint32_t monotime_coarse_get_stamp | ( | void | ) |
Return the current time "stamp" as described by monotime_coarse_to_stamp.
uint64_t monotime_coarse_stamp_units_to_approx_msec | ( | uint64_t | units | ) |
Convert a difference, expressed in the units of monotime_coarse_to_stamp, into an approximate number of milliseconds.
uint32_t monotime_coarse_to_stamp | ( | const monotime_coarse_t * | t | ) |
Return a "timestamp" approximation for a coarse monotonic timer. This timestamp is meant to be fast to calculate and easy to compare, and have a unit of something roughly around 1 msec.
It will wrap over from time to time.
It has no defined zero point.
int64_t monotime_diff_msec | ( | const monotime_t * | start, |
const monotime_t * | end | ||
) |
Return the number of milliseconds between start and end.
int64_t monotime_diff_nsec | ( | const monotime_t * | start, |
const monotime_t * | end | ||
) |
Return the number of nanoseconds between start and end.
int64_t monotime_diff_usec | ( | const monotime_t * | start, |
const monotime_t * | end | ||
) |
Return the number of microseconds between start and end.
void monotime_get | ( | monotime_t * | out | ) |
Set out to the current time.
void monotime_init | ( | void | ) |
Initialize the monotonic timer subsystem. Must be called before any monotonic timer functions. This function is idempotent.
int monotime_is_zero | ( | const monotime_t * | out | ) |
Return true iff out is zero
void monotime_zero | ( | monotime_t * | out | ) |
Set out to zero.