tor  0.4.0.0-alpha-dev
Macros | Functions | Variables
compat_time.c File Reference
#include "lib/time/compat_time.h"
#include "lib/err/torerr.h"
#include "lib/log/log.h"
#include "lib/log/util_bug.h"
#include "lib/intmath/muldiv.h"
#include "lib/intmath/bits.h"
#include "lib/fs/winlib.h"
#include "lib/wallclock/timeval.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

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

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)
 
 MOCK_IMPL (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)
 

Variables

static int monotime_initialized = 0
 
static monotime_t initialized_at
 

Detailed Description

Portable wrappers for finding out the current time, running timers, etc.

Definition in file compat_time.c.

Function Documentation

◆ monotime_absolute_msec()

uint64_t monotime_absolute_msec ( void  )

Return the number of milliseconds since the timer system was initialized.

Definition at line 797 of file compat_time.c.

References monotime_absolute_nsec().

◆ monotime_absolute_nsec()

uint64_t monotime_absolute_nsec ( void  )

Return the number of nanoseconds since the timer system was initialized.

Definition at line 779 of file compat_time.c.

Referenced by monotime_absolute_msec().

◆ monotime_coarse_get_stamp()

uint32_t monotime_coarse_get_stamp ( void  )

Return the current time "stamp" as described by monotime_coarse_to_stamp.

Definition at line 834 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().

◆ monotime_coarse_stamp_units_to_approx_msec()

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.

Definition at line 860 of file compat_time.c.

Referenced by rate_per_sec_to_rate_per_step().

◆ monotime_diff_msec()

int64_t monotime_diff_msec ( const monotime_t start,
const monotime_t end 
)

Return the number of milliseconds between start and end.

Definition at line 771 of file compat_time.c.

References monotime_diff_nsec().

◆ 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.

Definition at line 763 of file compat_time.c.

References monotime_diff_nsec().

◆ monotime_init()

void monotime_init ( void  )

Initialize the monotonic timer subsystem. Must be called before any monotonic timer functions. This function is idempotent.

Definition at line 737 of file compat_time.c.

References monotime_get(), and monotime_initialized.

◆ monotime_zero()

void monotime_zero ( monotime_t out)

Set out to zero.

Definition at line 750 of file compat_time.c.

Variable Documentation

◆ monotime_initialized

int monotime_initialized = 0
static

True iff monotime_init has been called.

Definition at line 80 of file compat_time.c.

Referenced by monotime_init().