Fix the iomux_add/clear events. Also properly remember

the events in the IOMuxFD
This commit is contained in:
Nils O. Selåsdal
2015-05-12 19:21:57 +02:00
parent e517c33da9
commit 11939065fb
2 changed files with 16 additions and 11 deletions
+15 -11
View File
@@ -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); 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_)\ static inline int iomux_clear_event(struct IOMux *mux, struct IOMuxFD *fd,
({\ unsigned int what)
(fd)->what &= ~(what_);\ {
iomux_update_events((mux), (fd), (fd)->what & ~(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_)\
({\ static inline int iomux_add_event(struct IOMux *mux, struct IOMuxFD *fd,
iomux_update_events((mux), (fd), (fd)->what | (what_));\ 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. /** @return a UCTimer instance tied to this mux.
* Used to schedule timers within this mux. * Used to schedule timers within this mux.
+1
View File
@@ -151,6 +151,7 @@ int iomux_update_events(struct IOMux *mux, struct IOMuxFD *fd, unsigned int what
if (fd->what != what) { if (fd->what != what) {
fd->what = what; fd->what = what;
rc = mux->ops.update_events_impl(mux, fd); rc = mux->ops.update_events_impl(mux, fd);
fd->what = what;
} }
return rc; return rc;