diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2017-05-08 18:00:28 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@gnumonks.org> | 2017-05-09 12:10:51 +0200 |
commit | 44f423f11717367639a12e6b533e293cccf6f6ba (patch) | |
tree | b4d0605d4102925742b8fbab838b85dd18055e09 /tests/timer | |
parent | c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7 (diff) |
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
Diffstat (limited to 'tests/timer')
-rw-r--r-- | tests/timer/timer_test.c | 9 |
1 files changed, 3 insertions, 6 deletions
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 |