summaryrefslogtreecommitdiffstats
path: root/src/timer.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-22 03:58:13 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-22 07:18:39 +0200
commit8e2f7e87f4d854e697c40545326a16e50614dd5c (patch)
tree4474fbe1c0fa0262167b980227efe0c7280f9280 /src/timer.c
parent13a8fb84f0d83f23e65daa528f2f392ec3b83a75 (diff)
add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/timer.c b/src/timer.c
index 0358b89e..10a0b95d 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -91,7 +91,7 @@ osmo_timer_schedule(struct osmo_timer_list *timer, int seconds, int microseconds
{
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ osmo_gettimeofday(&current_time, NULL);
timer->timeout.tv_sec = seconds;
timer->timeout.tv_usec = microseconds;
timeradd(&timer->timeout, &current_time, &timer->timeout);
@@ -143,7 +143,7 @@ int osmo_timer_remaining(const struct osmo_timer_list *timer,
struct timeval current_time;
if (!now)
- gettimeofday(&current_time, NULL);
+ osmo_gettimeofday(&current_time, NULL);
else
current_time = *now;
@@ -193,7 +193,7 @@ void osmo_timers_prepare(void)
struct rb_node *node;
struct timeval current;
- gettimeofday(&current, NULL);
+ osmo_gettimeofday(&current, NULL);
node = rb_first(&timer_root);
if (node) {
@@ -214,7 +214,7 @@ int osmo_timers_update(void)
struct osmo_timer_list *this;
int work = 0;
- gettimeofday(&current_time, NULL);
+ osmo_gettimeofday(&current_time, NULL);
INIT_LLIST_HEAD(&timer_eviction_list);
for (node = rb_first(&timer_root); node; node = rb_next(node)) {