poll.in.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Header for poll(2) emulation
  2. Contributed by Paolo Bonzini.
  3. Copyright 2001-2003, 2007, 2009-2023 Free Software Foundation, Inc.
  4. This file is part of gnulib.
  5. This file is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as
  7. published by the Free Software Foundation; either version 2.1 of the
  8. License, or (at your option) any later version.
  9. This file is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  15. #ifndef _@GUARD_PREFIX@_POLL_H
  16. #if __GNUC__ >= 3
  17. @PRAGMA_SYSTEM_HEADER@
  18. #endif
  19. @PRAGMA_COLUMNS@
  20. /* The include_next requires a split double-inclusion guard. */
  21. #if @HAVE_POLL_H@
  22. # @INCLUDE_NEXT@ @NEXT_POLL_H@
  23. #endif
  24. #ifndef _@GUARD_PREFIX@_POLL_H
  25. #define _@GUARD_PREFIX@_POLL_H
  26. /* On native Windows, get the 'struct pollfd' type and the POLL* macro
  27. definitions before we override them. mingw defines them in <winsock2.h>
  28. if _WIN32_WINNT >= 0x0600. */
  29. #if @HAVE_WINSOCK2_H@
  30. # include <winsock2.h>
  31. #endif
  32. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  33. /* The definition of _GL_WARN_ON_USE is copied here. */
  34. #if !@HAVE_POLL_H@
  35. # if @HAVE_WINSOCK2_H@
  36. /* Override the definitions from <winsock2.h>. */
  37. # undef POLLIN
  38. # undef POLLPRI
  39. # undef POLLOUT
  40. # undef POLLERR
  41. # undef POLLHUP
  42. # undef POLLNVAL
  43. # undef POLLRDNORM
  44. # undef POLLRDBAND
  45. # undef POLLWRNORM
  46. # undef POLLWRBAND
  47. # define pollfd rpl_pollfd
  48. # endif
  49. /* fake a poll(2) environment */
  50. # define POLLIN 0x0001 /* any readable data available */
  51. # define POLLPRI 0x0002 /* OOB/Urgent readable data */
  52. # define POLLOUT 0x0004 /* file descriptor is writable */
  53. # define POLLERR 0x0008 /* some poll error occurred */
  54. # define POLLHUP 0x0010 /* file descriptor was "hung up" */
  55. # define POLLNVAL 0x0020 /* requested events "invalid" */
  56. # define POLLRDNORM 0x0040
  57. # define POLLRDBAND 0x0080
  58. # define POLLWRNORM 0x0100
  59. # define POLLWRBAND 0x0200
  60. # if !GNULIB_defined_poll_types
  61. struct pollfd
  62. {
  63. int fd; /* which file descriptor to poll */
  64. short events; /* events we are interested in */
  65. short revents; /* events found on return */
  66. };
  67. typedef unsigned long nfds_t;
  68. # define GNULIB_defined_poll_types 1
  69. # endif
  70. /* Define INFTIM only if doing so conforms to POSIX. */
  71. # if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
  72. # define INFTIM (-1)
  73. # endif
  74. #endif
  75. #if @GNULIB_POLL@
  76. # if @REPLACE_POLL@
  77. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  78. # undef poll
  79. # define poll rpl_poll
  80. # endif
  81. _GL_FUNCDECL_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  82. _GL_CXXALIAS_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  83. # else
  84. # if !@HAVE_POLL@
  85. _GL_FUNCDECL_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  86. # endif
  87. _GL_CXXALIAS_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  88. # endif
  89. _GL_CXXALIASWARN (poll);
  90. #elif defined GNULIB_POSIXCHECK
  91. # undef poll
  92. # if HAVE_RAW_DECL_POLL
  93. _GL_WARN_ON_USE (poll, "poll is unportable - "
  94. "use gnulib module poll for portability");
  95. # endif
  96. #endif
  97. #endif /* _@GUARD_PREFIX@_POLL_H */
  98. #endif /* _@GUARD_PREFIX@_POLL_H */