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