poll.in.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Header for poll(2) emulation
  2. Contributed by Paolo Bonzini.
  3. Copyright 2001-2003, 2007, 2009-2017 Free Software Foundation, Inc.
  4. This file is part of gnulib.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. This program 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 along
  14. with this program; if not, see <http://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. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  27. /* The definition of _GL_WARN_ON_USE is copied here. */
  28. #if !@HAVE_POLL_H@
  29. /* fake a poll(2) environment */
  30. # define POLLIN 0x0001 /* any readable data available */
  31. # define POLLPRI 0x0002 /* OOB/Urgent readable data */
  32. # define POLLOUT 0x0004 /* file descriptor is writable */
  33. # define POLLERR 0x0008 /* some poll error occurred */
  34. # define POLLHUP 0x0010 /* file descriptor was "hung up" */
  35. # define POLLNVAL 0x0020 /* requested events "invalid" */
  36. # define POLLRDNORM 0x0040
  37. # define POLLRDBAND 0x0080
  38. # define POLLWRNORM 0x0100
  39. # define POLLWRBAND 0x0200
  40. # if !GNULIB_defined_poll_types
  41. struct pollfd
  42. {
  43. int fd; /* which file descriptor to poll */
  44. short events; /* events we are interested in */
  45. short revents; /* events found on return */
  46. };
  47. typedef unsigned long nfds_t;
  48. # define GNULIB_defined_poll_types 1
  49. # endif
  50. /* Define INFTIM only if doing so conforms to POSIX. */
  51. # if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
  52. # define INFTIM (-1)
  53. # endif
  54. #endif
  55. #if @GNULIB_POLL@
  56. # if @REPLACE_POLL@
  57. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  58. # undef poll
  59. # define poll rpl_poll
  60. # endif
  61. _GL_FUNCDECL_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  62. _GL_CXXALIAS_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  63. # else
  64. # if !@HAVE_POLL@
  65. _GL_FUNCDECL_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  66. # endif
  67. _GL_CXXALIAS_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
  68. # endif
  69. _GL_CXXALIASWARN (poll);
  70. #elif defined GNULIB_POSIXCHECK
  71. # undef poll
  72. # if HAVE_RAW_DECL_POLL
  73. _GL_WARN_ON_USE (poll, "poll is unportable - "
  74. "use gnulib module poll for portability");
  75. # endif
  76. #endif
  77. #endif /* _@GUARD_PREFIX@_POLL_H */
  78. #endif /* _@GUARD_PREFIX@_POLL_H */