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;