1 /**
2  * @file epoll_inner.h
3  * epoll_inner.h API header file.
4  *
5  * @version   V1.0
6  * @date      2020-04-26
7  * @copyright Copyright (C) 2015-2020 Alibaba Group Holding Limited
8  */
9 
10 
11 #ifndef ___EPOLL_INNNER_H__
12 #define ___EPOLL_INNNER_H__
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 #include <stddef.h>
18 #include <stdint.h>
19 #include <aos/kernel.h>
20 #include <k_rbtree.h>
21 #include <aos/list.h>
22 #include <epoll.h>
23 
24 #define EPOLL_VFS_CTL             10
25 #define EPOLL_VFS_WAIT            11
26 
27 #define EP_PRIVATE_BITS (EPOLLWAKEUP | EPOLLONESHOT | EPOLLET | EPOLLEXCLUSIVE)
28 
29 typedef struct eventpoll {
30     struct k_rbtree_root_t rb_tree;
31     int             rbcnt;
32     dlist_t         ready_list;
33     int             rdnum;
34     int             waiting;
35     aos_hdl_t     rbt_mutex;
36     aos_hdl_t     evt_mutex;
37     aos_hdl_t     event;
38 
39 } epoll_dev_t;
40 
41 
42 struct pollfd {
43     int   fd;
44     short events;
45     short revents;
46 };
47 
48 typedef struct epoll_item {
49     struct k_rbtree_node_t    tree_node;
50     dlist_t            link_node;
51     int                rdy; //exist in list
52     int                fd;
53     struct epoll_event event;
54     epoll_dev_t        *epoll;
55     struct pollfd      compat_evt;//compat to vfs poll
56     uint32_t           revents;
57 } epoll_item_t;
58 
59 typedef struct {
60     int                 fd;
61     int                 op;
62     struct epoll_event  *event;
63 } epoll_ctl_data_t;
64 
65 typedef struct {
66     int                 maxevents;
67     int                 timeout;
68     struct epoll_event  *events;
69 } epoll_wait_data_t;
70 
71 int vfs_device_epoll_init(void);
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif