Tor
0.4.7.0-alpha-dev
|
Compute the difference between timevals, in various units. More...
#include "lib/time/tvdiff.h"
#include "lib/cc/compat_compiler.h"
#include "lib/defs/time.h"
#include "lib/log/log.h"
Go to the source code of this file.
Functions | |
static int64_t | tv_secdiff_impl (const struct timeval *start, const struct timeval *end) |
long | tv_udiff (const struct timeval *start, const struct timeval *end) |
long | tv_mdiff (const struct timeval *start, const struct timeval *end) |
int64_t | tv_to_msec (const struct timeval *tv) |
time_t | time_diff (const time_t t1, const time_t t2) |
Compute the difference between timevals, in various units.
Definition in file tvdiff.c.
time_t time_diff | ( | const time_t | t1, |
const time_t | t2 | ||
) |
Return duration in seconds between time_t values t1 and t2 iff t1 is numerically less or equal than t2. Otherwise, return TIME_MAX.
This provides a safe way to compute difference between two UNIX timestamps (t2 can be assumed by calling code to be later than t1) or two durations measured in seconds (t2 can be assumed to be longer than t1). Calling code is expected to check for TIME_MAX return value and interpret that as error condition.
Definition at line 181 of file tvdiff.c.
Referenced by predicted_ports_prediction_time_remaining().
Return the number of milliseconds elapsed between *start and *end. If the tv_usec difference is 500, rounds away from zero. Returns LONG_MAX on overflow and underflow.
Definition at line 102 of file tvdiff.c.
Referenced by circuit_build_times_handle_completed_hop().
int64_t tv_to_msec | ( | const struct timeval * | tv | ) |