summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-06-01 19:56:15 +1000
committerJeremy Kerr <jk@ozlabs.org>2013-08-16 14:41:08 +0800
commit7f4057edddbcb1b18293ebb96475ed37551edc73 (patch)
treecbf87298522fd1c0bf9440f13391dd2dc358375b /lib
parentf4ebd9c3c3767802178ab92204f499042c124d49 (diff)
downloadtalos-petitboot-7f4057edddbcb1b18293ebb96475ed37551edc73.tar.gz
talos-petitboot-7f4057edddbcb1b18293ebb96475ed37551edc73.zip
lib/waiter: move type-specific members to a union
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/waiter/waiter.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/waiter/waiter.c b/lib/waiter/waiter.c
index 89fa9cb..1d9a7d8 100644
--- a/lib/waiter/waiter.c
+++ b/lib/waiter/waiter.c
@@ -11,14 +11,18 @@
#include "waiter.h"
struct waiter {
+ struct waitset *set;
enum {
WAITER_IO,
WAITER_TIME,
- } type;
- struct waitset *set;
- int fd;
- int events;
- struct timeval timeout;
+ } type;
+ union {
+ struct {
+ int fd;
+ int events;
+ } io;
+ struct timeval timeout;
+ };
waiter_cb callback;
void *arg;
@@ -90,8 +94,8 @@ struct waiter *waiter_register_io(struct waitset *set, int fd, int events,
waiter->type = WAITER_IO;
waiter->set = set;
- waiter->fd = fd;
- waiter->events = events;
+ waiter->io.fd = fd;
+ waiter->io.events = events;
waiter->callback = callback;
waiter->arg = arg;
@@ -179,8 +183,8 @@ static void update_waiters(struct waitset *set)
if (waiter->type != WAITER_IO)
continue;
- set->pollfds[i_io].fd = waiter->fd;
- set->pollfds[i_io].events = waiter->events;
+ set->pollfds[i_io].fd = waiter->io.fd;
+ set->pollfds[i_io].events = waiter->io.events;
set->io_waiters[i_io] = waiter;
i_io++;
}
OpenPOWER on IntegriCloud