Tor 0.4.9.0-alpha-dev
|
Functions and types for monotonic times. More...
Go to the source code of this file.
Data Structures | |
struct | timeval |
struct | monotime_t |
Macros | |
#define | MONOTIME_USING_GETTIMEOFDAY |
#define | monotime_coarse_t monotime_t |
#define | monotime_coarse_get monotime_get |
#define | monotime_coarse_absolute_nsec monotime_absolute_nsec |
#define | monotime_coarse_absolute_usec monotime_absolute_usec |
#define | monotime_coarse_absolute_msec monotime_absolute_msec |
#define | monotime_coarse_absolute_sec monotime_absolute_sec |
#define | monotime_coarse_diff_nsec monotime_diff_nsec |
#define | monotime_coarse_diff_usec monotime_diff_usec |
#define | monotime_coarse_diff_msec monotime_diff_msec |
#define | monotime_coarse_zero monotime_zero |
#define | monotime_coarse_is_zero monotime_is_zero |
#define | monotime_coarse_add_msec monotime_add_msec |
#define | USING_32BIT_MSEC_HACK |
Functions | |
void | monotime_init (void) |
void | monotime_get (monotime_t *out) |
int64_t | monotime_diff_nsec (const monotime_t *start, const monotime_t *end) |
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) |
uint64_t | monotime_absolute_sec (void) |
void | monotime_zero (monotime_t *out) |
int | monotime_is_zero (const monotime_t *out) |
void | monotime_add_msec (monotime_t *out, const monotime_t *val, uint32_t msec) |
uint32_t | monotime_coarse_to_stamp (const monotime_coarse_t *t) |
uint64_t | monotime_coarse_stamp_units_to_approx_msec (uint64_t units) |
uint64_t | monotime_msec_to_approx_coarse_stamp_units (uint64_t msec) |
uint32_t | monotime_coarse_get_stamp (void) |
int32_t | monotime_coarse_diff_msec32_ (const monotime_coarse_t *start, const monotime_coarse_t *end) |
static int32_t | monotime_coarse_diff_msec32 (const monotime_coarse_t *start, const monotime_coarse_t *end) |
Functions and types for monotonic times.
monotime_* functions try to provide a high-resolution monotonic timer with something the best resolution the system provides. monotime_coarse_* functions run faster (if the operating system gives us a way to do that) but produce a less accurate timer: accuracy will probably be on the order of tens of milliseconds.
Definition in file compat_time.h.
#define monotime_coarse_absolute_msec monotime_absolute_msec |
Definition at line 279 of file compat_time.h.
#define monotime_coarse_absolute_nsec monotime_absolute_nsec |
Definition at line 277 of file compat_time.h.
#define monotime_coarse_absolute_sec monotime_absolute_sec |
Definition at line 280 of file compat_time.h.
#define monotime_coarse_absolute_usec monotime_absolute_usec |
Definition at line 278 of file compat_time.h.
#define monotime_coarse_add_msec monotime_add_msec |
Definition at line 327 of file compat_time.h.
#define monotime_coarse_diff_msec monotime_diff_msec |
Definition at line 324 of file compat_time.h.
#define monotime_coarse_diff_nsec monotime_diff_nsec |
Definition at line 322 of file compat_time.h.
#define monotime_coarse_diff_usec monotime_diff_usec |
Definition at line 323 of file compat_time.h.
#define monotime_coarse_get monotime_get |
Definition at line 276 of file compat_time.h.
#define monotime_coarse_is_zero monotime_is_zero |
Definition at line 326 of file compat_time.h.
#define monotime_coarse_t monotime_t |
Definition at line 197 of file compat_time.h.
#define monotime_coarse_zero monotime_zero |
Definition at line 325 of file compat_time.h.
#define MONOTIME_USING_GETTIMEOFDAY |
Definition at line 176 of file compat_time.h.
uint64_t monotime_absolute_msec | ( | void | ) |
Return the number of milliseconds since the timer system was initialized. The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 810 of file compat_time.c.
uint64_t monotime_absolute_nsec | ( | void | ) |
Return the number of nanoseconds since the timer system was initialized. The returned value may be equal to zero.
Definition at line 792 of file compat_time.c.
Referenced by monotime_absolute_msec(), monotime_absolute_sec(), and monotime_absolute_usec().
uint64_t monotime_absolute_sec | ( | void | ) |
Return the number of seconds since the timer system was initialized. The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 816 of file compat_time.c.
uint64_t monotime_absolute_usec | ( | void | ) |
Return the number of microseconds since the timer system was initialized. The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 804 of file compat_time.c.
Referenced by circpad_estimate_circ_rtt_on_send(), circpad_machine_remove_token(), congestion_control_note_cell_sent(), congestion_control_update_circuit_estimates(), connection_half_edge_is_valid_data(), and connection_half_edges_waiting().
void monotime_add_msec | ( | monotime_t * | out, |
const monotime_t * | val, | ||
uint32_t | msec | ||
) |
Set out to N milliseconds after val.
|
inlinestatic |
As monotime_coarse_diff_msec, but avoid 64-bit division if it is expensive.
Requires that the difference fit into an int32_t; not for use with large time differences.
The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 352 of file compat_time.h.
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.
The returned value may be equal to zero. Fractional units are truncated, not rounded.
uint32_t monotime_coarse_get_stamp | ( | void | ) |
Return the current time "stamp" as described by monotime_coarse_to_stamp.
Definition at line 864 of file compat_time.c.
Referenced by cell_queue_append_packed_copy(), connection_bucket_init(), connection_handle_read_impl(), and connection_or_update_token_buckets_helper().
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.
The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 890 of file compat_time.c.
Referenced by rate_per_sec_to_rate_per_step().
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. The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 784 of file compat_time.c.
int64_t monotime_diff_nsec | ( | const monotime_t * | start, |
const monotime_t * | end | ||
) |
Return the number of nanoseconds between start and end. The returned value may be equal to zero.
Referenced by monotime_diff_msec(), and monotime_diff_usec().
int64_t monotime_diff_usec | ( | const monotime_t * | start, |
const monotime_t * | end | ||
) |
Return the number of microseconds between start and end. The returned value may be equal to zero. Fractional units are truncated, not rounded.
Definition at line 776 of file compat_time.c.
void monotime_get | ( | monotime_t * | out | ) |
Set out to the current time.
Referenced by libevent_timer_reschedule(), monotime_init(), and timers_run_pending().
void monotime_init | ( | void | ) |
Initialize the timing subsystem. This function is idempotent.
Initialize the monotonic timer subsystem. Must be called before any monotonic timer functions. This function is idempotent.
Definition at line 750 of file compat_time.c.
int monotime_is_zero | ( | const monotime_t * | out | ) |
Return true iff out is zero
uint64_t monotime_msec_to_approx_coarse_stamp_units | ( | uint64_t | msec | ) |
Definition at line 895 of file compat_time.c.
void monotime_zero | ( | monotime_t * | out | ) |
Set out to zero.
Definition at line 763 of file compat_time.c.