mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 15:43:32 +01:00
Make the monotonic{_coarse,}_get() functions mockable.
This commit is contained in:
parent
a31078a581
commit
2999f0b33f
@ -220,8 +220,8 @@ monotime_init_internal(void)
|
||||
/**
|
||||
* Set "out" to the most recent monotonic time value
|
||||
*/
|
||||
void
|
||||
monotime_get(monotime_t *out)
|
||||
MOCK_IMPL(void,
|
||||
monotime_get,(monotime_t *out))
|
||||
{
|
||||
out->abstime_ = mach_absolute_time();
|
||||
}
|
||||
@ -251,16 +251,16 @@ monotime_init_internal(void)
|
||||
/* no action needed. */
|
||||
}
|
||||
|
||||
void
|
||||
monotime_get(monotime_t *out)
|
||||
MOCK_IMPL(void,
|
||||
monotime_get,(monotime_t *out))
|
||||
{
|
||||
int r = clock_gettime(CLOCK_MONOTONIC, &out->ts_);
|
||||
tor_assert(r == 0);
|
||||
}
|
||||
|
||||
#ifdef CLOCK_MONOTONIC_COARSE
|
||||
void
|
||||
monotime_coarse_get(monotime_coarse_t *out)
|
||||
MOCK_IMPL(void,
|
||||
monotime_coarse_get,(monotime_coarse_t *out))
|
||||
{
|
||||
int r = clock_gettime(CLOCK_MONOTONIC_COARSE, &out->ts_);
|
||||
tor_assert(r == 0);
|
||||
@ -316,8 +316,8 @@ monotime_init_internal(void)
|
||||
// FreeLibrary(h) ?
|
||||
}
|
||||
|
||||
void
|
||||
monotime_get(monotime_t *out)
|
||||
MOCK_IMPL(void,
|
||||
monotime_get,(monotime_t *out))
|
||||
{
|
||||
if (BUG(monotime_initialized == 0)) {
|
||||
monotime_init();
|
||||
@ -337,8 +337,8 @@ monotime_get(monotime_t *out)
|
||||
LeaveCriticalSection(&monotime_lock);
|
||||
}
|
||||
|
||||
void
|
||||
monotime_coarse_get(monotime_coarse_t *out)
|
||||
MOCK_IMPL(void,
|
||||
monotime_coarse_get,(monotime_coarse_t *out))
|
||||
{
|
||||
if (GetTickCount64_fn) {
|
||||
out->tick_count_ = (int64_t)GetTickCount64_fn();
|
||||
@ -396,8 +396,8 @@ monotime_init_internal(void)
|
||||
tor_mutex_init(&monotime_lock);
|
||||
}
|
||||
|
||||
void
|
||||
monotime_get(monotime_t *out)
|
||||
MOCK_IMPL(void,
|
||||
monotime_get,(monotime_t *out))
|
||||
{
|
||||
if (BUG(monotime_initialized == 0)) {
|
||||
monotime_init();
|
||||
|
@ -72,7 +72,7 @@ void monotime_init(void);
|
||||
/**
|
||||
* Set <b>out</b> to the current time.
|
||||
*/
|
||||
void monotime_get(monotime_t *out);
|
||||
MOCK_DECL(void, monotime_get, (monotime_t *out));
|
||||
/**
|
||||
* Return the number of nanoseconds between <b>start</b> and <b>end</b>.
|
||||
*/
|
||||
@ -102,7 +102,7 @@ uint64_t monotime_absolute_msec(void);
|
||||
/**
|
||||
* Set <b>out</b> to the current coarse time.
|
||||
*/
|
||||
void monotime_coarse_get(monotime_coarse_t *out);
|
||||
MOCK_DECL(void, monotime_coarse_get, (monotime_coarse_t *out));
|
||||
uint64_t monotime_coarse_absolute_nsec(void);
|
||||
uint64_t monotime_coarse_absolute_usec(void);
|
||||
uint64_t monotime_coarse_absolute_msec(void);
|
||||
|
Loading…
Reference in New Issue
Block a user