eventpoll.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /*
  37. * Request the handling of system wakeup events so as to prevent system suspends
  38. * from happening while those events are being processed.
  39. *
  40. * Assuming neither EPOLLET nor EPOLLONESHOT is set, system suspends will not be
  41. * re-allowed until epoll_wait is called again after consuming the wakeup
  42. * event(s).
  43. *
  44. * Requires CAP_BLOCK_SUSPEND
  45. */
  46. #define EPOLLWAKEUP (1 << 29)
  47. /* Set the One Shot behaviour for the target file descriptor */
  48. #define EPOLLONESHOT (1 << 30)
  49. /* Set the Edge Triggered behaviour for the target file descriptor */
  50. #define EPOLLET (1 << 31)
  51. /*
  52. * On x86-64 make the 64bit structure have the same alignment as the
  53. * 32bit structure. This makes 32bit emulation easier.
  54. *
  55. * UML/x86_64 needs the same packing as x86_64
  56. */
  57. #ifdef __x86_64__
  58. #define EPOLL_PACKED __attribute__((packed))
  59. #else
  60. #define EPOLL_PACKED
  61. #endif
  62. struct epoll_event {
  63. __u32 events;
  64. __u64 data;
  65. } EPOLL_PACKED;
  66. #ifdef CONFIG_PM_SLEEP
  67. static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
  68. {
  69. if ((epev->events & EPOLLWAKEUP) && !capable(CAP_BLOCK_SUSPEND))
  70. epev->events &= ~EPOLLWAKEUP;
  71. }
  72. #else
  73. static inline void ep_take_care_of_epollwakeup(struct epoll_event *epev)
  74. {
  75. epev->events &= ~EPOLLWAKEUP;
  76. }
  77. #endif
  78. #endif /* _UAPI_LINUX_EVENTPOLL_H */