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