epoll.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _SYS_EPOLL_H
  16. #define _SYS_EPOLL_H 1
  17. #include <stdint.h>
  18. #include <sys/types.h>
  19. enum EPOLL_EVENTS
  20. {
  21. EPOLLIN = 0x001,
  22. #define EPOLLIN EPOLLIN
  23. EPOLLPRI = 0x002,
  24. #define EPOLLPRI EPOLLPRI
  25. EPOLLOUT = 0x004,
  26. #define EPOLLOUT EPOLLOUT
  27. EPOLLRDNORM = 0x040,
  28. #define EPOLLRDNORM EPOLLRDNORM
  29. EPOLLRDBAND = 0x080,
  30. #define EPOLLRDBAND EPOLLRDBAND
  31. EPOLLWRNORM = 0x100,
  32. #define EPOLLWRNORM EPOLLWRNORM
  33. EPOLLWRBAND = 0x200,
  34. #define EPOLLWRBAND EPOLLWRBAND
  35. EPOLLMSG = 0x400,
  36. #define EPOLLMSG EPOLLMSG
  37. EPOLLERR = 0x008,
  38. #define EPOLLERR EPOLLERR
  39. EPOLLHUP = 0x010,
  40. #define EPOLLHUP EPOLLHUP
  41. EPOLLRDHUP = 0x2000,
  42. #define EPOLLRDHUP EPOLLRDHUP
  43. EPOLLONESHOT = (1 << 30),
  44. #define EPOLLONESHOT EPOLLONESHOT
  45. EPOLLET = (1 << 31)
  46. #define EPOLLET EPOLLET
  47. };
  48. /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
  49. #define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */
  50. #define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */
  51. #define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */
  52. typedef union epoll_data
  53. {
  54. void *ptr;
  55. int fd;
  56. uint32_t u32;
  57. uint64_t u64;
  58. } epoll_data_t;
  59. struct epoll_event
  60. {
  61. uint32_t events; /* Epoll events */
  62. epoll_data_t data; /* User data variable */
  63. };
  64. __BEGIN_DECLS
  65. /* Creates an epoll instance. Returns an fd for the new instance.
  66. The "size" parameter is a hint specifying the number of file
  67. descriptors to be associated with the new instance. The fd
  68. returned by epoll_create() should be closed with close(). */
  69. extern int epoll_create (int __size) __THROW;
  70. /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
  71. -1 in case of error ( the "errno" variable will contain the
  72. specific error code ) The "op" parameter is one of the EPOLL_CTL_*
  73. constants defined above. The "fd" parameter is the target of the
  74. operation. The "event" parameter describes which events the caller
  75. is interested in and any associated user data. */
  76. extern int epoll_ctl (int __epfd, int __op, int __fd,
  77. struct epoll_event *__event) __THROW;
  78. /* Wait for events on an epoll instance "epfd". Returns the number of
  79. triggered events returned in "events" buffer. Or -1 in case of
  80. error with the "errno" variable set to the specific error code. The
  81. "events" parameter is a buffer that will contain triggered
  82. events. The "maxevents" is the maximum number of events to be
  83. returned ( usually size of "events" ). The "timeout" parameter
  84. specifies the maximum wait time in milliseconds (-1 == infinite).
  85. This function is a cancellation point and therefore not marked with
  86. __THROW. */
  87. extern int epoll_wait (int __epfd, struct epoll_event *__events,
  88. int __maxevents, int __timeout);
  89. __END_DECLS
  90. #endif /* sys/epoll.h */