This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/3500 add osmo_fd_setup() convenience function to fill-in osmo_fd This basically follows the concept of osmo_timer_setup() and allows the caller to fill-in all configurable fields of osmo_fd in one line of code, rather than open-coding it in 5 lines everywhere. Change-Id: I6dbf19ea22fd65302bfc5424c10418d1b7939094 --- M include/osmocom/core/select.h M src/select.c 2 files changed, 22 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/00/3500/1 diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index 2abda2d..b6fed3c 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -36,6 +36,10 @@ unsigned int priv_nr; }; +void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when, + int (*cb)(struct osmo_fd *fd, unsigned int what), + void *data, unsigned int priv_nr); + bool osmo_fd_is_registered(struct osmo_fd *fd); int osmo_fd_register(struct osmo_fd *fd); void osmo_fd_unregister(struct osmo_fd *fd); diff --git a/src/select.c b/src/select.c index 0ba8bc6..4b98b62 100644 --- a/src/select.c +++ b/src/select.c @@ -47,6 +47,24 @@ static LLIST_HEAD(osmo_fds); static int unregistered_count; +/*! Set up an osmo-fd. Will not register it. + * \param[inout] ofd Osmo FD to be set-up + * \param[in] fd OS-level file descriptor number + * \param[in] when bit-mask of BSC_FD_{READ,WRITE,EXECEPT} + * \param[in] cb Call-back function to be called + * \param[in] data Private context pointer + * \param[in] priv_nr Private number + */ +void osmo_fd_setup(struct osmo_fd *ofd, int fd, unsigned int when, + int (*cb)(struct osmo_fd *fd, unsigned int what), + void *data, unsigned int priv_nr) +{ + ofd->fd = fd; + ofd->when = when; + ofd->cb = cb; + ofd->data = data; + ofd->priv_nr = priv_nr; +} /*! Check if a file descriptor is already registered * \param[in] fd osmocom file descriptor to be checked -- To view, visit https://gerrit.osmocom.org/3500 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6dbf19ea22fd65302bfc5424c10418d1b7939094 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>