select: Introduce osmo_fd_{read,write}_{enable,disable}()
If we watn to migrate to something like epoll(), user application
code must call a function of the libosmocore API whenever it changes
its read/write interest in a file descriptor.
Let's introduce API so applications can be ported to this API,
before making direct 'ofd->when' manipulations illegal as a second step.
Change-Id: Idb89ba7bc7c129a6304a76900d17f47daf54d17d
diff --git a/src/select.c b/src/select.c
index 496beea..1bb354b 100644
--- a/src/select.c
+++ b/src/select.c
@@ -75,6 +75,15 @@
ofd->priv_nr = priv_nr;
}
+/*! Update the 'when' field of osmo_fd. "ofd->when = (ofd->when & when_mask) | when".
+ * Use this function instead of directly modifying ofd->when, as the latter will be
+ * removed soon. */
+void osmo_fd_update_when(struct osmo_fd *ofd, unsigned int when_mask, unsigned int when)
+{
+ ofd->when &= when_mask;
+ ofd->when |= when;
+}
+
/*! Check if a file descriptor is already registered
* \param[in] fd osmocom file descriptor to be checked
* \returns true if registered; otherwise false