From a405fc138596f552581d2011fd6de02d5c8186c4 Mon Sep 17 00:00:00 2001
From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com>
Date: Wed, 17 Nov 2021 01:05:54 +0100
Subject: Sync with the latest Gnulib code (1a268176f)
---
gl/sys_socket.in.h | 137 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 91 insertions(+), 46 deletions(-)
(limited to 'gl/sys_socket.in.h')
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index b4cf0c39..0a2c57db 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -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-2021 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 . */
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see . */
/* This file is supposed to be used on platforms that lack ,
on platforms where 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
@@ -133,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__
@@ -152,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
-
+
suggests that getaddrinfo should be available on all Windows
releases. */
@@ -178,12 +195,7 @@ struct sockaddr_storage
/* Include headers needed by the emulation code. */
# include
# include
-
-# if !GNULIB_defined_socklen_t
-typedef int socklen_t;
-# define GNULIB_defined_socklen_t 1
-# endif
-
+/* If these headers don't define socklen_t, does. */
# endif
/* Rudimentary 'struct msghdr'; this works as long as you don't try to
@@ -198,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 . */
#if @HAVE_WINSOCK2_H@
@@ -235,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 ");
# endif
@@ -320,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@
@@ -378,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@
@@ -407,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@
@@ -435,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@
@@ -491,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@
@@ -517,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@
@@ -539,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@
@@ -654,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 )
and O_TEXT, O_BINARY (defined in "binary-io.h").
See also the Linux man page at
- . */
+ . */
# if @HAVE_ACCEPT4@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define accept4 rpl_accept4
--
cgit v1.2.3-74-g34f1