* package.el (describe-package): Convert the guess to a string
[emacs.git] / lib / sys_select.in.h
blobfd7a2917c7e08241088af0e8f33c3a25e5156450
1 /* Substitute for <sys/select.h>.
2 Copyright (C) 2007-2015 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 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 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 # if __GNUC__ >= 3
18 @PRAGMA_SYSTEM_HEADER@
19 # endif
20 @PRAGMA_COLUMNS@
22 /* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
23 both include <sys/select.h>.
24 On Cygwin, <sys/time.h> includes <sys/select.h>.
25 Simply delegate to the system's header in this case. */
26 #if (@HAVE_SYS_SELECT_H@ \
27 && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H \
28 && ((defined __osf__ && defined _SYS_TYPES_H_ \
29 && defined _OSF_SOURCE) \
30 || (defined __sun && defined _SYS_TYPES_H \
31 && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \
32 || defined __EXTENSIONS__))))
34 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
35 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
37 #elif (@HAVE_SYS_SELECT_H@ \
38 && (defined _CYGWIN_SYS_TIME_H \
39 || (!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H \
40 && ((defined __osf__ && defined _SYS_TIME_H_ \
41 && defined _OSF_SOURCE) \
42 || (defined __sun && defined _SYS_TIME_H \
43 && (! (defined _XOPEN_SOURCE \
44 || defined _POSIX_C_SOURCE) \
45 || defined __EXTENSIONS__))))))
47 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
48 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
50 /* On IRIX 6.5, <sys/timespec.h> includes <sys/types.h>, which includes
51 <sys/bsd_types.h>, which includes <sys/select.h>. At this point we cannot
52 include <signal.h>, because that includes <internal/signal_core.h>, which
53 gives a syntax error because <sys/timespec.h> has not been completely
54 processed. Simply delegate to the system's header in this case. */
55 #elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H)
57 # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H
58 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
60 /* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes
61 <sys/select.h>. At this point we cannot include <signal.h>, because that
62 includes gnulib's pthread.h override, which gives a syntax error because
63 /usr/include/pthread.h has not been completely processed. Simply delegate
64 to the system's header in this case. */
65 #elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER)
67 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
69 #else
71 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
73 /* On many platforms, <sys/select.h> assumes prior inclusion of
74 <sys/types.h>. Also, mingw defines sigset_t there, instead of
75 in <signal.h> where it belongs. */
76 #include <sys/types.h>
78 #if @HAVE_SYS_SELECT_H@
80 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
81 of 'struct timeval', and no definition of this type.
82 Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
83 in <sys/time.h>.
84 But avoid namespace pollution on glibc systems. */
85 # ifndef __GLIBC__
86 # include <sys/time.h>
87 # endif
89 /* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
90 that relies on memset(), but without including <string.h>.
91 But in any case avoid namespace pollution on glibc systems. */
92 # if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \
93 && ! defined __GLIBC__
94 # include <string.h>
95 # endif
97 /* The include_next requires a split double-inclusion guard. */
98 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
100 #endif
102 /* Get definition of 'sigset_t'.
103 But avoid namespace pollution on glibc systems.
104 Do this after the include_next (for the sake of OpenBSD 5.0) but before
105 the split double-inclusion guard (for the sake of Solaris). */
106 #if !(defined __GLIBC__ && !defined __UCLIBC__)
107 # include <signal.h>
108 #endif
110 #ifndef _@GUARD_PREFIX@_SYS_SELECT_H
111 #define _@GUARD_PREFIX@_SYS_SELECT_H
113 #if !@HAVE_SYS_SELECT_H@
114 /* A platform that lacks <sys/select.h>. */
115 /* Get the 'struct timeval' and 'fd_set' types and the FD_* macros
116 on most platforms. */
117 # include <sys/time.h>
118 /* On HP-UX 11, <sys/time.h> provides an FD_ZERO implementation
119 that relies on memset(), but without including <string.h>. */
120 # if defined __hpux
121 # include <string.h>
122 # endif
123 /* On native Windows platforms:
124 Get the 'fd_set' type.
125 Get the close() declaration before we override it. */
126 # if @HAVE_WINSOCK2_H@
127 # if !defined _GL_INCLUDING_WINSOCK2_H
128 # define _GL_INCLUDING_WINSOCK2_H
129 # include <winsock2.h>
130 # undef _GL_INCLUDING_WINSOCK2_H
131 # endif
132 # include <io.h>
133 # endif
134 #endif
136 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
138 /* The definition of _GL_WARN_ON_USE is copied here. */
141 /* Fix some definitions from <winsock2.h>. */
143 #if @HAVE_WINSOCK2_H@
145 # if !GNULIB_defined_rpl_fd_isset
147 /* Re-define FD_ISSET to avoid a WSA call while we are not using
148 network sockets. */
149 static int
150 rpl_fd_isset (SOCKET fd, fd_set * set)
152 u_int i;
153 if (set == NULL)
154 return 0;
156 for (i = 0; i < set->fd_count; i++)
157 if (set->fd_array[i] == fd)
158 return 1;
160 return 0;
163 # define GNULIB_defined_rpl_fd_isset 1
164 # endif
166 # undef FD_ISSET
167 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
169 #endif
171 /* Hide some function declarations from <winsock2.h>. */
173 #if @HAVE_WINSOCK2_H@
174 # if !defined _@GUARD_PREFIX@_UNISTD_H
175 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176 # undef close
177 # define close close_used_without_including_unistd_h
178 # else
179 _GL_WARN_ON_USE (close,
180 "close() used without including <unistd.h>");
181 # endif
182 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
183 # undef gethostname
184 # define gethostname gethostname_used_without_including_unistd_h
185 # else
186 _GL_WARN_ON_USE (gethostname,
187 "gethostname() used without including <unistd.h>");
188 # endif
189 # endif
190 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
191 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
192 # undef socket
193 # define socket socket_used_without_including_sys_socket_h
194 # undef connect
195 # define connect connect_used_without_including_sys_socket_h
196 # undef accept
197 # define accept accept_used_without_including_sys_socket_h
198 # undef bind
199 # define bind bind_used_without_including_sys_socket_h
200 # undef getpeername
201 # define getpeername getpeername_used_without_including_sys_socket_h
202 # undef getsockname
203 # define getsockname getsockname_used_without_including_sys_socket_h
204 # undef getsockopt
205 # define getsockopt getsockopt_used_without_including_sys_socket_h
206 # undef listen
207 # define listen listen_used_without_including_sys_socket_h
208 # undef recv
209 # define recv recv_used_without_including_sys_socket_h
210 # undef send
211 # define send send_used_without_including_sys_socket_h
212 # undef recvfrom
213 # define recvfrom recvfrom_used_without_including_sys_socket_h
214 # undef sendto
215 # define sendto sendto_used_without_including_sys_socket_h
216 # undef setsockopt
217 # define setsockopt setsockopt_used_without_including_sys_socket_h
218 # undef shutdown
219 # define shutdown shutdown_used_without_including_sys_socket_h
220 # else
221 _GL_WARN_ON_USE (socket,
222 "socket() used without including <sys/socket.h>");
223 _GL_WARN_ON_USE (connect,
224 "connect() used without including <sys/socket.h>");
225 _GL_WARN_ON_USE (accept,
226 "accept() used without including <sys/socket.h>");
227 _GL_WARN_ON_USE (bind,
228 "bind() used without including <sys/socket.h>");
229 _GL_WARN_ON_USE (getpeername,
230 "getpeername() used without including <sys/socket.h>");
231 _GL_WARN_ON_USE (getsockname,
232 "getsockname() used without including <sys/socket.h>");
233 _GL_WARN_ON_USE (getsockopt,
234 "getsockopt() used without including <sys/socket.h>");
235 _GL_WARN_ON_USE (listen,
236 "listen() used without including <sys/socket.h>");
237 _GL_WARN_ON_USE (recv,
238 "recv() used without including <sys/socket.h>");
239 _GL_WARN_ON_USE (send,
240 "send() used without including <sys/socket.h>");
241 _GL_WARN_ON_USE (recvfrom,
242 "recvfrom() used without including <sys/socket.h>");
243 _GL_WARN_ON_USE (sendto,
244 "sendto() used without including <sys/socket.h>");
245 _GL_WARN_ON_USE (setsockopt,
246 "setsockopt() used without including <sys/socket.h>");
247 _GL_WARN_ON_USE (shutdown,
248 "shutdown() used without including <sys/socket.h>");
249 # endif
250 # endif
251 #endif
254 #if @GNULIB_PSELECT@
255 # if @REPLACE_PSELECT@
256 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257 # undef pselect
258 # define pselect rpl_pselect
259 # endif
260 _GL_FUNCDECL_RPL (pselect, int,
261 (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
262 struct timespec const *restrict, const sigset_t *restrict));
263 _GL_CXXALIAS_RPL (pselect, int,
264 (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
265 struct timespec const *restrict, const sigset_t *restrict));
266 # else
267 # if !@HAVE_PSELECT@
268 _GL_FUNCDECL_SYS (pselect, int,
269 (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
270 struct timespec const *restrict, const sigset_t *restrict));
271 # endif
272 _GL_CXXALIAS_SYS (pselect, int,
273 (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
274 struct timespec const *restrict, const sigset_t *restrict));
275 # endif
276 _GL_CXXALIASWARN (pselect);
277 #elif defined GNULIB_POSIXCHECK
278 # undef pselect
279 # if HAVE_RAW_DECL_PSELECT
280 _GL_WARN_ON_USE (pselect, "pselect is not portable - "
281 "use gnulib module pselect for portability");
282 # endif
283 #endif
285 #if @GNULIB_SELECT@
286 # if @REPLACE_SELECT@
287 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
288 # undef select
289 # define select rpl_select
290 # endif
291 _GL_FUNCDECL_RPL (select, int,
292 (int, fd_set *, fd_set *, fd_set *, struct timeval *));
293 _GL_CXXALIAS_RPL (select, int,
294 (int, fd_set *, fd_set *, fd_set *, struct timeval *));
295 # else
296 _GL_CXXALIAS_SYS (select, int,
297 (int, fd_set *, fd_set *, fd_set *, struct timeval *));
298 # endif
299 _GL_CXXALIASWARN (select);
300 #elif @HAVE_WINSOCK2_H@
301 # undef select
302 # define select select_used_without_requesting_gnulib_module_select
303 #elif defined GNULIB_POSIXCHECK
304 # undef select
305 # if HAVE_RAW_DECL_SELECT
306 _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
307 "use gnulib module select for portability");
308 # endif
309 #endif
312 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
313 #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */
314 #endif /* OSF/1 */