1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 13 #pragma once 14 15 #include <debug_lock.h> 16 #include <errno.h> 17 #include <poll.h> 18 #include <signal.h> 19 #include <sys/epoll.h> 20 21 struct epitem { 22 int fd; 23 struct epoll_event event; 24 /* epitem list in the same eventpoll */ 25 struct list_head epi_node; 26 }; 27 28 struct eventpoll { 29 /* All epitems */ 30 int volatile epi_lock; 31 struct list_head epi_list; 32 uint32_t wait_count; 33 }; 34 35 /* Use by poll wait */ 36 struct pollarg { 37 /* Event mask */ 38 short int events; 39 }; 40 41 int chcore_epoll_create1(int flags); 42 int chcore_epoll_ctl(int epfd, int op, int fd, struct epoll_event *events); 43 int chcore_epoll_pwait(int epfd, struct epoll_event *events, int maxevents, 44 int timeout, const sigset_t *sigmask); 45 46 int chcore_poll(struct pollfd fds[], nfds_t nfds, int timeout); 47 int chcore_ppoll(struct pollfd *fds, nfds_t n, const struct timespec *tmo_p, 48 const sigset_t *sigmask);