From 44f423f11717367639a12e6b533e293cccf6f6ba Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 8 May 2017 18:00:28 +0200 Subject: timer: add osmo_timer_setup() Add a new function timer function to set up the timer, similar to what we have in the Linux kernel. This patch also converts existing opencoded timer setup in the libosmocore tree as initial client of this new function. This patch implicitly removes function callback passed by reference that defeat compile time type validation. Compile-tested only, but I ran make check that reports success when testing timer infrastructure. Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666 --- tests/timer/timer_test.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/timer') diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 066dc72d..d2b0204d 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -39,10 +39,7 @@ static void main_timer_fired(void *data); static void secondary_timer_fired(void *data); static unsigned int main_timer_step = 0; -static struct osmo_timer_list main_timer = { - .cb = main_timer_fired, - .data = &main_timer_step, -}; +static struct osmo_timer_list main_timer; static LLIST_HEAD(timer_test_list); @@ -92,8 +89,7 @@ static void main_timer_fired(void *data) return; } osmo_gettimeofday(&v->start, NULL); - v->timer.cb = secondary_timer_fired; - v->timer.data = v; + osmo_timer_setup(&v->timer, secondary_timer_fired, v); unsigned int seconds = (i & 0x7) + 1; v->stop.tv_sec = v->start.tv_sec + seconds; v->stop.tv_usec = v->start.tv_usec; @@ -195,6 +191,7 @@ int main(int argc, char *argv[]) " %d steps of %d msecs each\n", timer_nsteps, steps, TIME_BETWEEN_TIMER_CHECKS / 1000); + osmo_timer_setup(&main_timer, main_timer_fired, &main_timer_step); osmo_timer_schedule(&main_timer, 1, 0); #ifdef HAVE_SYS_SELECT_H -- cgit v1.2.3