New upstream version 2.3.4
This commit is contained in:
parent
e7bdd1c6c6
commit
de72f6f588
556 changed files with 90432 additions and 53391 deletions
|
@ -1,20 +1,20 @@
|
|||
/* Provide a sys/socket header file for systems lacking it (read: MinGW)
|
||||
and for systems where it is incomplete.
|
||||
Copyright (C) 2005-2013 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005-2023 Free Software Foundation, Inc.
|
||||
Written by Simon Josefsson.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>. */
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This file is supposed to be used on platforms that lack <sys/socket.h>,
|
||||
on platforms where <sys/socket.h> cannot be included standalone, and on
|
||||
|
@ -63,6 +63,9 @@
|
|||
#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
|
||||
#define _@GUARD_PREFIX@_SYS_SOCKET_H
|
||||
|
||||
#ifndef _GL_INLINE_HEADER_BEGIN
|
||||
#error "Please include config.h first."
|
||||
#endif
|
||||
_GL_INLINE_HEADER_BEGIN
|
||||
#ifndef _GL_SYS_SOCKET_INLINE
|
||||
# define _GL_SYS_SOCKET_INLINE _GL_INLINE
|
||||
|
@ -76,7 +79,12 @@ _GL_INLINE_HEADER_BEGIN
|
|||
|
||||
#if !@HAVE_SA_FAMILY_T@
|
||||
# if !GNULIB_defined_sa_family_t
|
||||
/* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
|
||||
# if !defined __KLIBC__ || defined TCPV40HDRS
|
||||
typedef unsigned short sa_family_t;
|
||||
# else
|
||||
typedef unsigned char sa_family_t;
|
||||
# endif
|
||||
# define GNULIB_defined_sa_family_t 1
|
||||
# endif
|
||||
#endif
|
||||
|
@ -89,7 +97,6 @@ typedef unsigned short sa_family_t;
|
|||
# endif
|
||||
# endif
|
||||
#else
|
||||
# include <stdalign.h>
|
||||
/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
|
||||
2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
|
||||
# define __ss_aligntype unsigned long int
|
||||
|
@ -133,6 +140,15 @@ struct sockaddr_storage
|
|||
# define SHUT_RDWR 2
|
||||
# endif
|
||||
|
||||
# ifdef __VMS /* OpenVMS */
|
||||
# ifndef CMSG_SPACE
|
||||
# define CMSG_SPACE(length) _CMSG_SPACE(length)
|
||||
# endif
|
||||
# ifndef CMSG_LEN
|
||||
# define CMSG_LEN(length) _CMSG_LEN(length)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
|
@ -152,7 +168,7 @@ struct sockaddr_storage
|
|||
code may not run on older Windows releases then. My Windows 2000
|
||||
box was not able to run the code, for example. The situation is
|
||||
slightly confusing because
|
||||
<http://msdn.microsoft.com/en-us/library/ms738520>
|
||||
<https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
|
||||
suggests that getaddrinfo should be available on all Windows
|
||||
releases. */
|
||||
|
||||
|
@ -178,12 +194,7 @@ struct sockaddr_storage
|
|||
/* Include headers needed by the emulation code. */
|
||||
# include <sys/types.h>
|
||||
# include <io.h>
|
||||
|
||||
# if !GNULIB_defined_socklen_t
|
||||
typedef int socklen_t;
|
||||
# define GNULIB_defined_socklen_t 1
|
||||
# endif
|
||||
|
||||
/* If these headers don't define socklen_t, <config.h> does. */
|
||||
# endif
|
||||
|
||||
/* Rudimentary 'struct msghdr'; this works as long as you don't try to
|
||||
|
@ -198,6 +209,15 @@ struct msghdr {
|
|||
|
||||
#endif
|
||||
|
||||
/* Ensure SO_REUSEPORT is defined. */
|
||||
/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
|
||||
https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
|
||||
and https://lwn.net/Articles/542629/
|
||||
*/
|
||||
#ifndef SO_REUSEPORT
|
||||
# define SO_REUSEPORT SO_REUSEADDR
|
||||
#endif
|
||||
|
||||
/* Fix some definitions from <winsock2.h>. */
|
||||
|
||||
#if @HAVE_WINSOCK2_H@
|
||||
|
@ -235,7 +255,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
|
|||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef close
|
||||
# define close close_used_without_including_unistd_h
|
||||
# else
|
||||
# elif !defined __clang__
|
||||
_GL_WARN_ON_USE (close,
|
||||
"close() used without including <unistd.h>");
|
||||
# endif
|
||||
|
@ -320,14 +340,20 @@ _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
|
|||
# define accept rpl_accept
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (accept, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd,
|
||||
struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
_GL_CXXALIAS_RPL (accept, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd,
|
||||
struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
# else
|
||||
/* Need to cast, because on Solaris 10 systems, the third parameter is
|
||||
void *addrlen. */
|
||||
void *addrlen. */
|
||||
_GL_CXXALIAS_SYS_CAST (accept, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd,
|
||||
struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (accept);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -378,15 +404,18 @@ _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
|
|||
# define getpeername rpl_getpeername
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (getpeername, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen)
|
||||
(int fd, struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen)
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
_GL_CXXALIAS_RPL (getpeername, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd, struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
# else
|
||||
/* Need to cast, because on Solaris 10 systems, the third parameter is
|
||||
void *addrlen. */
|
||||
void *addrlen. */
|
||||
_GL_CXXALIAS_SYS_CAST (getpeername, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd, struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (getpeername);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -407,15 +436,18 @@ _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
|
|||
# define getsockname rpl_getsockname
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (getsockname, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen)
|
||||
(int fd, struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen)
|
||||
_GL_ARG_NONNULL ((2, 3)));
|
||||
_GL_CXXALIAS_RPL (getsockname, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd, struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
# else
|
||||
/* Need to cast, because on Solaris 10 systems, the third parameter is
|
||||
void *addrlen. */
|
||||
void *addrlen. */
|
||||
_GL_CXXALIAS_SYS_CAST (getsockname, int,
|
||||
(int fd, struct sockaddr *addr, socklen_t *addrlen));
|
||||
(int fd, struct sockaddr *restrict addr,
|
||||
socklen_t *restrict addrlen));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (getsockname);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -435,16 +467,19 @@ _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
|
|||
# undef getsockopt
|
||||
# define getsockopt rpl_getsockopt
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (getsockopt, int, (int fd, int level, int optname,
|
||||
void *optval, socklen_t *optlen)
|
||||
_GL_ARG_NONNULL ((4, 5)));
|
||||
_GL_CXXALIAS_RPL (getsockopt, int, (int fd, int level, int optname,
|
||||
void *optval, socklen_t *optlen));
|
||||
_GL_FUNCDECL_RPL (getsockopt, int,
|
||||
(int fd, int level, int optname,
|
||||
void *restrict optval, socklen_t *restrict optlen)
|
||||
_GL_ARG_NONNULL ((4, 5)));
|
||||
_GL_CXXALIAS_RPL (getsockopt, int,
|
||||
(int fd, int level, int optname,
|
||||
void *restrict optval, socklen_t *restrict optlen));
|
||||
# else
|
||||
/* Need to cast, because on Solaris 10 systems, the fifth parameter is
|
||||
void *optlen. */
|
||||
_GL_CXXALIAS_SYS_CAST (getsockopt, int, (int fd, int level, int optname,
|
||||
void *optval, socklen_t *optlen));
|
||||
_GL_CXXALIAS_SYS_CAST (getsockopt, int,
|
||||
(int fd, int level, int optname,
|
||||
void *restrict optval, socklen_t *restrict optlen));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (getsockopt);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -491,7 +526,10 @@ _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
|
|||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
|
||||
/* Need to cast, because on HP-UX 11.31 the return type may be
|
||||
int,
|
||||
depending on compiler options. */
|
||||
_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (recv);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -517,8 +555,11 @@ _GL_FUNCDECL_RPL (send, ssize_t,
|
|||
_GL_CXXALIAS_RPL (send, ssize_t,
|
||||
(int fd, const void *buf, size_t len, int flags));
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (send, ssize_t,
|
||||
(int fd, const void *buf, size_t len, int flags));
|
||||
/* Need to cast, because on HP-UX 11.31 the return type may be
|
||||
int,
|
||||
depending on compiler options. */
|
||||
_GL_CXXALIAS_SYS_CAST (send, ssize_t,
|
||||
(int fd, const void *buf, size_t len, int flags));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (send);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -539,18 +580,21 @@ _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
|
|||
# define recvfrom rpl_recvfrom
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (recvfrom, ssize_t,
|
||||
(int fd, void *buf, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen)
|
||||
(int fd, void *restrict buf, size_t len, int flags,
|
||||
struct sockaddr *restrict from,
|
||||
socklen_t *restrict fromlen)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (recvfrom, ssize_t,
|
||||
(int fd, void *buf, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen));
|
||||
(int fd, void *restrict buf, size_t len, int flags,
|
||||
struct sockaddr *restrict from,
|
||||
socklen_t *restrict fromlen));
|
||||
# else
|
||||
/* Need to cast, because on Solaris 10 systems, the sixth parameter is
|
||||
void *fromlen. */
|
||||
_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
|
||||
(int fd, void *buf, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen));
|
||||
(int fd, void *restrict buf, size_t len, int flags,
|
||||
struct sockaddr *restrict from,
|
||||
socklen_t *restrict fromlen));
|
||||
# endif
|
||||
_GL_CXXALIASWARN (recvfrom);
|
||||
#elif @HAVE_WINSOCK2_H@
|
||||
|
@ -654,7 +698,7 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
|
|||
The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
|
||||
and O_TEXT, O_BINARY (defined in "binary-io.h").
|
||||
See also the Linux man page at
|
||||
<http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
|
||||
<https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
|
||||
# if @HAVE_ACCEPT4@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define accept4 rpl_accept4
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue