Skip to content

Commit 3de8c71

Browse files
committed
libc: change to flattened event struct
1 parent 7f89301 commit 3de8c71

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

libc-bottom-half/cloudlibc/src/libc/poll/poll.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) {
7777
// Set revents fields.
7878
for (size_t i = 0; i < nevents; ++i) {
7979
const __wasi_event_t *event = &events[i];
80-
if (event->u.tag == __WASI_EVENTTYPE_FD_READ ||
81-
event->u.tag == __WASI_EVENTTYPE_FD_WRITE) {
80+
if (event->type == __WASI_EVENTTYPE_FD_READ ||
81+
event->type == __WASI_EVENTTYPE_FD_WRITE) {
8282
struct pollfd *pollfd = (struct pollfd *)(uintptr_t)event->userdata;
8383
#ifdef __wasilibc_unmodified_upstream // generated constant names
8484
if (event->error == __WASI_EBADF) {
@@ -99,14 +99,14 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) {
9999
pollfd->revents |= POLLERR;
100100
} else {
101101
// Data can be read or written.
102-
if (event->u.tag == __WASI_EVENTTYPE_FD_READ) {
102+
if (event->type == __WASI_EVENTTYPE_FD_READ) {
103103
pollfd->revents |= POLLRDNORM;
104-
if (event->u.u.fd_read.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) {
104+
if (event->fd_readwrite.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) {
105105
pollfd->revents |= POLLHUP;
106106
}
107-
} else if (event->u.tag == __WASI_EVENTTYPE_FD_WRITE) {
107+
} else if (event->type == __WASI_EVENTTYPE_FD_WRITE) {
108108
pollfd->revents |= POLLWRNORM;
109-
if (event->u.u.fd_write.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) {
109+
if (event->fd_readwrite.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) {
110110
pollfd->revents |= POLLHUP;
111111
}
112112
}

libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ int ioctl(int fildes, int request, ...) {
4848
errno = event->error;
4949
return -1;
5050
}
51-
if (event->u.tag == __WASI_EVENTTYPE_FD_READ) {
52-
*result = event->u.u.fd_read.nbytes;
51+
if (event->type == __WASI_EVENTTYPE_FD_READ) {
52+
*result = event->fd_readwrite.nbytes;
5353
return 0;
5454
}
5555
}

libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds,
9797
// Test for EBADF.
9898
for (size_t i = 0; i < nevents; ++i) {
9999
const __wasi_event_t *event = &events[i];
100-
if ((event->u.tag == __WASI_EVENTTYPE_FD_READ ||
101-
event->u.tag == __WASI_EVENTTYPE_FD_WRITE) &&
100+
if ((event->type == __WASI_EVENTTYPE_FD_READ ||
101+
event->type == __WASI_EVENTTYPE_FD_WRITE) &&
102102
#ifdef __wasilibc_unmodified_upstream // generated constant names
103103
event->error == __WASI_EBADF) {
104104
#else
@@ -114,9 +114,9 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds,
114114
FD_ZERO(writefds);
115115
for (size_t i = 0; i < nevents; ++i) {
116116
const __wasi_event_t *event = &events[i];
117-
if (event->u.tag == __WASI_EVENTTYPE_FD_READ) {
117+
if (event->type == __WASI_EVENTTYPE_FD_READ) {
118118
readfds->__fds[readfds->__nfds++] = event->userdata;
119-
} else if (event->u.tag == __WASI_EVENTTYPE_FD_WRITE) {
119+
} else if (event->type == __WASI_EVENTTYPE_FD_WRITE) {
120120
writefds->__fds[writefds->__nfds++] = event->userdata;
121121
}
122122
}

0 commit comments

Comments
 (0)