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