1 /* Header for poll(2) emulation
2 Contributed by Paolo Bonzini.
4 Copyright 2001-2003, 2007, 2009-2020 Free Software Foundation, Inc.
6 This file is part of gnulib.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, see <https://www.gnu.org/licenses/>. */
21 #ifndef _@GUARD_PREFIX@_POLL_H
24 @PRAGMA_SYSTEM_HEADER@
28 /* The include_next requires a split double-inclusion guard. */
30 # @INCLUDE_NEXT@ @NEXT_POLL_H@
33 #ifndef _@GUARD_PREFIX@_POLL_H
34 #define _@GUARD_PREFIX@_POLL_H
36 /* On native Windows, get the 'struct pollfd' type and the POLL* macro
37 definitions before we override them. mingw defines them in <winsock2.h>
38 if _WIN32_WINNT >= 0x0600. */
40 # include <winsock2.h>
44 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
46 /* The definition of _GL_WARN_ON_USE is copied here. */
51 # if @HAVE_WINSOCK2_H@
52 /* Override the definitions from <winsock2.h>. */
63 # define pollfd rpl_pollfd
66 /* fake a poll(2) environment */
67 # define POLLIN 0x0001 /* any readable data available */
68 # define POLLPRI 0x0002 /* OOB/Urgent readable data */
69 # define POLLOUT 0x0004 /* file descriptor is writable */
70 # define POLLERR 0x0008 /* some poll error occurred */
71 # define POLLHUP 0x0010 /* file descriptor was "hung up" */
72 # define POLLNVAL 0x0020 /* requested events "invalid" */
73 # define POLLRDNORM 0x0040
74 # define POLLRDBAND 0x0080
75 # define POLLWRNORM 0x0100
76 # define POLLWRBAND 0x0200
78 # if !GNULIB_defined_poll_types
82 int fd
; /* which file descriptor to poll */
83 short events
; /* events we are interested in */
84 short revents
; /* events found on return */
87 typedef unsigned long nfds_t
;
89 # define GNULIB_defined_poll_types 1
92 /* Define INFTIM only if doing so conforms to POSIX. */
93 # if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
102 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104 # define poll rpl_poll
106 _GL_FUNCDECL_RPL (poll
, int, (struct pollfd
*pfd
, nfds_t nfd
, int timeout
));
107 _GL_CXXALIAS_RPL (poll
, int, (struct pollfd
*pfd
, nfds_t nfd
, int timeout
));
110 _GL_FUNCDECL_SYS (poll
, int, (struct pollfd
*pfd
, nfds_t nfd
, int timeout
));
112 _GL_CXXALIAS_SYS (poll
, int, (struct pollfd
*pfd
, nfds_t nfd
, int timeout
));
114 _GL_CXXALIASWARN (poll
);
115 #elif defined GNULIB_POSIXCHECK
117 # if HAVE_RAW_DECL_POLL
118 _GL_WARN_ON_USE (poll
, "poll is unportable - "
119 "use gnulib module poll for portability");
124 #endif /* _@GUARD_PREFIX@_POLL_H */
125 #endif /* _@GUARD_PREFIX@_POLL_H */