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-2018 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)
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 <https://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
26 @PRAGMA_SYSTEM_HEADER@
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@
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
50 # include <sys/types.h>
52 /* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL
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
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."
69 _GL_INLINE_HEADER_BEGIN
70 #ifndef _GL_SYS_SOCKET_INLINE
71 # define _GL_SYS_SOCKET_INLINE _GL_INLINE
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
;
86 typedef unsigned char sa_family_t
;
88 # define GNULIB_defined_sa_family_t 1
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@
96 # define ss_family __ss_family
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
123 /* Get struct iovec. */
124 /* But avoid namespace pollution on glibc systems. */
125 #if ! defined __GLIBC__
126 # include <sys/uio.h>
129 #if @HAVE_SYS_SOCKET_H@
131 /* A platform that has <sys/socket.h>. */
133 /* For shutdown(). */
134 # if !defined SHUT_RD
137 # if !defined SHUT_WR
140 # if !defined SHUT_RDWR
144 # ifdef __VMS /* OpenVMS */
146 # define CMSG_SPACE(length) _CMSG_SPACE(length)
149 # define CMSG_LEN(length) _CMSG_LEN(length)
156 # error "Cygwin does have a sys/socket.h, doesn't it?!?"
159 /* A platform that lacks <sys/socket.h>.
161 Currently only MinGW is supported. See the gnulib manual regarding
162 Windows sockets. MinGW has the header files winsock2.h and
163 ws2tcpip.h that declare the sys/socket.h definitions we need. Note
164 that you can influence which definitions you get by setting the
165 WINVER symbol before including these two files. For example,
166 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
167 symbol is set indirectly through WINVER). You can set this by
168 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
169 code may not run on older Windows releases then. My Windows 2000
170 box was not able to run the code, for example. The situation is
171 slightly confusing because
172 <https://msdn.microsoft.com/en-us/library/ms738520>
173 suggests that getaddrinfo should be available on all Windows
176 # if @HAVE_WINSOCK2_H@
177 # include <winsock2.h>
179 # if @HAVE_WS2TCPIP_H@
180 # include <ws2tcpip.h>
183 /* For shutdown(). */
184 # if !defined SHUT_RD && defined SD_RECEIVE
185 # define SHUT_RD SD_RECEIVE
187 # if !defined SHUT_WR && defined SD_SEND
188 # define SHUT_WR SD_SEND
190 # if !defined SHUT_RDWR && defined SD_BOTH
191 # define SHUT_RDWR SD_BOTH
194 # if @HAVE_WINSOCK2_H@
195 /* Include headers needed by the emulation code. */
196 # include <sys/types.h>
199 # if !GNULIB_defined_socklen_t
200 typedef int socklen_t
;
201 # define GNULIB_defined_socklen_t 1
206 /* Rudimentary 'struct msghdr'; this works as long as you don't try to
207 access msg_control or msg_controllen. */
210 socklen_t msg_namelen
;
211 struct iovec
*msg_iov
;
218 /* Ensure SO_REUSEPORT is defined. */
219 /* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
220 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
221 and https://lwn.net/Articles/542629/
224 # define SO_REUSEPORT SO_REUSEADDR
227 /* Fix some definitions from <winsock2.h>. */
229 #if @HAVE_WINSOCK2_H@
231 # if !GNULIB_defined_rpl_fd_isset
233 /* Re-define FD_ISSET to avoid a WSA call while we are not using
235 _GL_SYS_SOCKET_INLINE
int
236 rpl_fd_isset (SOCKET fd
, fd_set
* set
)
242 for (i
= 0; i
< set
->fd_count
; i
++)
243 if (set
->fd_array
[i
] == fd
)
249 # define GNULIB_defined_rpl_fd_isset 1
253 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
257 /* Hide some function declarations from <winsock2.h>. */
259 #if @HAVE_WINSOCK2_H@
260 # if !defined _@GUARD_PREFIX@_UNISTD_H
261 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
263 # define close close_used_without_including_unistd_h
265 _GL_WARN_ON_USE (close
,
266 "close() used without including <unistd.h>");
268 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
270 # define gethostname gethostname_used_without_including_unistd_h
272 _GL_WARN_ON_USE (gethostname
,
273 "gethostname() used without including <unistd.h>");
276 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
277 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
279 # define select select_used_without_including_sys_select_h
281 _GL_WARN_ON_USE (select
,
282 "select() used without including <sys/select.h>");
287 /* Wrap everything else to use libc file descriptors for sockets. */
290 # if @HAVE_WINSOCK2_H@
291 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
293 # define socket rpl_socket
295 _GL_FUNCDECL_RPL (socket
, int, (int domain
, int type
, int protocol
));
296 _GL_CXXALIAS_RPL (socket
, int, (int domain
, int type
, int protocol
));
298 _GL_CXXALIAS_SYS (socket
, int, (int domain
, int type
, int protocol
));
300 _GL_CXXALIASWARN (socket
);
301 #elif @HAVE_WINSOCK2_H@
303 # define socket socket_used_without_requesting_gnulib_module_socket
304 #elif defined GNULIB_POSIXCHECK
306 # if HAVE_RAW_DECL_SOCKET
307 _GL_WARN_ON_USE (socket
, "socket is not always POSIX compliant - "
308 "use gnulib module socket for portability");
313 # if @HAVE_WINSOCK2_H@
314 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316 # define connect rpl_connect
318 _GL_FUNCDECL_RPL (connect
, int,
319 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
)
320 _GL_ARG_NONNULL ((2)));
321 _GL_CXXALIAS_RPL (connect
, int,
322 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
));
324 /* Need to cast, because on NonStop Kernel, the third parameter is
326 _GL_CXXALIAS_SYS_CAST (connect
, int,
328 const struct sockaddr
*addr
, socklen_t addrlen
));
330 _GL_CXXALIASWARN (connect
);
331 #elif @HAVE_WINSOCK2_H@
333 # define connect socket_used_without_requesting_gnulib_module_connect
334 #elif defined GNULIB_POSIXCHECK
336 # if HAVE_RAW_DECL_CONNECT
337 _GL_WARN_ON_USE (connect
, "connect is not always POSIX compliant - "
338 "use gnulib module connect for portability");
343 # if @HAVE_WINSOCK2_H@
344 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
346 # define accept rpl_accept
348 _GL_FUNCDECL_RPL (accept
, int,
349 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
350 _GL_CXXALIAS_RPL (accept
, int,
351 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
353 /* Need to cast, because on Solaris 10 systems, the third parameter is
355 _GL_CXXALIAS_SYS_CAST (accept
, int,
356 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
358 _GL_CXXALIASWARN (accept
);
359 #elif @HAVE_WINSOCK2_H@
361 # define accept accept_used_without_requesting_gnulib_module_accept
362 #elif defined GNULIB_POSIXCHECK
364 # if HAVE_RAW_DECL_ACCEPT
365 _GL_WARN_ON_USE (accept
, "accept is not always POSIX compliant - "
366 "use gnulib module accept for portability");
371 # if @HAVE_WINSOCK2_H@
372 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
374 # define bind rpl_bind
376 _GL_FUNCDECL_RPL (bind
, int,
377 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
)
378 _GL_ARG_NONNULL ((2)));
379 _GL_CXXALIAS_RPL (bind
, int,
380 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
));
382 /* Need to cast, because on NonStop Kernel, the third parameter is
384 _GL_CXXALIAS_SYS_CAST (bind
, int,
386 const struct sockaddr
*addr
, socklen_t addrlen
));
388 _GL_CXXALIASWARN (bind
);
389 #elif @HAVE_WINSOCK2_H@
391 # define bind bind_used_without_requesting_gnulib_module_bind
392 #elif defined GNULIB_POSIXCHECK
394 # if HAVE_RAW_DECL_BIND
395 _GL_WARN_ON_USE (bind
, "bind is not always POSIX compliant - "
396 "use gnulib module bind for portability");
400 #if @GNULIB_GETPEERNAME@
401 # if @HAVE_WINSOCK2_H@
402 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
404 # define getpeername rpl_getpeername
406 _GL_FUNCDECL_RPL (getpeername
, int,
407 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
)
408 _GL_ARG_NONNULL ((2, 3)));
409 _GL_CXXALIAS_RPL (getpeername
, int,
410 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
412 /* Need to cast, because on Solaris 10 systems, the third parameter is
414 _GL_CXXALIAS_SYS_CAST (getpeername
, int,
415 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
417 _GL_CXXALIASWARN (getpeername
);
418 #elif @HAVE_WINSOCK2_H@
420 # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
421 #elif defined GNULIB_POSIXCHECK
423 # if HAVE_RAW_DECL_GETPEERNAME
424 _GL_WARN_ON_USE (getpeername
, "getpeername is not always POSIX compliant - "
425 "use gnulib module getpeername for portability");
429 #if @GNULIB_GETSOCKNAME@
430 # if @HAVE_WINSOCK2_H@
431 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
433 # define getsockname rpl_getsockname
435 _GL_FUNCDECL_RPL (getsockname
, int,
436 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
)
437 _GL_ARG_NONNULL ((2, 3)));
438 _GL_CXXALIAS_RPL (getsockname
, int,
439 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
441 /* Need to cast, because on Solaris 10 systems, the third parameter is
443 _GL_CXXALIAS_SYS_CAST (getsockname
, int,
444 (int fd
, struct sockaddr
*addr
, socklen_t
*addrlen
));
446 _GL_CXXALIASWARN (getsockname
);
447 #elif @HAVE_WINSOCK2_H@
449 # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
450 #elif defined GNULIB_POSIXCHECK
452 # if HAVE_RAW_DECL_GETSOCKNAME
453 _GL_WARN_ON_USE (getsockname
, "getsockname is not always POSIX compliant - "
454 "use gnulib module getsockname for portability");
458 #if @GNULIB_GETSOCKOPT@
459 # if @HAVE_WINSOCK2_H@
460 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
462 # define getsockopt rpl_getsockopt
464 _GL_FUNCDECL_RPL (getsockopt
, int, (int fd
, int level
, int optname
,
465 void *optval
, socklen_t
*optlen
)
466 _GL_ARG_NONNULL ((4, 5)));
467 _GL_CXXALIAS_RPL (getsockopt
, int, (int fd
, int level
, int optname
,
468 void *optval
, socklen_t
*optlen
));
470 /* Need to cast, because on Solaris 10 systems, the fifth parameter is
472 _GL_CXXALIAS_SYS_CAST (getsockopt
, int, (int fd
, int level
, int optname
,
473 void *optval
, socklen_t
*optlen
));
475 _GL_CXXALIASWARN (getsockopt
);
476 #elif @HAVE_WINSOCK2_H@
478 # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
479 #elif defined GNULIB_POSIXCHECK
481 # if HAVE_RAW_DECL_GETSOCKOPT
482 _GL_WARN_ON_USE (getsockopt
, "getsockopt is not always POSIX compliant - "
483 "use gnulib module getsockopt for portability");
488 # if @HAVE_WINSOCK2_H@
489 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
491 # define listen rpl_listen
493 _GL_FUNCDECL_RPL (listen
, int, (int fd
, int backlog
));
494 _GL_CXXALIAS_RPL (listen
, int, (int fd
, int backlog
));
496 _GL_CXXALIAS_SYS (listen
, int, (int fd
, int backlog
));
498 _GL_CXXALIASWARN (listen
);
499 #elif @HAVE_WINSOCK2_H@
501 # define listen listen_used_without_requesting_gnulib_module_listen
502 #elif defined GNULIB_POSIXCHECK
504 # if HAVE_RAW_DECL_LISTEN
505 _GL_WARN_ON_USE (listen
, "listen is not always POSIX compliant - "
506 "use gnulib module listen for portability");
511 # if @HAVE_WINSOCK2_H@
512 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
514 # define recv rpl_recv
516 _GL_FUNCDECL_RPL (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
)
517 _GL_ARG_NONNULL ((2)));
518 _GL_CXXALIAS_RPL (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
));
520 _GL_CXXALIAS_SYS (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
));
522 _GL_CXXALIASWARN (recv
);
523 #elif @HAVE_WINSOCK2_H@
525 # define recv recv_used_without_requesting_gnulib_module_recv
526 #elif defined GNULIB_POSIXCHECK
528 # if HAVE_RAW_DECL_RECV
529 _GL_WARN_ON_USE (recv
, "recv is not always POSIX compliant - "
530 "use gnulib module recv for portability");
535 # if @HAVE_WINSOCK2_H@
536 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
538 # define send rpl_send
540 _GL_FUNCDECL_RPL (send
, ssize_t
,
541 (int fd
, const void *buf
, size_t len
, int flags
)
542 _GL_ARG_NONNULL ((2)));
543 _GL_CXXALIAS_RPL (send
, ssize_t
,
544 (int fd
, const void *buf
, size_t len
, int flags
));
546 _GL_CXXALIAS_SYS (send
, ssize_t
,
547 (int fd
, const void *buf
, size_t len
, int flags
));
549 _GL_CXXALIASWARN (send
);
550 #elif @HAVE_WINSOCK2_H@
552 # define send send_used_without_requesting_gnulib_module_send
553 #elif defined GNULIB_POSIXCHECK
555 # if HAVE_RAW_DECL_SEND
556 _GL_WARN_ON_USE (send
, "send is not always POSIX compliant - "
557 "use gnulib module send for portability");
561 #if @GNULIB_RECVFROM@
562 # if @HAVE_WINSOCK2_H@
563 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
565 # define recvfrom rpl_recvfrom
567 _GL_FUNCDECL_RPL (recvfrom
, ssize_t
,
568 (int fd
, void *buf
, size_t len
, int flags
,
569 struct sockaddr
*from
, socklen_t
*fromlen
)
570 _GL_ARG_NONNULL ((2)));
571 _GL_CXXALIAS_RPL (recvfrom
, ssize_t
,
572 (int fd
, void *buf
, size_t len
, int flags
,
573 struct sockaddr
*from
, socklen_t
*fromlen
));
575 /* Need to cast, because on Solaris 10 systems, the sixth parameter is
577 _GL_CXXALIAS_SYS_CAST (recvfrom
, ssize_t
,
578 (int fd
, void *buf
, size_t len
, int flags
,
579 struct sockaddr
*from
, socklen_t
*fromlen
));
581 _GL_CXXALIASWARN (recvfrom
);
582 #elif @HAVE_WINSOCK2_H@
584 # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
585 #elif defined GNULIB_POSIXCHECK
587 # if HAVE_RAW_DECL_RECVFROM
588 _GL_WARN_ON_USE (recvfrom
, "recvfrom is not always POSIX compliant - "
589 "use gnulib module recvfrom for portability");
594 # if @HAVE_WINSOCK2_H@
595 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
597 # define sendto rpl_sendto
599 _GL_FUNCDECL_RPL (sendto
, ssize_t
,
600 (int fd
, const void *buf
, size_t len
, int flags
,
601 const struct sockaddr
*to
, socklen_t tolen
)
602 _GL_ARG_NONNULL ((2)));
603 _GL_CXXALIAS_RPL (sendto
, ssize_t
,
604 (int fd
, const void *buf
, size_t len
, int flags
,
605 const struct sockaddr
*to
, socklen_t tolen
));
607 /* Need to cast, because on NonStop Kernel, the sixth parameter is
609 _GL_CXXALIAS_SYS_CAST (sendto
, ssize_t
,
610 (int fd
, const void *buf
, size_t len
, int flags
,
611 const struct sockaddr
*to
, socklen_t tolen
));
613 _GL_CXXALIASWARN (sendto
);
614 #elif @HAVE_WINSOCK2_H@
616 # define sendto sendto_used_without_requesting_gnulib_module_sendto
617 #elif defined GNULIB_POSIXCHECK
619 # if HAVE_RAW_DECL_SENDTO
620 _GL_WARN_ON_USE (sendto
, "sendto is not always POSIX compliant - "
621 "use gnulib module sendto for portability");
625 #if @GNULIB_SETSOCKOPT@
626 # if @HAVE_WINSOCK2_H@
627 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
629 # define setsockopt rpl_setsockopt
631 _GL_FUNCDECL_RPL (setsockopt
, int, (int fd
, int level
, int optname
,
632 const void * optval
, socklen_t optlen
)
633 _GL_ARG_NONNULL ((4)));
634 _GL_CXXALIAS_RPL (setsockopt
, int, (int fd
, int level
, int optname
,
635 const void * optval
, socklen_t optlen
));
637 /* Need to cast, because on NonStop Kernel, the fifth parameter is
639 _GL_CXXALIAS_SYS_CAST (setsockopt
, int,
640 (int fd
, int level
, int optname
,
641 const void * optval
, socklen_t optlen
));
643 _GL_CXXALIASWARN (setsockopt
);
644 #elif @HAVE_WINSOCK2_H@
646 # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
647 #elif defined GNULIB_POSIXCHECK
649 # if HAVE_RAW_DECL_SETSOCKOPT
650 _GL_WARN_ON_USE (setsockopt
, "setsockopt is not always POSIX compliant - "
651 "use gnulib module setsockopt for portability");
655 #if @GNULIB_SHUTDOWN@
656 # if @HAVE_WINSOCK2_H@
657 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
659 # define shutdown rpl_shutdown
661 _GL_FUNCDECL_RPL (shutdown
, int, (int fd
, int how
));
662 _GL_CXXALIAS_RPL (shutdown
, int, (int fd
, int how
));
664 _GL_CXXALIAS_SYS (shutdown
, int, (int fd
, int how
));
666 _GL_CXXALIASWARN (shutdown
);
667 #elif @HAVE_WINSOCK2_H@
669 # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
670 #elif defined GNULIB_POSIXCHECK
672 # if HAVE_RAW_DECL_SHUTDOWN
673 _GL_WARN_ON_USE (shutdown
, "shutdown is not always POSIX compliant - "
674 "use gnulib module shutdown for portability");
679 /* Accept a connection on a socket, with specific opening flags.
680 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
681 and O_TEXT, O_BINARY (defined in "binary-io.h").
682 See also the Linux man page at
683 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
685 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
686 # define accept4 rpl_accept4
688 _GL_FUNCDECL_RPL (accept4
, int,
689 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
691 _GL_CXXALIAS_RPL (accept4
, int,
692 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
695 _GL_FUNCDECL_SYS (accept4
, int,
696 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
698 _GL_CXXALIAS_SYS (accept4
, int,
699 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
702 _GL_CXXALIASWARN (accept4
);
703 #elif defined GNULIB_POSIXCHECK
705 # if HAVE_RAW_DECL_ACCEPT4
706 _GL_WARN_ON_USE (accept4
, "accept4 is unportable - "
707 "use gnulib module accept4 for portability");
711 _GL_INLINE_HEADER_END
713 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
714 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */