summaryrefslogtreecommitdiff
path: root/lib/sys_socket.in.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2021-01-20 21:52:54 +0100
committerAndy Wingo <wingo@pobox.com>2021-01-20 23:03:56 +0100
commita91b95cca2d397c84f8b9bbd602d40209a7092ce (patch)
tree2c286a291f5a2b812d6e216be10936f2709d59cf /lib/sys_socket.in.h
parent758b31994cff582c7e8785b4cc2240dbf3573837 (diff)
downloadguile-a91b95cca2d397c84f8b9bbd602d40209a7092ce.tar.gz
Update Gnulib to v0.1-4379-g2ef5a9b4b
Also bump required autoconf version to 2.64, as required by Gnulib.
Diffstat (limited to 'lib/sys_socket.in.h')
-rw-r--r--lib/sys_socket.in.h115
1 files changed, 76 insertions, 39 deletions
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index 841b4135f..c0baa71c0 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -1,6 +1,6 @@
/* Provide a sys/socket header file for systems lacking it (read: MinGW)
and for systems where it is incomplete.
- Copyright (C) 2005-2017 Free Software Foundation, Inc.
+ Copyright (C) 2005-2021 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
@@ -14,7 +14,7 @@
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>. */
+ 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
@@ -141,6 +141,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__
@@ -160,7 +169,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. */
@@ -186,12 +195,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
@@ -206,6 +210,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@
@@ -243,7 +256,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
@@ -328,14 +341,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@
@@ -386,15 +405,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@
@@ -415,15 +437,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@
@@ -443,16 +468,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@
@@ -499,7 +527,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@
@@ -525,8 +556,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@
@@ -547,18 +581,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@
@@ -662,7 +699,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