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