Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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];
- }
Add Comment
Please, Sign In to add comment