Add osmo_timerfd_* functions for osmo_fd-wrapped timerfd
Linux offers file descriptor based periodic (interval) timers,
which can achieve a higher precision than our userspace based
timers and which can be slave'd to CLOCK_MONOTINIC or other clock
sources. Let's add some code for osmo_fd wrapped versions that
integrate well with our select() abstraction.
The code has been used in osmo-bts-trx since June 2017 (change-id
I51b19adde14ebb7ef3bb863d45e06243c323e22e), and I'm just renaming
and moving it to libosmocore here. After a merge, the osmo-bts
implementations can be removed in favor if this one.
Change-Id: Ibeffba7c997252c003723bcd5d14122c4ded2fe7
diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h
index b6fed3c..1ba6b83 100644
--- a/include/osmocom/core/select.h
+++ b/include/osmocom/core/select.h
@@ -6,6 +6,7 @@
#include <osmocom/core/linuxlist.h>
#include <stdbool.h>
+#include <time.h>
/*! \defgroup select Select loop abstraction
* @{
@@ -54,4 +55,10 @@
int osmo_fd_fill_fds(void *readset, void *writeset, void *exceptset);
int osmo_fd_disp_fds(void *readset, void *writeset, void *exceptset);
+/* timerfd integration */
+int osmo_timerfd_disable(struct osmo_fd *ofd);
+int osmo_timerfd_schedule(struct osmo_fd *ofd, const struct timespec *first,
+ const struct timespec *interval);
+int osmo_timerfd_setup(struct osmo_fd *ofd, int (*cb)(struct osmo_fd *, unsigned int), void *data);
+
/*! @} */