epoll.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright (C) 2002, 2003, 2004 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. EPOLLONESHOT = (1 << 30),
  42. #define EPOLLONESHOT EPOLLONESHOT
  43. EPOLLET = (1 << 31)
  44. #define EPOLLET EPOLLET
  45. };
  46. /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */
  47. #define EPOLL_CTL_ADD 1 /* Add a file decriptor to the interface. */
  48. #define EPOLL_CTL_DEL 2 /* Remove a file decriptor from the interface. */
  49. #define EPOLL_CTL_MOD 3 /* Change file decriptor epoll_event structure. */
  50. typedef union epoll_data
  51. {
  52. void *ptr;
  53. int fd;
  54. uint32_t u32;
  55. uint64_t u64;
  56. } epoll_data_t;
  57. struct epoll_event
  58. {
  59. uint32_t events; /* Epoll events */
  60. epoll_data_t data; /* User data variable */
  61. } __attribute__ ((__packed__));
  62. __BEGIN_DECLS
  63. /* Creates an epoll instance. Returns an fd for the new instance.
  64. The "size" parameter is a hint specifying the number of file
  65. descriptors to be associated with the new instance. The fd
  66. returned by epoll_create() should be closed with close(). */
  67. extern int epoll_create (int __size) __THROW;
  68. /* Manipulate an epoll instance "epfd". Returns 0 in case of success,
  69. -1 in case of error ( the "errno" variable will contain the
  70. specific error code ) The "op" parameter is one of the EPOLL_CTL_*
  71. constants defined above. The "fd" parameter is the target of the
  72. operation. The "event" parameter describes which events the caller
  73. is interested in and any associated user data. */
  74. extern int epoll_ctl (int __epfd, int __op, int __fd,
  75. struct epoll_event *__event) __THROW;
  76. /* Wait for events on an epoll instance "epfd". Returns the number of
  77. triggered events returned in "events" buffer. Or -1 in case of
  78. error with the "errno" variable set to the specific error code. The
  79. "events" parameter is a buffer that will contain triggered
  80. events. The "maxevents" is the maximum number of events to be
  81. returned ( usually size of "events" ). The "timeout" parameter
  82. specifies the maximum wait time in milliseconds (-1 == infinite). */
  83. extern int epoll_wait (int __epfd, struct epoll_event *__events,
  84. int __maxevents, int __timeout) __THROW;
  85. __END_DECLS
  86. #endif /* sys/epoll.h */