From 8e2f7e87f4d854e697c40545326a16e50614dd5c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 22 Sep 2016 03:58:13 +0200 Subject: add osmo_gettimeofday as a shim around gettimeofday This allows feeding a custom time for unit tests by overriding osmo_gettimeofday. Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089 --- src/timer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/timer.c') 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(¤t_time, NULL); + osmo_gettimeofday(¤t_time, NULL); timer->timeout.tv_sec = seconds; timer->timeout.tv_usec = microseconds; timeradd(&timer->timeout, ¤t_time, &timer->timeout); @@ -143,7 +143,7 @@ int osmo_timer_remaining(const struct osmo_timer_list *timer, struct timeval current_time; if (!now) - gettimeofday(¤t_time, NULL); + osmo_gettimeofday(¤t_time, NULL); else current_time = *now; @@ -193,7 +193,7 @@ void osmo_timers_prepare(void) struct rb_node *node; struct timeval current; - gettimeofday(¤t, NULL); + osmo_gettimeofday(¤t, 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(¤t_time, NULL); + osmo_gettimeofday(¤t_time, NULL); INIT_LLIST_HEAD(&timer_eviction_list); for (node = rb_first(&timer_root); node; node = rb_next(node)) { -- cgit v1.2.3