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