Commit | Line | Data |
---|---|---|
428f9e95 JE |
1 | /* Header for poll(2) emulation |
2 | Contributed by Paolo Bonzini. | |
3 | ||
5e69ceb7 | 4 | Copyright 2001-2003, 2007, 2009-2014 Free Software Foundation, Inc. |
428f9e95 JE |
5 | |
6 | This file is part of gnulib. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
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 Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License along | |
19 | with this program; if not, see <http://www.gnu.org/licenses/>. */ | |
20 | ||
21 | #ifndef _@GUARD_PREFIX@_POLL_H | |
22 | ||
23 | #if __GNUC__ >= 3 | |
24 | @PRAGMA_SYSTEM_HEADER@ | |
25 | #endif | |
26 | @PRAGMA_COLUMNS@ | |
27 | ||
28 | /* The include_next requires a split double-inclusion guard. */ | |
29 | #if @HAVE_POLL_H@ | |
30 | # @INCLUDE_NEXT@ @NEXT_POLL_H@ | |
31 | #endif | |
32 | ||
33 | #ifndef _@GUARD_PREFIX@_POLL_H | |
34 | #define _@GUARD_PREFIX@_POLL_H | |
35 | ||
36 | ||
37 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | |
38 | ||
39 | /* The definition of _GL_WARN_ON_USE is copied here. */ | |
40 | ||
41 | ||
42 | #if !@HAVE_POLL_H@ | |
43 | ||
44 | /* fake a poll(2) environment */ | |
45 | # define POLLIN 0x0001 /* any readable data available */ | |
46 | # define POLLPRI 0x0002 /* OOB/Urgent readable data */ | |
47 | # define POLLOUT 0x0004 /* file descriptor is writable */ | |
48 | # define POLLERR 0x0008 /* some poll error occurred */ | |
49 | # define POLLHUP 0x0010 /* file descriptor was "hung up" */ | |
50 | # define POLLNVAL 0x0020 /* requested events "invalid" */ | |
51 | # define POLLRDNORM 0x0040 | |
52 | # define POLLRDBAND 0x0080 | |
53 | # define POLLWRNORM 0x0100 | |
54 | # define POLLWRBAND 0x0200 | |
55 | ||
56 | # if !GNULIB_defined_poll_types | |
57 | ||
58 | struct pollfd | |
59 | { | |
60 | int fd; /* which file descriptor to poll */ | |
61 | short events; /* events we are interested in */ | |
62 | short revents; /* events found on return */ | |
63 | }; | |
64 | ||
65 | typedef unsigned long nfds_t; | |
66 | ||
67 | # define GNULIB_defined_poll_types 1 | |
68 | # endif | |
69 | ||
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 | ||
75 | #endif | |
76 | ||
77 | ||
78 | #if @GNULIB_POLL@ | |
79 | # if @REPLACE_POLL@ | |
80 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
81 | # undef poll | |
82 | # define poll rpl_poll | |
83 | # endif | |
84 | _GL_FUNCDECL_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); | |
85 | _GL_CXXALIAS_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); | |
86 | # else | |
87 | # if !@HAVE_POLL@ | |
88 | _GL_FUNCDECL_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); | |
89 | # endif | |
90 | _GL_CXXALIAS_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout)); | |
91 | # endif | |
92 | _GL_CXXALIASWARN (poll); | |
93 | #elif defined GNULIB_POSIXCHECK | |
94 | # undef poll | |
95 | # if HAVE_RAW_DECL_POLL | |
96 | _GL_WARN_ON_USE (poll, "poll is unportable - " | |
97 | "use gnulib module poll for portability"); | |
98 | # endif | |
99 | #endif | |
100 | ||
101 | ||
102 | #endif /* _@GUARD_PREFIX@_POLL_H */ | |
103 | #endif /* _@GUARD_PREFIX@_POLL_H */ |