From 8a9208612eec8ddae4c418485d848ecfa0613699 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Mon, 30 Oct 2023 22:12:14 +0100 Subject: Meta: Move kernel and userland to their own folders. This is to allow both the kernel and the userland to share certain header files and to make the folder structure a bit more clear. --- poll.c | 54 ------------------------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 poll.c (limited to 'poll.c') diff --git a/poll.c b/poll.c deleted file mode 100644 index 5e02723..0000000 --- a/poll.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include -#include - -int poll(struct pollfd *fds, size_t nfds, int timeout) { - (void)timeout; - int read_locks[nfds]; - int write_locks[nfds]; - int disconnect_locks[nfds]; - for (size_t i = 0; i < nfds; i++) { - if (fds[i].fd < 0) - continue; - vfs_fd_t *f = get_vfs_fd(fds[i].fd); - if (fds[i].events & POLLIN) - read_locks[i] = create_read_fdhalt(f); - if (fds[i].events & POLLOUT) - write_locks[i] = create_write_fdhalt(f); - if (fds[i].events & POLLHUP) - disconnect_locks[i] = create_disconnect_fdhalt(f); - } - - switch_task(); - - for (size_t i = 0; i < nfds; i++) { - if (fds[i].fd < 0) - continue; - if (fds[i].events & POLLIN) - unset_read_fdhalt(read_locks[i]); - if (fds[i].events & POLLOUT) - unset_write_fdhalt(write_locks[i]); - if (fds[i].events & POLLHUP) - unset_disconnect_fdhalt(disconnect_locks[i]); - } - for (size_t i = 0; i < nfds; i++) { - if (0 > fds[i].fd) { - fds[i].revents = 0; - continue; - } - vfs_fd_t *f = get_vfs_fd(fds[i].fd); - if (!f) { - if (fds[i].events & POLLHUP) - fds[i].revents |= POLLHUP; - } else { - if (f->inode->has_data && fds[i].events & POLLIN) - fds[i].revents |= POLLIN; - if (f->inode->can_write && fds[i].events & POLLOUT) - fds[i].revents |= POLLOUT; - if (!(f->inode->is_open) && fds[i].events & POLLHUP) - fds[i].revents |= POLLHUP; - } - } - return 0; -} -- cgit v1.2.3