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-2023 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 #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 /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
101 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
102 # define __ss_aligntype unsigned long int
103 # define _SS_SIZE 256
104 # define _SS_PADSIZE \
105 (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype) \
106 ? sizeof (sa_family_t) \
107 : alignof (__ss_aligntype)) \
108 + sizeof (__ss_aligntype)))
110 # if !GNULIB_defined_struct_sockaddr_storage
111 struct sockaddr_storage
113 sa_family_t ss_family
; /* Address family, etc. */
114 __ss_aligntype __ss_align
; /* Force desired alignment. */
115 char __ss_padding
[_SS_PADSIZE
];
117 # define GNULIB_defined_struct_sockaddr_storage 1
122 /* Get struct iovec. */
123 /* But avoid namespace pollution on glibc systems. */
124 #if ! defined __GLIBC__
125 # include <sys/uio.h>
128 #if @HAVE_SYS_SOCKET_H@
130 /* A platform that has <sys/socket.h>. */
132 /* For shutdown(). */
133 # if !defined SHUT_RD
136 # if !defined SHUT_WR
139 # if !defined SHUT_RDWR
143 # ifdef __VMS /* OpenVMS */
145 # define CMSG_SPACE(length) _CMSG_SPACE(length)
148 # define CMSG_LEN(length) _CMSG_LEN(length)
155 # error "Cygwin does have a sys/socket.h, doesn't it?!?"
158 /* A platform that lacks <sys/socket.h>.
160 Currently only MinGW is supported. See the gnulib manual regarding
161 Windows sockets. MinGW has the header files winsock2.h and
162 ws2tcpip.h that declare the sys/socket.h definitions we need. Note
163 that you can influence which definitions you get by setting the
164 WINVER symbol before including these two files. For example,
165 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
166 symbol is set indirectly through WINVER). You can set this by
167 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
168 code may not run on older Windows releases then. My Windows 2000
169 box was not able to run the code, for example. The situation is
170 slightly confusing because
171 <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
172 suggests that getaddrinfo should be available on all Windows
175 # if @HAVE_WINSOCK2_H@
176 # include <winsock2.h>
178 # if @HAVE_WS2TCPIP_H@
179 # include <ws2tcpip.h>
182 /* For shutdown(). */
183 # if !defined SHUT_RD && defined SD_RECEIVE
184 # define SHUT_RD SD_RECEIVE
186 # if !defined SHUT_WR && defined SD_SEND
187 # define SHUT_WR SD_SEND
189 # if !defined SHUT_RDWR && defined SD_BOTH
190 # define SHUT_RDWR SD_BOTH
193 # if @HAVE_WINSOCK2_H@
194 /* Include headers needed by the emulation code. */
195 # include <sys/types.h>
197 /* If these headers don't define socklen_t, <config.h> does. */
200 /* Rudimentary 'struct msghdr'; this works as long as you don't try to
201 access msg_control or msg_controllen. */
204 socklen_t msg_namelen
;
205 struct iovec
*msg_iov
;
212 /* Ensure SO_REUSEPORT is defined. */
213 /* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
214 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
215 and https://lwn.net/Articles/542629/
218 # define SO_REUSEPORT SO_REUSEADDR
221 /* Fix some definitions from <winsock2.h>. */
223 #if @HAVE_WINSOCK2_H@
225 # if !GNULIB_defined_rpl_fd_isset
227 /* Re-define FD_ISSET to avoid a WSA call while we are not using
229 _GL_SYS_SOCKET_INLINE
int
230 rpl_fd_isset (SOCKET fd
, fd_set
* set
)
236 for (i
= 0; i
< set
->fd_count
; i
++)
237 if (set
->fd_array
[i
] == fd
)
243 # define GNULIB_defined_rpl_fd_isset 1
247 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
251 /* Hide some function declarations from <winsock2.h>. */
253 #if @HAVE_WINSOCK2_H@
254 # if !defined _@GUARD_PREFIX@_UNISTD_H
255 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257 # define close close_used_without_including_unistd_h
258 # elif !defined __clang__
259 _GL_WARN_ON_USE (close
,
260 "close() used without including <unistd.h>");
262 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
264 # define gethostname gethostname_used_without_including_unistd_h
266 _GL_WARN_ON_USE (gethostname
,
267 "gethostname() used without including <unistd.h>");
270 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
271 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273 # define select select_used_without_including_sys_select_h
275 _GL_WARN_ON_USE (select
,
276 "select() used without including <sys/select.h>");
281 /* Wrap everything else to use libc file descriptors for sockets. */
284 # if @HAVE_WINSOCK2_H@
285 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
287 # define socket rpl_socket
289 _GL_FUNCDECL_RPL (socket
, int, (int domain
, int type
, int protocol
));
290 _GL_CXXALIAS_RPL (socket
, int, (int domain
, int type
, int protocol
));
292 _GL_CXXALIAS_SYS (socket
, int, (int domain
, int type
, int protocol
));
294 _GL_CXXALIASWARN (socket
);
295 #elif @HAVE_WINSOCK2_H@
297 # define socket socket_used_without_requesting_gnulib_module_socket
298 #elif defined GNULIB_POSIXCHECK
300 # if HAVE_RAW_DECL_SOCKET
301 _GL_WARN_ON_USE (socket
, "socket is not always POSIX compliant - "
302 "use gnulib module socket for portability");
307 # if @HAVE_WINSOCK2_H@
308 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310 # define connect rpl_connect
312 _GL_FUNCDECL_RPL (connect
, int,
313 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
)
314 _GL_ARG_NONNULL ((2)));
315 _GL_CXXALIAS_RPL (connect
, int,
316 (int fd
, const struct sockaddr
*addr
, socklen_t addrlen
));
318 /* Need to cast, because on NonStop Kernel, the third parameter is
320 _GL_CXXALIAS_SYS_CAST (connect
, int,
322 const struct sockaddr
*addr
, socklen_t addrlen
));
324 _GL_CXXALIASWARN (connect
);
325 #elif @HAVE_WINSOCK2_H@
327 # define connect socket_used_without_requesting_gnulib_module_connect
328 #elif defined GNULIB_POSIXCHECK
330 # if HAVE_RAW_DECL_CONNECT
331 _GL_WARN_ON_USE (connect
, "connect is not always POSIX compliant - "
332 "use gnulib module connect for portability");
337 # if @HAVE_WINSOCK2_H@
338 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340 # define accept rpl_accept
342 _GL_FUNCDECL_RPL (accept
, int,
344 struct sockaddr
*restrict addr
,
345 socklen_t
*restrict addrlen
));
346 _GL_CXXALIAS_RPL (accept
, int,
348 struct sockaddr
*restrict addr
,
349 socklen_t
*restrict addrlen
));
351 /* Need to cast, because on Solaris 10 systems, the third parameter is
353 _GL_CXXALIAS_SYS_CAST (accept
, int,
355 struct sockaddr
*restrict addr
,
356 socklen_t
*restrict 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
*restrict addr
,
408 socklen_t
*restrict addrlen
)
409 _GL_ARG_NONNULL ((2, 3)));
410 _GL_CXXALIAS_RPL (getpeername
, int,
411 (int fd
, struct sockaddr
*restrict addr
,
412 socklen_t
*restrict addrlen
));
414 /* Need to cast, because on Solaris 10 systems, the third parameter is
416 _GL_CXXALIAS_SYS_CAST (getpeername
, int,
417 (int fd
, struct sockaddr
*restrict addr
,
418 socklen_t
*restrict addrlen
));
420 _GL_CXXALIASWARN (getpeername
);
421 #elif @HAVE_WINSOCK2_H@
423 # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
424 #elif defined GNULIB_POSIXCHECK
426 # if HAVE_RAW_DECL_GETPEERNAME
427 _GL_WARN_ON_USE (getpeername
, "getpeername is not always POSIX compliant - "
428 "use gnulib module getpeername for portability");
432 #if @GNULIB_GETSOCKNAME@
433 # if @HAVE_WINSOCK2_H@
434 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
436 # define getsockname rpl_getsockname
438 _GL_FUNCDECL_RPL (getsockname
, int,
439 (int fd
, struct sockaddr
*restrict addr
,
440 socklen_t
*restrict addrlen
)
441 _GL_ARG_NONNULL ((2, 3)));
442 _GL_CXXALIAS_RPL (getsockname
, int,
443 (int fd
, struct sockaddr
*restrict addr
,
444 socklen_t
*restrict addrlen
));
446 /* Need to cast, because on Solaris 10 systems, the third parameter is
448 _GL_CXXALIAS_SYS_CAST (getsockname
, int,
449 (int fd
, struct sockaddr
*restrict addr
,
450 socklen_t
*restrict addrlen
));
452 _GL_CXXALIASWARN (getsockname
);
453 #elif @HAVE_WINSOCK2_H@
455 # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
456 #elif defined GNULIB_POSIXCHECK
458 # if HAVE_RAW_DECL_GETSOCKNAME
459 _GL_WARN_ON_USE (getsockname
, "getsockname is not always POSIX compliant - "
460 "use gnulib module getsockname for portability");
464 #if @GNULIB_GETSOCKOPT@
465 # if @HAVE_WINSOCK2_H@
466 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
468 # define getsockopt rpl_getsockopt
470 _GL_FUNCDECL_RPL (getsockopt
, int,
471 (int fd
, int level
, int optname
,
472 void *restrict optval
, socklen_t
*restrict optlen
)
473 _GL_ARG_NONNULL ((4, 5)));
474 _GL_CXXALIAS_RPL (getsockopt
, int,
475 (int fd
, int level
, int optname
,
476 void *restrict optval
, socklen_t
*restrict optlen
));
478 /* Need to cast, because on Solaris 10 systems, the fifth parameter is
480 _GL_CXXALIAS_SYS_CAST (getsockopt
, int,
481 (int fd
, int level
, int optname
,
482 void *restrict optval
, socklen_t
*restrict optlen
));
484 _GL_CXXALIASWARN (getsockopt
);
485 #elif @HAVE_WINSOCK2_H@
487 # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
488 #elif defined GNULIB_POSIXCHECK
490 # if HAVE_RAW_DECL_GETSOCKOPT
491 _GL_WARN_ON_USE (getsockopt
, "getsockopt is not always POSIX compliant - "
492 "use gnulib module getsockopt for portability");
497 # if @HAVE_WINSOCK2_H@
498 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500 # define listen rpl_listen
502 _GL_FUNCDECL_RPL (listen
, int, (int fd
, int backlog
));
503 _GL_CXXALIAS_RPL (listen
, int, (int fd
, int backlog
));
505 _GL_CXXALIAS_SYS (listen
, int, (int fd
, int backlog
));
507 _GL_CXXALIASWARN (listen
);
508 #elif @HAVE_WINSOCK2_H@
510 # define listen listen_used_without_requesting_gnulib_module_listen
511 #elif defined GNULIB_POSIXCHECK
513 # if HAVE_RAW_DECL_LISTEN
514 _GL_WARN_ON_USE (listen
, "listen is not always POSIX compliant - "
515 "use gnulib module listen for portability");
520 # if @HAVE_WINSOCK2_H@
521 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
523 # define recv rpl_recv
525 _GL_FUNCDECL_RPL (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
)
526 _GL_ARG_NONNULL ((2)));
527 _GL_CXXALIAS_RPL (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
));
529 /* Need to cast, because on HP-UX 11.31 the return type may be
531 depending on compiler options. */
532 _GL_CXXALIAS_SYS_CAST (recv
, ssize_t
, (int fd
, void *buf
, size_t len
, int flags
));
534 _GL_CXXALIASWARN (recv
);
535 #elif @HAVE_WINSOCK2_H@
537 # define recv recv_used_without_requesting_gnulib_module_recv
538 #elif defined GNULIB_POSIXCHECK
540 # if HAVE_RAW_DECL_RECV
541 _GL_WARN_ON_USE (recv
, "recv is not always POSIX compliant - "
542 "use gnulib module recv for portability");
547 # if @HAVE_WINSOCK2_H@
548 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
550 # define send rpl_send
552 _GL_FUNCDECL_RPL (send
, ssize_t
,
553 (int fd
, const void *buf
, size_t len
, int flags
)
554 _GL_ARG_NONNULL ((2)));
555 _GL_CXXALIAS_RPL (send
, ssize_t
,
556 (int fd
, const void *buf
, size_t len
, int flags
));
558 /* Need to cast, because on HP-UX 11.31 the return type may be
560 depending on compiler options. */
561 _GL_CXXALIAS_SYS_CAST (send
, ssize_t
,
562 (int fd
, const void *buf
, size_t len
, int flags
));
564 _GL_CXXALIASWARN (send
);
565 #elif @HAVE_WINSOCK2_H@
567 # define send send_used_without_requesting_gnulib_module_send
568 #elif defined GNULIB_POSIXCHECK
570 # if HAVE_RAW_DECL_SEND
571 _GL_WARN_ON_USE (send
, "send is not always POSIX compliant - "
572 "use gnulib module send for portability");
576 #if @GNULIB_RECVFROM@
577 # if @HAVE_WINSOCK2_H@
578 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
580 # define recvfrom rpl_recvfrom
582 _GL_FUNCDECL_RPL (recvfrom
, ssize_t
,
583 (int fd
, void *restrict buf
, size_t len
, int flags
,
584 struct sockaddr
*restrict from
,
585 socklen_t
*restrict fromlen
)
586 _GL_ARG_NONNULL ((2)));
587 _GL_CXXALIAS_RPL (recvfrom
, ssize_t
,
588 (int fd
, void *restrict buf
, size_t len
, int flags
,
589 struct sockaddr
*restrict from
,
590 socklen_t
*restrict fromlen
));
592 /* Need to cast, because on Solaris 10 systems, the sixth parameter is
594 _GL_CXXALIAS_SYS_CAST (recvfrom
, ssize_t
,
595 (int fd
, void *restrict buf
, size_t len
, int flags
,
596 struct sockaddr
*restrict from
,
597 socklen_t
*restrict fromlen
));
599 _GL_CXXALIASWARN (recvfrom
);
600 #elif @HAVE_WINSOCK2_H@
602 # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
603 #elif defined GNULIB_POSIXCHECK
605 # if HAVE_RAW_DECL_RECVFROM
606 _GL_WARN_ON_USE (recvfrom
, "recvfrom is not always POSIX compliant - "
607 "use gnulib module recvfrom for portability");
612 # if @HAVE_WINSOCK2_H@
613 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
615 # define sendto rpl_sendto
617 _GL_FUNCDECL_RPL (sendto
, ssize_t
,
618 (int fd
, const void *buf
, size_t len
, int flags
,
619 const struct sockaddr
*to
, socklen_t tolen
)
620 _GL_ARG_NONNULL ((2)));
621 _GL_CXXALIAS_RPL (sendto
, ssize_t
,
622 (int fd
, const void *buf
, size_t len
, int flags
,
623 const struct sockaddr
*to
, socklen_t tolen
));
625 /* Need to cast, because on NonStop Kernel, the sixth parameter is
627 _GL_CXXALIAS_SYS_CAST (sendto
, ssize_t
,
628 (int fd
, const void *buf
, size_t len
, int flags
,
629 const struct sockaddr
*to
, socklen_t tolen
));
631 _GL_CXXALIASWARN (sendto
);
632 #elif @HAVE_WINSOCK2_H@
634 # define sendto sendto_used_without_requesting_gnulib_module_sendto
635 #elif defined GNULIB_POSIXCHECK
637 # if HAVE_RAW_DECL_SENDTO
638 _GL_WARN_ON_USE (sendto
, "sendto is not always POSIX compliant - "
639 "use gnulib module sendto for portability");
643 #if @GNULIB_SETSOCKOPT@
644 # if @HAVE_WINSOCK2_H@
645 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
647 # define setsockopt rpl_setsockopt
649 _GL_FUNCDECL_RPL (setsockopt
, int, (int fd
, int level
, int optname
,
650 const void * optval
, socklen_t optlen
)
651 _GL_ARG_NONNULL ((4)));
652 _GL_CXXALIAS_RPL (setsockopt
, int, (int fd
, int level
, int optname
,
653 const void * optval
, socklen_t optlen
));
655 /* Need to cast, because on NonStop Kernel, the fifth parameter is
657 _GL_CXXALIAS_SYS_CAST (setsockopt
, int,
658 (int fd
, int level
, int optname
,
659 const void * optval
, socklen_t optlen
));
661 _GL_CXXALIASWARN (setsockopt
);
662 #elif @HAVE_WINSOCK2_H@
664 # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
665 #elif defined GNULIB_POSIXCHECK
667 # if HAVE_RAW_DECL_SETSOCKOPT
668 _GL_WARN_ON_USE (setsockopt
, "setsockopt is not always POSIX compliant - "
669 "use gnulib module setsockopt for portability");
673 #if @GNULIB_SHUTDOWN@
674 # if @HAVE_WINSOCK2_H@
675 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
677 # define shutdown rpl_shutdown
679 _GL_FUNCDECL_RPL (shutdown
, int, (int fd
, int how
));
680 _GL_CXXALIAS_RPL (shutdown
, int, (int fd
, int how
));
682 _GL_CXXALIAS_SYS (shutdown
, int, (int fd
, int how
));
684 _GL_CXXALIASWARN (shutdown
);
685 #elif @HAVE_WINSOCK2_H@
687 # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
688 #elif defined GNULIB_POSIXCHECK
690 # if HAVE_RAW_DECL_SHUTDOWN
691 _GL_WARN_ON_USE (shutdown
, "shutdown is not always POSIX compliant - "
692 "use gnulib module shutdown for portability");
697 /* Accept a connection on a socket, with specific opening flags.
698 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
699 and O_TEXT, O_BINARY (defined in "binary-io.h").
700 See also the Linux man page at
701 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
703 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
704 # define accept4 rpl_accept4
706 _GL_FUNCDECL_RPL (accept4
, int,
707 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
709 _GL_CXXALIAS_RPL (accept4
, int,
710 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
713 _GL_FUNCDECL_SYS (accept4
, int,
714 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
716 _GL_CXXALIAS_SYS (accept4
, int,
717 (int sockfd
, struct sockaddr
*addr
, socklen_t
*addrlen
,
720 _GL_CXXALIASWARN (accept4
);
721 #elif defined GNULIB_POSIXCHECK
723 # if HAVE_RAW_DECL_ACCEPT4
724 _GL_WARN_ON_USE (accept4
, "accept4 is unportable - "
725 "use gnulib module accept4 for portability");
729 _GL_INLINE_HEADER_END
731 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
732 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */