epoll.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _SYS_EPOLL_H
  2. #define _SYS_EPOLL_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdint.h>
  7. #include <sys/types.h>
  8. #include <sys/ioctl.h>
  9. #include <fcntl.h>
  10. #define __NEED_sigset_t
  11. #include <bits/alltypes.h>
  12. #define EPOLL_CLOEXEC O_CLOEXEC
  13. #define EPOLL_NONBLOCK O_NONBLOCK
  14. enum EPOLL_EVENTS { __EPOLL_DUMMY };
  15. #define EPOLLIN 0x001
  16. #define EPOLLPRI 0x002
  17. #define EPOLLOUT 0x004
  18. #define EPOLLRDNORM 0x040
  19. #define EPOLLNVAL 0x020
  20. #define EPOLLRDBAND 0x080
  21. #define EPOLLWRNORM 0x100
  22. #define EPOLLWRBAND 0x200
  23. #define EPOLLMSG 0x400
  24. #define EPOLLERR 0x008
  25. #define EPOLLHUP 0x010
  26. #define EPOLLRDHUP 0x2000
  27. #define EPOLLEXCLUSIVE (1U<<28)
  28. #define EPOLLWAKEUP (1U<<29)
  29. #define EPOLLONESHOT (1U<<30)
  30. #define EPOLLET (1U<<31)
  31. #define EPOLL_CTL_ADD 1
  32. #define EPOLL_CTL_DEL 2
  33. #define EPOLL_CTL_MOD 3
  34. typedef union epoll_data {
  35. void *ptr;
  36. int fd;
  37. uint32_t u32;
  38. uint64_t u64;
  39. } epoll_data_t;
  40. struct epoll_event {
  41. uint32_t events;
  42. epoll_data_t data;
  43. }
  44. #ifdef __x86_64__
  45. __attribute__ ((__packed__))
  46. #endif
  47. ;
  48. struct epoll_params {
  49. uint32_t busy_poll_usecs;
  50. uint16_t busy_poll_budget;
  51. uint8_t prefer_busy_poll;
  52. uint8_t __pad;
  53. };
  54. #define EPOLL_IOC_TYPE 0x8A
  55. #define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params)
  56. #define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params)
  57. int epoll_create(int);
  58. int epoll_create1(int);
  59. int epoll_ctl(int, int, int, struct epoll_event *);
  60. int epoll_wait(int, struct epoll_event *, int, int);
  61. int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* sys/epoll.h */