Commit | Line | Data |
---|---|---|
8912421c LC |
1 | /* Provide a sys/socket header file for systems lacking it (read: MinGW) |
2 | and for systems where it is incomplete. | |
f0007cad | 3 | Copyright (C) 2005-2012 Free Software Foundation, Inc. |
8912421c LC |
4 | Written by Simon Josefsson. |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU Lesser General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public License | |
005de2e8 | 17 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
8912421c LC |
18 | |
19 | /* This file is supposed to be used on platforms that lack <sys/socket.h>, | |
20 | on platforms where <sys/socket.h> cannot be included standalone, and on | |
21 | platforms where <sys/socket.h> does not provide all necessary definitions. | |
22 | It is intended to provide definitions and prototypes needed by an | |
23 | application. */ | |
24 | ||
a927b6c1 LC |
25 | #if __GNUC__ >= 3 |
26 | @PRAGMA_SYSTEM_HEADER@ | |
27 | #endif | |
0f00f2c3 | 28 | @PRAGMA_COLUMNS@ |
a927b6c1 | 29 | |
f4c79b3c LC |
30 | #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H |
31 | /* Special invocation convention: | |
32 | - On Cygwin 1.5.x we have a sequence of nested includes | |
33 | <sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>, | |
34 | and the latter includes <sys/socket.h>. In this situation, the functions | |
35 | are not yet declared, therefore we cannot provide the C++ aliases. */ | |
36 | ||
37 | #@INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ | |
38 | ||
39 | #else | |
40 | /* Normal invocation convention. */ | |
41 | ||
3d458a81 | 42 | #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H |
8912421c LC |
43 | |
44 | #if @HAVE_SYS_SOCKET_H@ | |
45 | ||
f4c79b3c LC |
46 | # define _GL_ALREADY_INCLUDING_SYS_SOCKET_H |
47 | ||
8912421c LC |
48 | /* On many platforms, <sys/socket.h> assumes prior inclusion of |
49 | <sys/types.h>. */ | |
50 | # include <sys/types.h> | |
51 | ||
dd7d0148 LC |
52 | /* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL |
53 | is defined. */ | |
54 | # include <stddef.h> | |
55 | ||
8912421c LC |
56 | /* The include_next requires a split double-inclusion guard. */ |
57 | # @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ | |
58 | ||
f4c79b3c LC |
59 | # undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H |
60 | ||
8912421c LC |
61 | #endif |
62 | ||
3d458a81 AW |
63 | #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H |
64 | #define _@GUARD_PREFIX@_SYS_SOCKET_H | |
8912421c | 65 | |
f4c79b3c LC |
66 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
67 | ||
1cd4fffc LC |
68 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
69 | ||
f4c79b3c LC |
70 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
71 | ||
8912421c | 72 | #if !@HAVE_SA_FAMILY_T@ |
49114fd4 | 73 | # if !GNULIB_defined_sa_family_t |
8912421c | 74 | typedef unsigned short sa_family_t; |
49114fd4 LC |
75 | # define GNULIB_defined_sa_family_t 1 |
76 | # endif | |
8912421c LC |
77 | #endif |
78 | ||
0f00f2c3 LC |
79 | #if @HAVE_STRUCT_SOCKADDR_STORAGE@ |
80 | /* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */ | |
81 | # if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ | |
82 | # ifndef ss_family | |
83 | # define ss_family __ss_family | |
84 | # endif | |
85 | # endif | |
86 | #else | |
7f1ea859 | 87 | # include <stdalign.h> |
8912421c LC |
88 | /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on |
89 | 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ | |
90 | # define __ss_aligntype unsigned long int | |
91 | # define _SS_SIZE 256 | |
92 | # define _SS_PADSIZE \ | |
1cd4fffc LC |
93 | (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \ |
94 | ? sizeof (sa_family_t) \ | |
95 | : alignof (__ss_aligntype)) \ | |
96 | + sizeof (__ss_aligntype))) | |
8912421c | 97 | |
49114fd4 | 98 | # if !GNULIB_defined_struct_sockaddr_storage |
8912421c LC |
99 | struct sockaddr_storage |
100 | { | |
101 | sa_family_t ss_family; /* Address family, etc. */ | |
102 | __ss_aligntype __ss_align; /* Force desired alignment. */ | |
103 | char __ss_padding[_SS_PADSIZE]; | |
104 | }; | |
49114fd4 LC |
105 | # define GNULIB_defined_struct_sockaddr_storage 1 |
106 | # endif | |
107 | ||
8912421c LC |
108 | #endif |
109 | ||
3d458a81 AW |
110 | /* Get struct iovec. */ |
111 | /* But avoid namespace pollution on glibc systems. */ | |
112 | #if ! defined __GLIBC__ | |
113 | # include <sys/uio.h> | |
114 | #endif | |
115 | ||
8912421c LC |
116 | #if @HAVE_SYS_SOCKET_H@ |
117 | ||
118 | /* A platform that has <sys/socket.h>. */ | |
119 | ||
120 | /* For shutdown(). */ | |
121 | # if !defined SHUT_RD | |
122 | # define SHUT_RD 0 | |
123 | # endif | |
124 | # if !defined SHUT_WR | |
125 | # define SHUT_WR 1 | |
126 | # endif | |
127 | # if !defined SHUT_RDWR | |
128 | # define SHUT_RDWR 2 | |
129 | # endif | |
130 | ||
131 | #else | |
132 | ||
133 | # ifdef __CYGWIN__ | |
134 | # error "Cygwin does have a sys/socket.h, doesn't it?!?" | |
135 | # endif | |
136 | ||
137 | /* A platform that lacks <sys/socket.h>. | |
138 | ||
139 | Currently only MinGW is supported. See the gnulib manual regarding | |
140 | Windows sockets. MinGW has the header files winsock2.h and | |
141 | ws2tcpip.h that declare the sys/socket.h definitions we need. Note | |
142 | that you can influence which definitions you get by setting the | |
143 | WINVER symbol before including these two files. For example, | |
144 | getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that | |
005de2e8 | 145 | symbol is set indirectly through WINVER). You can set this by |
8912421c LC |
146 | adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your |
147 | code may not run on older Windows releases then. My Windows 2000 | |
148 | box was not able to run the code, for example. The situation is | |
0f00f2c3 LC |
149 | slightly confusing because |
150 | <http://msdn.microsoft.com/en-us/library/ms738520> | |
8912421c LC |
151 | suggests that getaddrinfo should be available on all Windows |
152 | releases. */ | |
153 | ||
8912421c LC |
154 | # if @HAVE_WINSOCK2_H@ |
155 | # include <winsock2.h> | |
156 | # endif | |
157 | # if @HAVE_WS2TCPIP_H@ | |
158 | # include <ws2tcpip.h> | |
159 | # endif | |
160 | ||
161 | /* For shutdown(). */ | |
162 | # if !defined SHUT_RD && defined SD_RECEIVE | |
163 | # define SHUT_RD SD_RECEIVE | |
164 | # endif | |
165 | # if !defined SHUT_WR && defined SD_SEND | |
166 | # define SHUT_WR SD_SEND | |
167 | # endif | |
168 | # if !defined SHUT_RDWR && defined SD_BOTH | |
169 | # define SHUT_RDWR SD_BOTH | |
170 | # endif | |
171 | ||
8912421c LC |
172 | # if @HAVE_WINSOCK2_H@ |
173 | /* Include headers needed by the emulation code. */ | |
174 | # include <sys/types.h> | |
175 | # include <io.h> | |
176 | ||
49114fd4 | 177 | # if !GNULIB_defined_socklen_t |
8912421c | 178 | typedef int socklen_t; |
49114fd4 LC |
179 | # define GNULIB_defined_socklen_t 1 |
180 | # endif | |
8912421c LC |
181 | |
182 | # endif | |
183 | ||
dd7d0148 LC |
184 | /* Rudimentary 'struct msghdr'; this works as long as you don't try to |
185 | access msg_control or msg_controllen. */ | |
186 | struct msghdr { | |
187 | void *msg_name; | |
188 | socklen_t msg_namelen; | |
189 | struct iovec *msg_iov; | |
190 | int msg_iovlen; | |
191 | int msg_flags; | |
192 | }; | |
193 | ||
f4c79b3c | 194 | #endif |
8912421c | 195 | |
35428fb6 LC |
196 | /* Fix some definitions from <winsock2.h>. */ |
197 | ||
f4c79b3c | 198 | #if @HAVE_WINSOCK2_H@ |
8912421c | 199 | |
49114fd4 LC |
200 | # if !GNULIB_defined_rpl_fd_isset |
201 | ||
8912421c LC |
202 | /* Re-define FD_ISSET to avoid a WSA call while we are not using |
203 | network sockets. */ | |
204 | static inline int | |
205 | rpl_fd_isset (SOCKET fd, fd_set * set) | |
206 | { | |
207 | u_int i; | |
208 | if (set == NULL) | |
209 | return 0; | |
210 | ||
211 | for (i = 0; i < set->fd_count; i++) | |
212 | if (set->fd_array[i] == fd) | |
213 | return 1; | |
214 | ||
215 | return 0; | |
216 | } | |
217 | ||
49114fd4 LC |
218 | # define GNULIB_defined_rpl_fd_isset 1 |
219 | # endif | |
220 | ||
f4c79b3c LC |
221 | # undef FD_ISSET |
222 | # define FD_ISSET(fd, set) rpl_fd_isset(fd, set) | |
8912421c | 223 | |
f4c79b3c | 224 | #endif |
8912421c | 225 | |
35428fb6 | 226 | /* Hide some function declarations from <winsock2.h>. */ |
8912421c | 227 | |
35428fb6 LC |
228 | #if @HAVE_WINSOCK2_H@ |
229 | # if !defined _@GUARD_PREFIX@_UNISTD_H | |
230 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
231 | # undef close | |
232 | # define close close_used_without_including_unistd_h | |
233 | # else | |
234 | _GL_WARN_ON_USE (close, | |
235 | "close() used without including <unistd.h>"); | |
236 | # endif | |
237 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
238 | # undef gethostname | |
239 | # define gethostname gethostname_used_without_including_unistd_h | |
240 | # else | |
241 | _GL_WARN_ON_USE (gethostname, | |
242 | "gethostname() used without including <unistd.h>"); | |
243 | # endif | |
a927b6c1 | 244 | # endif |
35428fb6 LC |
245 | # if !defined _@GUARD_PREFIX@_SYS_SELECT_H |
246 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
247 | # undef select | |
248 | # define select select_used_without_including_sys_select_h | |
249 | # else | |
250 | _GL_WARN_ON_USE (select, | |
251 | "select() used without including <sys/select.h>"); | |
252 | # endif | |
a927b6c1 | 253 | # endif |
f4c79b3c | 254 | #endif |
8912421c | 255 | |
35428fb6 LC |
256 | /* Wrap everything else to use libc file descriptors for sockets. */ |
257 | ||
f4c79b3c LC |
258 | #if @GNULIB_SOCKET@ |
259 | # if @HAVE_WINSOCK2_H@ | |
260 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 261 | # undef socket |
f4c79b3c | 262 | # define socket rpl_socket |
8912421c | 263 | # endif |
f4c79b3c LC |
264 | _GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol)); |
265 | _GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol)); | |
266 | # else | |
267 | _GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol)); | |
268 | # endif | |
269 | _GL_CXXALIASWARN (socket); | |
270 | #elif @HAVE_WINSOCK2_H@ | |
271 | # undef socket | |
272 | # define socket socket_used_without_requesting_gnulib_module_socket | |
273 | #elif defined GNULIB_POSIXCHECK | |
274 | # undef socket | |
275 | # if HAVE_RAW_DECL_SOCKET | |
61cd9dc9 LC |
276 | _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - " |
277 | "use gnulib module socket for portability"); | |
8912421c | 278 | # endif |
f4c79b3c | 279 | #endif |
8912421c | 280 | |
f4c79b3c LC |
281 | #if @GNULIB_CONNECT@ |
282 | # if @HAVE_WINSOCK2_H@ | |
283 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 284 | # undef connect |
f4c79b3c | 285 | # define connect rpl_connect |
8912421c | 286 | # endif |
f4c79b3c LC |
287 | _GL_FUNCDECL_RPL (connect, int, |
288 | (int fd, const struct sockaddr *addr, socklen_t addrlen) | |
289 | _GL_ARG_NONNULL ((2))); | |
290 | _GL_CXXALIAS_RPL (connect, int, | |
291 | (int fd, const struct sockaddr *addr, socklen_t addrlen)); | |
292 | # else | |
49114fd4 LC |
293 | /* Need to cast, because on NonStop Kernel, the third parameter is |
294 | size_t addrlen. */ | |
295 | _GL_CXXALIAS_SYS_CAST (connect, int, | |
296 | (int fd, | |
297 | const struct sockaddr *addr, socklen_t addrlen)); | |
f4c79b3c LC |
298 | # endif |
299 | _GL_CXXALIASWARN (connect); | |
300 | #elif @HAVE_WINSOCK2_H@ | |
301 | # undef connect | |
302 | # define connect socket_used_without_requesting_gnulib_module_connect | |
303 | #elif defined GNULIB_POSIXCHECK | |
304 | # undef connect | |
305 | # if HAVE_RAW_DECL_CONNECT | |
61cd9dc9 LC |
306 | _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - " |
307 | "use gnulib module connect for portability"); | |
8912421c | 308 | # endif |
f4c79b3c | 309 | #endif |
8912421c | 310 | |
f4c79b3c LC |
311 | #if @GNULIB_ACCEPT@ |
312 | # if @HAVE_WINSOCK2_H@ | |
313 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 314 | # undef accept |
f4c79b3c | 315 | # define accept rpl_accept |
8912421c | 316 | # endif |
f4c79b3c LC |
317 | _GL_FUNCDECL_RPL (accept, int, |
318 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
319 | _GL_CXXALIAS_RPL (accept, int, | |
320 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
321 | # else | |
322 | /* Need to cast, because on Solaris 10 systems, the third parameter is | |
323 | void *addrlen. */ | |
324 | _GL_CXXALIAS_SYS_CAST (accept, int, | |
325 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
326 | # endif | |
327 | _GL_CXXALIASWARN (accept); | |
328 | #elif @HAVE_WINSOCK2_H@ | |
329 | # undef accept | |
330 | # define accept accept_used_without_requesting_gnulib_module_accept | |
331 | #elif defined GNULIB_POSIXCHECK | |
332 | # undef accept | |
61cd9dc9 LC |
333 | # if HAVE_RAW_DECL_ACCEPT |
334 | _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - " | |
335 | "use gnulib module accept for portability"); | |
8912421c | 336 | # endif |
f4c79b3c | 337 | #endif |
8912421c | 338 | |
f4c79b3c LC |
339 | #if @GNULIB_BIND@ |
340 | # if @HAVE_WINSOCK2_H@ | |
341 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 342 | # undef bind |
f4c79b3c | 343 | # define bind rpl_bind |
8912421c | 344 | # endif |
f4c79b3c LC |
345 | _GL_FUNCDECL_RPL (bind, int, |
346 | (int fd, const struct sockaddr *addr, socklen_t addrlen) | |
347 | _GL_ARG_NONNULL ((2))); | |
348 | _GL_CXXALIAS_RPL (bind, int, | |
349 | (int fd, const struct sockaddr *addr, socklen_t addrlen)); | |
350 | # else | |
49114fd4 LC |
351 | /* Need to cast, because on NonStop Kernel, the third parameter is |
352 | size_t addrlen. */ | |
353 | _GL_CXXALIAS_SYS_CAST (bind, int, | |
354 | (int fd, | |
355 | const struct sockaddr *addr, socklen_t addrlen)); | |
f4c79b3c LC |
356 | # endif |
357 | _GL_CXXALIASWARN (bind); | |
358 | #elif @HAVE_WINSOCK2_H@ | |
359 | # undef bind | |
360 | # define bind bind_used_without_requesting_gnulib_module_bind | |
361 | #elif defined GNULIB_POSIXCHECK | |
362 | # undef bind | |
363 | # if HAVE_RAW_DECL_BIND | |
61cd9dc9 LC |
364 | _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - " |
365 | "use gnulib module bind for portability"); | |
8912421c | 366 | # endif |
f4c79b3c | 367 | #endif |
8912421c | 368 | |
f4c79b3c LC |
369 | #if @GNULIB_GETPEERNAME@ |
370 | # if @HAVE_WINSOCK2_H@ | |
371 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 372 | # undef getpeername |
f4c79b3c | 373 | # define getpeername rpl_getpeername |
8912421c | 374 | # endif |
f4c79b3c LC |
375 | _GL_FUNCDECL_RPL (getpeername, int, |
376 | (int fd, struct sockaddr *addr, socklen_t *addrlen) | |
377 | _GL_ARG_NONNULL ((2, 3))); | |
378 | _GL_CXXALIAS_RPL (getpeername, int, | |
379 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
380 | # else | |
381 | /* Need to cast, because on Solaris 10 systems, the third parameter is | |
382 | void *addrlen. */ | |
383 | _GL_CXXALIAS_SYS_CAST (getpeername, int, | |
384 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
385 | # endif | |
386 | _GL_CXXALIASWARN (getpeername); | |
387 | #elif @HAVE_WINSOCK2_H@ | |
388 | # undef getpeername | |
389 | # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername | |
390 | #elif defined GNULIB_POSIXCHECK | |
391 | # undef getpeername | |
392 | # if HAVE_RAW_DECL_GETPEERNAME | |
61cd9dc9 LC |
393 | _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - " |
394 | "use gnulib module getpeername for portability"); | |
8912421c | 395 | # endif |
f4c79b3c | 396 | #endif |
8912421c | 397 | |
f4c79b3c LC |
398 | #if @GNULIB_GETSOCKNAME@ |
399 | # if @HAVE_WINSOCK2_H@ | |
400 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 401 | # undef getsockname |
f4c79b3c | 402 | # define getsockname rpl_getsockname |
8912421c | 403 | # endif |
f4c79b3c LC |
404 | _GL_FUNCDECL_RPL (getsockname, int, |
405 | (int fd, struct sockaddr *addr, socklen_t *addrlen) | |
406 | _GL_ARG_NONNULL ((2, 3))); | |
407 | _GL_CXXALIAS_RPL (getsockname, int, | |
408 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
409 | # else | |
410 | /* Need to cast, because on Solaris 10 systems, the third parameter is | |
411 | void *addrlen. */ | |
412 | _GL_CXXALIAS_SYS_CAST (getsockname, int, | |
413 | (int fd, struct sockaddr *addr, socklen_t *addrlen)); | |
414 | # endif | |
415 | _GL_CXXALIASWARN (getsockname); | |
416 | #elif @HAVE_WINSOCK2_H@ | |
417 | # undef getsockname | |
418 | # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname | |
419 | #elif defined GNULIB_POSIXCHECK | |
420 | # undef getsockname | |
421 | # if HAVE_RAW_DECL_GETSOCKNAME | |
61cd9dc9 LC |
422 | _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - " |
423 | "use gnulib module getsockname for portability"); | |
8912421c | 424 | # endif |
f4c79b3c | 425 | #endif |
8912421c | 426 | |
f4c79b3c LC |
427 | #if @GNULIB_GETSOCKOPT@ |
428 | # if @HAVE_WINSOCK2_H@ | |
429 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 430 | # undef getsockopt |
f4c79b3c | 431 | # define getsockopt rpl_getsockopt |
8912421c | 432 | # endif |
f4c79b3c LC |
433 | _GL_FUNCDECL_RPL (getsockopt, int, (int fd, int level, int optname, |
434 | void *optval, socklen_t *optlen) | |
435 | _GL_ARG_NONNULL ((4, 5))); | |
436 | _GL_CXXALIAS_RPL (getsockopt, int, (int fd, int level, int optname, | |
437 | void *optval, socklen_t *optlen)); | |
438 | # else | |
439 | /* Need to cast, because on Solaris 10 systems, the fifth parameter is | |
440 | void *optlen. */ | |
441 | _GL_CXXALIAS_SYS_CAST (getsockopt, int, (int fd, int level, int optname, | |
442 | void *optval, socklen_t *optlen)); | |
443 | # endif | |
444 | _GL_CXXALIASWARN (getsockopt); | |
445 | #elif @HAVE_WINSOCK2_H@ | |
446 | # undef getsockopt | |
447 | # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt | |
448 | #elif defined GNULIB_POSIXCHECK | |
449 | # undef getsockopt | |
450 | # if HAVE_RAW_DECL_GETSOCKOPT | |
61cd9dc9 LC |
451 | _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - " |
452 | "use gnulib module getsockopt for portability"); | |
8912421c | 453 | # endif |
f4c79b3c | 454 | #endif |
8912421c | 455 | |
f4c79b3c LC |
456 | #if @GNULIB_LISTEN@ |
457 | # if @HAVE_WINSOCK2_H@ | |
458 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 459 | # undef listen |
f4c79b3c | 460 | # define listen rpl_listen |
8912421c | 461 | # endif |
f4c79b3c LC |
462 | _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog)); |
463 | _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog)); | |
464 | # else | |
465 | _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog)); | |
466 | # endif | |
467 | _GL_CXXALIASWARN (listen); | |
468 | #elif @HAVE_WINSOCK2_H@ | |
469 | # undef listen | |
470 | # define listen listen_used_without_requesting_gnulib_module_listen | |
471 | #elif defined GNULIB_POSIXCHECK | |
472 | # undef listen | |
473 | # if HAVE_RAW_DECL_LISTEN | |
61cd9dc9 LC |
474 | _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - " |
475 | "use gnulib module listen for portability"); | |
8912421c | 476 | # endif |
f4c79b3c | 477 | #endif |
8912421c | 478 | |
f4c79b3c LC |
479 | #if @GNULIB_RECV@ |
480 | # if @HAVE_WINSOCK2_H@ | |
481 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 482 | # undef recv |
f4c79b3c | 483 | # define recv rpl_recv |
8912421c | 484 | # endif |
f4c79b3c LC |
485 | _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags) |
486 | _GL_ARG_NONNULL ((2))); | |
487 | _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); | |
488 | # else | |
489 | _GL_CXXALIAS_SYS (recv, ssize_t, (int fd, void *buf, size_t len, int flags)); | |
490 | # endif | |
491 | _GL_CXXALIASWARN (recv); | |
492 | #elif @HAVE_WINSOCK2_H@ | |
493 | # undef recv | |
494 | # define recv recv_used_without_requesting_gnulib_module_recv | |
495 | #elif defined GNULIB_POSIXCHECK | |
496 | # undef recv | |
497 | # if HAVE_RAW_DECL_RECV | |
61cd9dc9 LC |
498 | _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - " |
499 | "use gnulib module recv for portability"); | |
8912421c | 500 | # endif |
f4c79b3c | 501 | #endif |
8912421c | 502 | |
f4c79b3c LC |
503 | #if @GNULIB_SEND@ |
504 | # if @HAVE_WINSOCK2_H@ | |
505 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 506 | # undef send |
f4c79b3c | 507 | # define send rpl_send |
8912421c | 508 | # endif |
f4c79b3c LC |
509 | _GL_FUNCDECL_RPL (send, ssize_t, |
510 | (int fd, const void *buf, size_t len, int flags) | |
511 | _GL_ARG_NONNULL ((2))); | |
512 | _GL_CXXALIAS_RPL (send, ssize_t, | |
513 | (int fd, const void *buf, size_t len, int flags)); | |
514 | # else | |
515 | _GL_CXXALIAS_SYS (send, ssize_t, | |
516 | (int fd, const void *buf, size_t len, int flags)); | |
517 | # endif | |
518 | _GL_CXXALIASWARN (send); | |
519 | #elif @HAVE_WINSOCK2_H@ | |
520 | # undef send | |
521 | # define send send_used_without_requesting_gnulib_module_send | |
522 | #elif defined GNULIB_POSIXCHECK | |
523 | # undef send | |
524 | # if HAVE_RAW_DECL_SEND | |
61cd9dc9 LC |
525 | _GL_WARN_ON_USE (send, "send is not always POSIX compliant - " |
526 | "use gnulib module send for portability"); | |
8912421c | 527 | # endif |
f4c79b3c | 528 | #endif |
8912421c | 529 | |
f4c79b3c LC |
530 | #if @GNULIB_RECVFROM@ |
531 | # if @HAVE_WINSOCK2_H@ | |
532 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 533 | # undef recvfrom |
f4c79b3c | 534 | # define recvfrom rpl_recvfrom |
8912421c | 535 | # endif |
f4c79b3c LC |
536 | _GL_FUNCDECL_RPL (recvfrom, ssize_t, |
537 | (int fd, void *buf, size_t len, int flags, | |
538 | struct sockaddr *from, socklen_t *fromlen) | |
539 | _GL_ARG_NONNULL ((2))); | |
540 | _GL_CXXALIAS_RPL (recvfrom, ssize_t, | |
541 | (int fd, void *buf, size_t len, int flags, | |
542 | struct sockaddr *from, socklen_t *fromlen)); | |
543 | # else | |
544 | /* Need to cast, because on Solaris 10 systems, the sixth parameter is | |
545 | void *fromlen. */ | |
546 | _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t, | |
547 | (int fd, void *buf, size_t len, int flags, | |
548 | struct sockaddr *from, socklen_t *fromlen)); | |
549 | # endif | |
550 | _GL_CXXALIASWARN (recvfrom); | |
551 | #elif @HAVE_WINSOCK2_H@ | |
552 | # undef recvfrom | |
553 | # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom | |
554 | #elif defined GNULIB_POSIXCHECK | |
555 | # undef recvfrom | |
556 | # if HAVE_RAW_DECL_RECVFROM | |
61cd9dc9 LC |
557 | _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - " |
558 | "use gnulib module recvfrom for portability"); | |
8912421c | 559 | # endif |
f4c79b3c | 560 | #endif |
8912421c | 561 | |
f4c79b3c LC |
562 | #if @GNULIB_SENDTO@ |
563 | # if @HAVE_WINSOCK2_H@ | |
564 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 565 | # undef sendto |
f4c79b3c | 566 | # define sendto rpl_sendto |
8912421c | 567 | # endif |
f4c79b3c LC |
568 | _GL_FUNCDECL_RPL (sendto, ssize_t, |
569 | (int fd, const void *buf, size_t len, int flags, | |
570 | const struct sockaddr *to, socklen_t tolen) | |
571 | _GL_ARG_NONNULL ((2))); | |
572 | _GL_CXXALIAS_RPL (sendto, ssize_t, | |
573 | (int fd, const void *buf, size_t len, int flags, | |
574 | const struct sockaddr *to, socklen_t tolen)); | |
575 | # else | |
49114fd4 LC |
576 | /* Need to cast, because on NonStop Kernel, the sixth parameter is |
577 | size_t tolen. */ | |
578 | _GL_CXXALIAS_SYS_CAST (sendto, ssize_t, | |
579 | (int fd, const void *buf, size_t len, int flags, | |
580 | const struct sockaddr *to, socklen_t tolen)); | |
f4c79b3c LC |
581 | # endif |
582 | _GL_CXXALIASWARN (sendto); | |
583 | #elif @HAVE_WINSOCK2_H@ | |
584 | # undef sendto | |
585 | # define sendto sendto_used_without_requesting_gnulib_module_sendto | |
586 | #elif defined GNULIB_POSIXCHECK | |
587 | # undef sendto | |
588 | # if HAVE_RAW_DECL_SENDTO | |
61cd9dc9 LC |
589 | _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - " |
590 | "use gnulib module sendto for portability"); | |
8912421c | 591 | # endif |
f4c79b3c | 592 | #endif |
8912421c | 593 | |
f4c79b3c LC |
594 | #if @GNULIB_SETSOCKOPT@ |
595 | # if @HAVE_WINSOCK2_H@ | |
596 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 597 | # undef setsockopt |
f4c79b3c | 598 | # define setsockopt rpl_setsockopt |
8912421c | 599 | # endif |
f4c79b3c LC |
600 | _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname, |
601 | const void * optval, socklen_t optlen) | |
602 | _GL_ARG_NONNULL ((4))); | |
603 | _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname, | |
604 | const void * optval, socklen_t optlen)); | |
605 | # else | |
49114fd4 LC |
606 | /* Need to cast, because on NonStop Kernel, the fifth parameter is |
607 | size_t optlen. */ | |
608 | _GL_CXXALIAS_SYS_CAST (setsockopt, int, | |
609 | (int fd, int level, int optname, | |
610 | const void * optval, socklen_t optlen)); | |
f4c79b3c LC |
611 | # endif |
612 | _GL_CXXALIASWARN (setsockopt); | |
613 | #elif @HAVE_WINSOCK2_H@ | |
614 | # undef setsockopt | |
615 | # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt | |
616 | #elif defined GNULIB_POSIXCHECK | |
617 | # undef setsockopt | |
618 | # if HAVE_RAW_DECL_SETSOCKOPT | |
61cd9dc9 LC |
619 | _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - " |
620 | "use gnulib module setsockopt for portability"); | |
8912421c | 621 | # endif |
f4c79b3c | 622 | #endif |
8912421c | 623 | |
f4c79b3c LC |
624 | #if @GNULIB_SHUTDOWN@ |
625 | # if @HAVE_WINSOCK2_H@ | |
626 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
8912421c | 627 | # undef shutdown |
f4c79b3c | 628 | # define shutdown rpl_shutdown |
8912421c | 629 | # endif |
f4c79b3c LC |
630 | _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how)); |
631 | _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how)); | |
632 | # else | |
633 | _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how)); | |
634 | # endif | |
635 | _GL_CXXALIASWARN (shutdown); | |
636 | #elif @HAVE_WINSOCK2_H@ | |
637 | # undef shutdown | |
638 | # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown | |
639 | #elif defined GNULIB_POSIXCHECK | |
640 | # undef shutdown | |
641 | # if HAVE_RAW_DECL_SHUTDOWN | |
61cd9dc9 LC |
642 | _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - " |
643 | "use gnulib module shutdown for portability"); | |
8912421c | 644 | # endif |
f4c79b3c | 645 | #endif |
8912421c | 646 | |
8912421c LC |
647 | #if @GNULIB_ACCEPT4@ |
648 | /* Accept a connection on a socket, with specific opening flags. | |
649 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
650 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
651 | See also the Linux man page at | |
652 | <http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */ | |
653 | # if @HAVE_ACCEPT4@ | |
f4c79b3c LC |
654 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
655 | # define accept4 rpl_accept4 | |
656 | # endif | |
657 | _GL_FUNCDECL_RPL (accept4, int, | |
658 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | |
659 | int flags)); | |
660 | _GL_CXXALIAS_RPL (accept4, int, | |
661 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | |
662 | int flags)); | |
663 | # else | |
664 | _GL_FUNCDECL_SYS (accept4, int, | |
665 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | |
666 | int flags)); | |
667 | _GL_CXXALIAS_SYS (accept4, int, | |
668 | (int sockfd, struct sockaddr *addr, socklen_t *addrlen, | |
669 | int flags)); | |
670 | # endif | |
671 | _GL_CXXALIASWARN (accept4); | |
8912421c LC |
672 | #elif defined GNULIB_POSIXCHECK |
673 | # undef accept4 | |
61cd9dc9 LC |
674 | # if HAVE_RAW_DECL_ACCEPT4 |
675 | _GL_WARN_ON_USE (accept4, "accept4 is unportable - " | |
676 | "use gnulib module accept4 for portability"); | |
677 | # endif | |
8912421c LC |
678 | #endif |
679 | ||
3d458a81 AW |
680 | #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ |
681 | #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */ | |
f4c79b3c | 682 | #endif |