aboutsummaryrefslogtreecommitdiffstats
path: root/src/timer.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2017-05-08 18:00:28 +0200
committerPablo Neira Ayuso <pablo@gnumonks.org>2017-05-09 12:10:51 +0200
commit44f423f11717367639a12e6b533e293cccf6f6ba (patch)
treeb4d0605d4102925742b8fbab838b85dd18055e09 /src/timer.c
parentc65c5b4ea075ef6cef11fff9442ae0b15c1d6af7 (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 'src/timer.c')
-rw-r--r--src/timer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/timer.c b/src/timer.c
index cc6d5ccd..47d1786b 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -65,6 +65,18 @@ static void __add_timer(struct osmo_timer_list *timer)
rb_insert_color(&timer->node, &timer_root);
}
+/*! \brief set up timer callback and data
+ * \param[in] timer the timer that should be added
+ * \param[in] callback function to be called when timer expires
+ * \param[in] pointer to data that passed to the callback function
+ */
+void osmo_timer_setup(struct osmo_timer_list *timer, void (*cb)(void *data),
+ void *data)
+{
+ timer->cb = cb;
+ timer->data = data;
+}
+
/*! \brief add a new timer to the timer management
* \param[in] timer the timer that should be added
*/