eventpoll.h 3.0 KB

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