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-2024 Free Software Foundation, Inc.
4 Written by Simon Josefsson.
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 This file 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.
16 You should have received a copy of the GNU Lesser 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 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK,
67 HAVE_RAW_DECL_*, alignof. */
68 #if !_GL_CONFIG_H_INCLUDED
69 #error "Please include config.h first."
72 _GL_INLINE_HEADER_BEGIN
73 #ifndef _GL_SYS_SOCKET_INLINE
74 # define _GL_SYS_SOCKET_INLINE _GL_INLINE
77 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
79 /* The definition of _GL_ARG_NONNULL is copied here. */
81 /* The definition of _GL_WARN_ON_USE is copied here. */
83 #if !@HAVE_SA_FAMILY_T@
84 # if !GNULIB_defined_sa_family_t
85 /* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
86 # if !defined __KLIBC__ || defined TCPV40HDRS
87 typedef unsigned short sa_family_t
;
89 typedef unsigned char sa_family_t
;
91 # define GNULIB_defined_sa_family_t 1
95 #if @HAVE_STRUCT_SOCKADDR_STORAGE@
96 /* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */
97 # if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@
99 # define ss_family __ss_family
103 /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
104 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
105 # define __ss_aligntype unsigned long int
106 # define _SS_SIZE 256
107 # define _SS_PADSIZE \
108 (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
109 ? sizeof (sa_family_t) \
110 : alignof (__ss_aligntype)) \
111 + sizeof (__ss_aligntype)))
113 # if !GNULIB_defined_struct_sockaddr_storage
114 struct sockaddr_storage
116 sa_family_t ss_family
; /* Address family, etc. */
117 __ss_aligntype __ss_align
; /* Force desired alignment. */
118 char __ss_padding
[_SS_PADSIZE
];
120 # define GNULIB_defined_struct_sockaddr_storage 1
125 /* Get struct iovec. */
126 /* But avoid namespace pollution on glibc systems. */
127 #if ! defined __GLIBC__
128 # include <sys/uio.h>
131 #if @HAVE_SYS_SOCKET_H@
133 /* A platform that has <sys/socket.h>. */
135 /* For shutdown(). */
136 # if !defined SHUT_RD
139 # if !defined SHUT_WR
142 # if !defined SHUT_RDWR
146 # ifdef __VMS /* OpenVMS */
148 # define CMSG_SPACE(length) _CMSG_SPACE(length)
151 # define CMSG_LEN(length) _CMSG_LEN(length)
158 # error "Cygwin does have a sys/socket.h, doesn't it?!?"
161 /* A platform that lacks <sys/socket.h>.
163 Currently only MinGW is supported. See the gnulib manual regarding
164 Windows sockets. MinGW has the header files winsock2.h and
165 ws2tcpip.h that declare the sys/socket.h definitions we need. Note
166 that you can influence which definitions you get by setting the
167 WINVER symbol before including these two files. For example,
168 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
169 symbol is set indirectly through WINVER). You can set this by
170 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
171 code may not run on older Windows releases then. My Windows 2000
172 box was not able to run the code, for example. The situation is
173 slightly confusing because
174 <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
175 suggests that getaddrinfo should be available on all Windows
178 # if @HAVE_WINSOCK2_H@
179 # include <winsock2.h>
181 # if @HAVE_WS2TCPIP_H@
182 # include <ws2tcpip.h>
185 /* For shutdown(). */
186 # if !defined SHUT_RD && defined SD_RECEIVE
187 # define SHUT_RD SD_RECEIVE
189 # if !defined SHUT_WR && defined SD_SEND
190 # define SHUT_WR SD_SEND
192 # if !defined SHUT_RDWR && defined SD_BOTH
193 # define SHUT_RDWR SD_BOTH
196 # if @HAVE_WINSOCK2_H@
197 /* Include headers needed by the emulation code. */
198 # include <sys/types.h>
200 /* If these headers don't define socklen_t, <config.h> does. */
203 /* Rudimentary 'struct msghdr'; this works as long as you don't try to
204 access msg_control or msg_controllen. */
207 socklen_t msg_namelen
;
208 struct iovec
*msg_iov
;
215 /* Ensure SO_REUSEPORT is defined. */
216 /* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
217 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
218 and https://lwn.net/Articles/542629/
221 # define SO_REUSEPORT SO_REUSEADDR
224 /* Fix some definitions from <winsock2.h>. */
226 #if @HAVE_WINSOCK2_H@
228 # if !GNULIB_defined_rpl_fd_isset
230 /* Re-define FD_ISSET to avoid a WSA call while we are not using
232 _GL_SYS_SOCKET_INLINE
int
233 rpl_fd_isset (SOCKET fd
, fd_set
* set
)
239 for (i
= 0; i
< set
->fd_count
; i
++)
240 if (set
->fd_array
[i
] == fd
)
246 # define GNULIB_defined_rpl_fd_isset 1
250 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
254 /* Hide some function declarations from <winsock2.h>. */
256 #if @HAVE_WINSOCK2_H@
257 # if !defined _@GUARD_PREFIX@_UNISTD_H
258 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
260 # define close close_used_without_including_unistd_h
261 # elif !defined __clang__
262 _GL_WARN_ON_USE (close
,
263 "close() used without including <unistd.h>");
265 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
267 # define gethostname gethostname_used_without_including_unistd_h
269 _GL_WARN_ON_USE (gethostname
,
270 "gethostname() used without including <unistd.h>");
273 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
274 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
276 # define select select_used_without_including_sys_select_h
278 _GL_WARN_ON_USE (select
,
279 "select() used without including <sys/select.h>");
284 /* Wrap everything else to use libc file descriptors for sockets. */
287 # if @HAVE_WINSOCK2_H@
288 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
290 # define socket rpl_socket
292 _GL_FUNCDECL_RPL (socket
, int, (int domain
, int type
, int protocol
));
293 _GL_CXXALIAS_RPL (socket
, int, (int domain
, int type
, int protocol
));
295 _GL_CXXALIAS_SYS (socket
, int, (int domain
, int type
, int protocol
));
297 _GL_CXXALIASWARN (socket
);
298 #elif @HAVE_WINSOCK2_H@
300 # define socket socket_used_without_requesting_gnulib_module_socket
301 #elif defined GNULIB_POSIXCHECK
303 # if HAVE_RAW_DECL_SOCKET
304 _GL_WARN_ON_USE (socket
, "socket is not always POSIX compliant - "
305 "use gnulib module socket for portability");
310 # if @HAVE_WINSOCK2_H@
311 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
313 # define connect rpl_connect
315 _GL_FUNCDECL_RPL (connect
, int,
316 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
)
317 _GL_ARG_NONNULL ((2)));
318 _GL_CXXALIAS_RPL (connect
, int,
319 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
));
321 /* Need to cast, because on NonStop Kernel, the third parameter is
323 _GL_CXXALIAS_SYS_CAST (connect
, int,
325 const struct sockaddr
*addr
, socklen_t addrlen
));
327 _GL_CXXALIASWARN (connect
);
328 #elif @HAVE_WINSOCK2_H@
330 # define connect socket_used_without_requesting_gnulib_module_connect
331 #elif defined GNULIB_POSIXCHECK
333 # if HAVE_RAW_DECL_CONNECT
334 _GL_WARN_ON_USE (connect
, "connect is not always POSIX compliant - "
335 "use gnulib module connect for portability");
340 # if @HAVE_WINSOCK2_H@
341 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
343 # define accept rpl_accept
345 _GL_FUNCDECL_RPL (accept
, int,
347 struct sockaddr
*restrict addr
,
348 socklen_t
*restrict addrlen
));
349 _GL_CXXALIAS_RPL (accept
, int,
351 struct sockaddr
*restrict addr
,
352 socklen_t
*restrict addrlen
));
354 /* Need to cast, because on Solaris 10 systems, the third parameter is
356 _GL_CXXALIAS_SYS_CAST (accept
, int,
358 struct sockaddr
*restrict addr
,
359 socklen_t
*restrict addrlen
));
362 _GL_CXXALIASWARN (accept
);
364 #elif @HAVE_WINSOCK2_H@
366 # define accept accept_used_without_requesting_gnulib_module_accept
367 #elif defined GNULIB_POSIXCHECK
369 # if HAVE_RAW_DECL_ACCEPT
370 _GL_WARN_ON_USE (accept
, "accept is not always POSIX compliant - "
371 "use gnulib module accept for portability");
376 # if @HAVE_WINSOCK2_H@
377 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
379 # define bind rpl_bind
381 _GL_FUNCDECL_RPL (bind
, int,
382 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
)
383 _GL_ARG_NONNULL ((2)));
384 _GL_CXXALIAS_RPL (bind
, int,
385 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
));
387 /* Need to cast, because on NonStop Kernel, the third parameter is
389 _GL_CXXALIAS_SYS_CAST (bind
, int,
391 const struct sockaddr
*addr
, socklen_t addrlen
));
393 _GL_CXXALIASWARN (bind
);
394 #elif @HAVE_WINSOCK2_H@
396 # define bind bind_used_without_requesting_gnulib_module_bind
397 #elif defined GNULIB_POSIXCHECK
399 # if HAVE_RAW_DECL_BIND
400 _GL_WARN_ON_USE (bind
, "bind is not always POSIX compliant - "
401 "use gnulib module bind for portability");
405 #if @GNULIB_GETPEERNAME@
406 # if @HAVE_WINSOCK2_H@
407 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
409 # define getpeername rpl_getpeername
411 _GL_FUNCDECL_RPL (getpeername
, int,
412 (int fd
, struct sockaddr
*restrict addr
,
413 socklen_t
*restrict addrlen
)
414 _GL_ARG_NONNULL ((2, 3)));
415 _GL_CXXALIAS_RPL (getpeername
, int,
416 (int fd
, struct sockaddr
*restrict addr
,
417 socklen_t
*restrict addrlen
));
419 /* Need to cast, because on Solaris 10 systems, the third parameter is
421 _GL_CXXALIAS_SYS_CAST (getpeername
, int,
422 (int fd
, struct sockaddr
*restrict addr
,
423 socklen_t
*restrict addrlen
));
426 _GL_CXXALIASWARN (getpeername
);
428 #elif @HAVE_WINSOCK2_H@
430 # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
431 #elif defined GNULIB_POSIXCHECK
433 # if HAVE_RAW_DECL_GETPEERNAME
434 _GL_WARN_ON_USE (getpeername
, "getpeername is not always POSIX compliant - "
435 "use gnulib module getpeername for portability");
439 #if @GNULIB_GETSOCKNAME@
440 # if @HAVE_WINSOCK2_H@
441 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443 # define getsockname rpl_getsockname
445 _GL_FUNCDECL_RPL (getsockname
, int,
446 (int fd
, struct sockaddr
*restrict addr
,
447 socklen_t
*restrict addrlen
)
448 _GL_ARG_NONNULL ((2, 3)));
449 _GL_CXXALIAS_RPL (getsockname
, int,
450 (int fd
, struct sockaddr
*restrict addr
,
451 socklen_t
*restrict addrlen
));
453 /* Need to cast, because on Solaris 10 systems, the third parameter is
455 _GL_CXXALIAS_SYS_CAST (getsockname
, int,
456 (int fd
, struct sockaddr
*restrict addr
,
457 socklen_t
*restrict addrlen
));
460 _GL_CXXALIASWARN (getsockname
);
462 #elif @HAVE_WINSOCK2_H@
464 # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
465 #elif defined GNULIB_POSIXCHECK
467 # if HAVE_RAW_DECL_GETSOCKNAME
468 _GL_WARN_ON_USE (getsockname
, "getsockname is not always POSIX compliant - "
469 "use gnulib module getsockname for portability");
473 #if @GNULIB_GETSOCKOPT@
474 # if @HAVE_WINSOCK2_H@
475 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
477 # define getsockopt rpl_getsockopt
479 _GL_FUNCDECL_RPL (getsockopt
, int,
480 (int fd
, int level
, int optname
,
481 void *restrict optval
, socklen_t
*restrict optlen
)
482 _GL_ARG_NONNULL ((4, 5)));
483 _GL_CXXALIAS_RPL (getsockopt
, int,
484 (int fd
, int level
, int optname
,
485 void *restrict optval
, socklen_t
*restrict optlen
));
487 /* Need to cast, because on Solaris 10 systems, the fifth parameter is
489 _GL_CXXALIAS_SYS_CAST (getsockopt
, int,
490 (int fd
, int level
, int optname
,
491 void *restrict optval
, socklen_t
*restrict optlen
));
493 _GL_CXXALIASWARN (getsockopt
);
494 #elif @HAVE_WINSOCK2_H@
496 # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
497 #elif defined GNULIB_POSIXCHECK
499 # if HAVE_RAW_DECL_GETSOCKOPT
500 _GL_WARN_ON_USE (getsockopt
, "getsockopt is not always POSIX compliant - "
501 "use gnulib module getsockopt for portability");
506 # if @HAVE_WINSOCK2_H@
507 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
509 # define listen rpl_listen
511 _GL_FUNCDECL_RPL (listen
, int, (int fd
, int backlog
));
512 _GL_CXXALIAS_RPL (listen
, int, (int fd
, int backlog
));
514 _GL_CXXALIAS_SYS (listen
, int, (int fd
, int backlog
));
516 _GL_CXXALIASWARN (listen
);
517 #elif @HAVE_WINSOCK2_H@
519 # define listen listen_used_without_requesting_gnulib_module_listen
520 #elif defined GNULIB_POSIXCHECK
522 # if HAVE_RAW_DECL_LISTEN
523 _GL_WARN_ON_USE (listen
, "listen is not always POSIX compliant - "
524 "use gnulib module listen for portability");
529 # if @HAVE_WINSOCK2_H@
530 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
532 # define recv rpl_recv
534 _GL_FUNCDECL_RPL (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
)
535 _GL_ARG_NONNULL ((2)));
536 _GL_CXXALIAS_RPL (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
));
538 /* Need to cast, because on HP-UX 11.31 the return type may be
540 depending on compiler options. */
541 _GL_CXXALIAS_SYS_CAST (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
));
543 _GL_CXXALIASWARN (recv
);
544 #elif @HAVE_WINSOCK2_H@
546 # define recv recv_used_without_requesting_gnulib_module_recv
547 #elif defined GNULIB_POSIXCHECK
549 # if HAVE_RAW_DECL_RECV
550 _GL_WARN_ON_USE (recv
, "recv is not always POSIX compliant - "
551 "use gnulib module recv for portability");
556 # if @HAVE_WINSOCK2_H@
557 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
559 # define send rpl_send
561 _GL_FUNCDECL_RPL (send
, ssize_t
,
562 (int fd
, const void *buf
, size_t len
, int flags
)
563 _GL_ARG_NONNULL ((2)));
564 _GL_CXXALIAS_RPL (send
, ssize_t
,
565 (int fd
, const void *buf
, size_t len
, int flags
));
567 /* Need to cast, because on HP-UX 11.31 the return type may be
569 depending on compiler options. */
570 _GL_CXXALIAS_SYS_CAST (send
, ssize_t
,
571 (int fd
, const void *buf
, size_t len
, int flags
));
573 _GL_CXXALIASWARN (send
);
574 #elif @HAVE_WINSOCK2_H@
576 # define send send_used_without_requesting_gnulib_module_send
577 #elif defined GNULIB_POSIXCHECK
579 # if HAVE_RAW_DECL_SEND
580 _GL_WARN_ON_USE (send
, "send is not always POSIX compliant - "
581 "use gnulib module send for portability");
585 #if @GNULIB_RECVFROM@
586 # if @HAVE_WINSOCK2_H@
587 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
589 # define recvfrom rpl_recvfrom
591 _GL_FUNCDECL_RPL (recvfrom
, ssize_t
,
592 (int fd
, void *restrict buf
, size_t len
, int flags
,
593 struct sockaddr
*restrict from
,
594 socklen_t
*restrict fromlen
)
595 _GL_ARG_NONNULL ((2)));
596 _GL_CXXALIAS_RPL (recvfrom
, ssize_t
,
597 (int fd
, void *restrict buf
, size_t len
, int flags
,
598 struct sockaddr
*restrict from
,
599 socklen_t
*restrict fromlen
));
601 /* Need to cast, because on Solaris 10 systems, the sixth parameter is
603 _GL_CXXALIAS_SYS_CAST (recvfrom
, ssize_t
,
604 (int fd
, void *restrict buf
, size_t len
, int flags
,
605 struct sockaddr
*restrict from
,
606 socklen_t
*restrict fromlen
));
609 _GL_CXXALIASWARN (recvfrom
);
611 #elif @HAVE_WINSOCK2_H@
613 # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
614 #elif defined GNULIB_POSIXCHECK
616 # if HAVE_RAW_DECL_RECVFROM
617 _GL_WARN_ON_USE (recvfrom
, "recvfrom is not always POSIX compliant - "
618 "use gnulib module recvfrom for portability");
623 # if @HAVE_WINSOCK2_H@
624 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
626 # define sendto rpl_sendto
628 _GL_FUNCDECL_RPL (sendto
, ssize_t
,
629 (int fd
, const void *buf
, size_t len
, int flags
,
630 const struct sockaddr
*to
, socklen_t tolen
)
631 _GL_ARG_NONNULL ((2)));
632 _GL_CXXALIAS_RPL (sendto
, ssize_t
,
633 (int fd
, const void *buf
, size_t len
, int flags
,
634 const struct sockaddr
*to
, socklen_t tolen
));
636 /* Need to cast, because on NonStop Kernel, the sixth parameter is
638 _GL_CXXALIAS_SYS_CAST (sendto
, ssize_t
,
639 (int fd
, const void *buf
, size_t len
, int flags
,
640 const struct sockaddr
*to
, socklen_t tolen
));
642 _GL_CXXALIASWARN (sendto
);
643 #elif @HAVE_WINSOCK2_H@
645 # define sendto sendto_used_without_requesting_gnulib_module_sendto
646 #elif defined GNULIB_POSIXCHECK
648 # if HAVE_RAW_DECL_SENDTO
649 _GL_WARN_ON_USE (sendto
, "sendto is not always POSIX compliant - "
650 "use gnulib module sendto for portability");
654 #if @GNULIB_SETSOCKOPT@
655 # if @HAVE_WINSOCK2_H@
656 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
658 # define setsockopt rpl_setsockopt
660 _GL_FUNCDECL_RPL (setsockopt
, int, (int fd
, int level
, int optname
,
661 const void * optval
, socklen_t optlen
)
662 _GL_ARG_NONNULL ((4)));
663 _GL_CXXALIAS_RPL (setsockopt
, int, (int fd
, int level
, int optname
,
664 const void * optval
, socklen_t optlen
));
666 /* Need to cast, because on NonStop Kernel, the fifth parameter is
668 _GL_CXXALIAS_SYS_CAST (setsockopt
, int,
669 (int fd
, int level
, int optname
,
670 const void * optval
, socklen_t optlen
));
672 _GL_CXXALIASWARN (setsockopt
);
673 #elif @HAVE_WINSOCK2_H@
675 # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
676 #elif defined GNULIB_POSIXCHECK
678 # if HAVE_RAW_DECL_SETSOCKOPT
679 _GL_WARN_ON_USE (setsockopt
, "setsockopt is not always POSIX compliant - "
680 "use gnulib module setsockopt for portability");
684 #if @GNULIB_SHUTDOWN@
685 # if @HAVE_WINSOCK2_H@
686 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
688 # define shutdown rpl_shutdown
690 _GL_FUNCDECL_RPL (shutdown
, int, (int fd
, int how
));
691 _GL_CXXALIAS_RPL (shutdown
, int, (int fd
, int how
));
693 _GL_CXXALIAS_SYS (shutdown
, int, (int fd
, int how
));
695 _GL_CXXALIASWARN (shutdown
);
696 #elif @HAVE_WINSOCK2_H@
698 # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
699 #elif defined GNULIB_POSIXCHECK
701 # if HAVE_RAW_DECL_SHUTDOWN
702 _GL_WARN_ON_USE (shutdown
, "shutdown is not always POSIX compliant - "
703 "use gnulib module shutdown for portability");
708 /* Accept a connection on a socket, with specific opening flags.
709 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
710 and O_TEXT, O_BINARY (defined in "binary-io.h").
711 See also the Linux man page at
712 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
714 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
715 # define accept4 rpl_accept4
717 _GL_FUNCDECL_RPL (accept4
, int,
718 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
720 _GL_CXXALIAS_RPL (accept4
, int,
721 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
724 _GL_FUNCDECL_SYS (accept4
, int,
725 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
727 _GL_CXXALIAS_SYS (accept4
, int,
728 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
731 _GL_CXXALIASWARN (accept4
);
732 #elif defined GNULIB_POSIXCHECK
734 # if HAVE_RAW_DECL_ACCEPT4
735 _GL_WARN_ON_USE (accept4
, "accept4 is unportable - "
736 "use gnulib module accept4 for portability");
740 _GL_INLINE_HEADER_END
742 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
743 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */