From 5ecd083e7fbb5ef1f80a7e20855db934e9cacb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Tue, 12 May 2015 19:21:57 +0200 Subject: [PATCH] Fix the iomux_add/clear events. Also properly remember the events in the IOMuxFD --- include/ucore/iomux.h | 26 +++++++++++++++----------- src/iomux_impl.c | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/ucore/iomux.h b/include/ucore/iomux.h index efcc3a1..2d5e591 100644 --- a/include/ucore/iomux.h +++ b/include/ucore/iomux.h @@ -112,20 +112,24 @@ int iomux_unregister_fd(struct IOMux *mux, struct IOMuxFD *fd); int iomux_update_events(struct IOMux *mux, struct IOMuxFD *fd, unsigned int what); /** - * Convenience macro for clearing the new event + * Convenience for clearing the new event */ -#define iomux_clear_event(mux, fd, what_)\ -({\ - (fd)->what &= ~(what_);\ - iomux_update_events((mux), (fd), (fd)->what & ~(what_));\ -}) +static inline int iomux_clear_event(struct IOMux *mux, struct IOMuxFD *fd, + unsigned int what) +{ + unsigned int new_what = fd->what & ~what; + return iomux_update_events(mux, fd, new_what); +} /** - * Convenience macro for adding the new event to the existing events + * Convenience for adding the new event to the existing events */ -#define iomux_add_event(mux, fd, what_)\ -({\ - iomux_update_events((mux), (fd), (fd)->what | (what_));\ -}) + +static inline int iomux_add_event(struct IOMux *mux, struct IOMuxFD *fd, + unsigned int what) +{ + unsigned int new_what = fd->what | what; + return iomux_update_events(mux, fd, new_what); +} /** @return a UCTimer instance tied to this mux. * Used to schedule timers within this mux. diff --git a/src/iomux_impl.c b/src/iomux_impl.c index a577b5b..e30f178 100644 --- a/src/iomux_impl.c +++ b/src/iomux_impl.c @@ -150,6 +150,7 @@ int iomux_update_events(struct IOMux *mux, struct IOMuxFD *fd, unsigned int what if (fd->what != what) { rc = mux->ops.update_events_impl(mux, fd); + fd->what = what; } return rc;