eventpoll.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * include/linux/eventpoll.h ( Efficient event polling implementation )
  3. * Copyright (C) 2001,...,2006 Davide Libenzi
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Davide Libenzi <davidel@xmailserver.org>
  11. *
  12. */
  13. #ifndef _UAPI_LINUX_EVENTPOLL_H
  14. #define _UAPI_LINUX_EVENTPOLL_H
  15. /* For O_CLOEXEC */
  16. #include <linux/fcntl.h>
  17. #include <linux/types.h>
  18. /* Flags for epoll_create1. */
  19. #define EPOLL_CLOEXEC O_CLOEXEC
  20. /* Valid opcodes to issue to sys_epoll_ctl() */
  21. #define EPOLL_CTL_ADD 1
  22. #define EPOLL_CTL_DEL 2
  23. #define EPOLL_CTL_MOD 3
  24. /* Epoll event masks */
  25. #define EPOLLIN 0x00000001
  26. #define EPOLLPRI 0x00000002
  27. #define EPOLLOUT 0x00000004
  28. #define EPOLLERR 0x00000008
  29. #define EPOLLHUP 0x00000010
  30. #define EPOLLRDNORM 0x00000040
  31. #define EPOLLRDBAND 0x00000080
  32. #define EPOLLWRNORM 0x00000100
  33. #define EPOLLWRBAND 0x00000200
  34. #define EPOLLMSG 0x00000400
  35. #define EPOLLRDHUP 0x00002000
  36. /* Set exclusive wakeup mode for the target file descriptor */
  37. #define EPOLLEXCLUSIVE (1U << 28)
  38. /*
  39. * Request the handling of system wakeup events so as to prevent system suspends
  40. * from happening while those events are being processed.
  41. *
  42. * Assuming neither EPOLLET nor EPOLLONESHOT is set, system suspends will not be
  43. * re-allowed until epoll_wait is called again after consuming the wakeup
  44. * event(s).
  45. *
  46. * Requires CAP_BLOCK_SUSPEND
  47. */
  48. #define EPOLLWAKEUP (1U << 29)
  49. /* Set the One Shot behaviour for the target file descriptor */
  50. #define EPOLLONESHOT (1U << 30)
  51. /* Set the Edge Triggered behaviour for the target file descriptor */
  52. #define EPOLLET (1U << 31)
  53. /*
  54. * On x86-64 make the 64bit structure have the same alignment as the
  55. * 32bit structure. This makes 32bit emulation easier.
  56. *
  57. * UML/x86_64 needs the same packing as x86_64
  58. */
  59. #ifdef __x86_64__
  60. #define EPOLL_PACKED __attribute__((packed))
  61. #else
  62. #define EPOLL_PACKED
  63. #endif
  64. struct epoll_event {
  65. __u32 events;
  66. __u64 data;
  67. } EPOLL_PACKED;
  68. #ifdef CONFIG_PM_SLEEP
  69. static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
  70. {
  71. if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
  72. epev->events &= ~EPOLLWAKEUP;
  73. }
  74. #else
  75. static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
  76. {
  77. epev->events &= ~EPOLLWAKEUP;
  78. }
  79. #endif
  80. #endif /* _UAPI_LINUX_EVENTPOLL_H */