add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.
Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
diff --git a/src/timer.c b/src/timer.c
index 0358b89..10a0b95 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -91,7 +91,7 @@
{
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 @@
struct timeval current_time;
if (!now)
- gettimeofday(¤t_time, NULL);
+ osmo_gettimeofday(¤t_time, NULL);
else
current_time = *now;
@@ -193,7 +193,7 @@
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 @@
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)) {