eventpoll.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 <davidel@xmailserver.org>
  12. *
  13. */
  14. #ifndef _LINUX_EVENTPOLL_H
  15. #define _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 (__poll_t)0x00000001
  27. #define EPOLLPRI (__poll_t)0x00000002
  28. #define EPOLLOUT (__poll_t)0x00000004
  29. #define EPOLLERR (__poll_t)0x00000008
  30. #define EPOLLHUP (__poll_t)0x00000010
  31. #define EPOLLNVAL (__poll_t)0x00000020
  32. #define EPOLLRDNORM (__poll_t)0x00000040
  33. #define EPOLLRDBAND (__poll_t)0x00000080
  34. #define EPOLLWRNORM (__poll_t)0x00000100
  35. #define EPOLLWRBAND (__poll_t)0x00000200
  36. #define EPOLLMSG (__poll_t)0x00000400
  37. #define EPOLLRDHUP (__poll_t)0x00002000
  38. /* Set exclusive wakeup mode for the target file descriptor */
  39. #define EPOLLEXCLUSIVE ((__poll_t)(1U << 28))
  40. /*
  41. * Request the handling of system wakeup events so as to prevent system suspends
  42. * from happening while those events are being processed.
  43. *
  44. * Assuming neither EPOLLET nor EPOLLONESHOT is set, system suspends will not be
  45. * re-allowed until epoll_wait is called again after consuming the wakeup
  46. * event(s).
  47. *
  48. * Requires CAP_BLOCK_SUSPEND
  49. */
  50. #define EPOLLWAKEUP ((__poll_t)(1U << 29))
  51. /* Set the One Shot behaviour for the target file descriptor */
  52. #define EPOLLONESHOT ((__poll_t)(1U << 30))
  53. /* Set the Edge Triggered behaviour for the target file descriptor */
  54. #define EPOLLET ((__poll_t)(1U << 31))
  55. /*
  56. * On x86-64 make the 64bit structure have the same alignment as the
  57. * 32bit structure. This makes 32bit emulation easier.
  58. *
  59. * UML/x86_64 needs the same packing as x86_64
  60. */
  61. #ifdef __x86_64__
  62. #define EPOLL_PACKED __attribute__((packed))
  63. #else
  64. #define EPOLL_PACKED
  65. #endif
  66. struct epoll_event {
  67. __poll_t events;
  68. __u64 data;
  69. } EPOLL_PACKED;
  70. #ifdef CONFIG_PM_SLEEP
  71. static __inline__ void ep_take_care_of_epollwakeup(struct epoll_event *epev)
  72. {
  73. if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
  74. epev->events &= ~EPOLLWAKEUP;
  75. }
  76. #else
  77. static __inline__ void ep_take_care_of_epollwakeup(struct epoll_event *epev)
  78. {
  79. epev->events &= ~EPOLLWAKEUP;
  80. }
  81. #endif
  82. #endif /* _LINUX_EVENTPOLL_H */