|
| 1 | +/* epoll.h |
| 2 | + Copyright (c) fd0, All rights reserved. |
| 3 | +
|
| 4 | + This library is free software; you can redistribute it and/or |
| 5 | + modify it under the terms of the GNU Lesser General Public |
| 6 | + License as published by the Free Software Foundation; either |
| 7 | + version 3.0 of the License, or (at your option) any later version. |
| 8 | +
|
| 9 | + This library is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | + Lesser General Public License for more details. |
| 13 | +
|
| 14 | + You should have received a copy of the GNU Lesser General Public |
| 15 | + License along with this library.*/ |
| 16 | + |
| 17 | +#ifndef _SYS_EPOLL_H |
| 18 | +#define _SYS_EPOLL_H 1 |
| 19 | + |
| 20 | +#include <stdint.h> |
| 21 | +#include <sys/types.h> |
| 22 | + |
| 23 | +#ifndef __EPOLL_PACKED |
| 24 | +# define __EPOLL_PACKED __attribute__ ((__packed__)) |
| 25 | +#endif |
| 26 | + |
| 27 | +#define EPOLLIN 0x01 |
| 28 | +#define EPOLLOUT 0x02 |
| 29 | +#define EPOLLERR 0x04 |
| 30 | +#define EPOLLET 0x08 |
| 31 | + |
| 32 | +/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ |
| 33 | +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ |
| 34 | +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ |
| 35 | +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ |
| 36 | + |
| 37 | +typedef union epoll_data |
| 38 | +{ |
| 39 | + void *ptr; |
| 40 | + int fd; |
| 41 | + uint32_t u32; |
| 42 | + uint64_t u64; |
| 43 | +} epoll_data_t; |
| 44 | + |
| 45 | +struct epoll_event |
| 46 | +{ |
| 47 | + uint32_t events; /* Epoll events */ |
| 48 | + epoll_data_t data; /* User data variable */ |
| 49 | +}; |
| 50 | + |
| 51 | +__BEGIN_DECLS |
| 52 | + |
| 53 | +int |
| 54 | +epoll_create (int size); |
| 55 | + |
| 56 | +int |
| 57 | +epoll_ctl (int epfd, int op, int fd, struct epoll_event *event); |
| 58 | + |
| 59 | +int |
| 60 | +epoll_wait (int epfd, struct epoll_event *events, int maxevents, int timeout); |
| 61 | + |
| 62 | +__END_DECLS |
| 63 | + |
| 64 | +#endif /* sys/epoll.h */ |
0 commit comments