Created
December 13, 2017 19:04
-
-
Save kgsws/3bf56c7333838a4261494c1cb03e2ed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct bsd_pollfd { | |
int fd; | |
short events; | |
short revents; | |
}; | |
#define BSD_POLLIN 0x0001 | |
int bsd_poll(struct bsd_pollfd *fds, int nfds, int timeout) { | |
result_t r; | |
int32_t raw[] = {nfds, timeout}; | |
ipc_buffer_t fds_in = { | |
.addr = fds, | |
.size = sizeof(struct bsd_pollfd) * nfds, | |
.type = 0x21 | |
}; | |
ipc_buffer_t fds_out = { | |
.addr = fds, | |
.size = sizeof(struct bsd_pollfd) * nfds, | |
.type = 0x22 | |
}; | |
ipc_buffer_t *buffers[] = { | |
&fds_in, | |
&fds_out, | |
}; | |
ipc_request_t rq = ipc_default_request; | |
rq.request_id = 6; | |
rq.raw_data = (uint32_t*)raw; | |
rq.raw_data_size = sizeof(raw); | |
rq.num_buffers = 2; | |
rq.buffers = buffers; | |
int32_t response[2]; // ret, errno | |
ipc_response_fmt_t rs = ipc_default_response_fmt; | |
rs.raw_data_size = sizeof(response); | |
rs.raw_data = (uint32_t*) response; | |
r = ipc_send(bsd_object, &rq, &rs); | |
if(r) { | |
bsd_result = r; | |
return -1; | |
} | |
if(response[0] < 0) { | |
bsd_result = LIBTRANSISTOR_ERR_BSD_ERRNO_SET; | |
bsd_errno = response[1]; | |
return -1; | |
} | |
return response[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment