Blame gl/sys_socket.in.h

Packit aea12f
/* Provide a sys/socket header file for systems lacking it (read: MinGW)
Packit aea12f
   and for systems where it is incomplete.
Packit Service 991b93
   Copyright (C) 2005-2020 Free Software Foundation, Inc.
Packit aea12f
   Written by Simon Josefsson.
Packit aea12f
Packit aea12f
   This program is free software; you can redistribute it and/or modify
Packit Service 991b93
   it under the terms of the GNU Lesser General Public License as published by
Packit Service 991b93
   the Free Software Foundation; either version 2.1, or (at your option)
Packit aea12f
   any later version.
Packit aea12f
Packit aea12f
   This program is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 991b93
   GNU Lesser General Public License for more details.
Packit aea12f
Packit Service 991b93
   You should have received a copy of the GNU Lesser General Public License
Packit aea12f
   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
/* This file is supposed to be used on platforms that lack <sys/socket.h>,
Packit aea12f
   on platforms where <sys/socket.h> cannot be included standalone, and on
Packit aea12f
   platforms where <sys/socket.h> does not provide all necessary definitions.
Packit aea12f
   It is intended to provide definitions and prototypes needed by an
Packit aea12f
   application.  */
Packit aea12f
Packit aea12f
#if __GNUC__ >= 3
Packit aea12f
@PRAGMA_SYSTEM_HEADER@
Packit aea12f
#endif
Packit aea12f
@PRAGMA_COLUMNS@
Packit aea12f
Packit aea12f
#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H
Packit aea12f
/* Special invocation convention:
Packit aea12f
   - On Cygwin 1.5.x we have a sequence of nested includes
Packit aea12f
     <sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>,
Packit aea12f
     and the latter includes <sys/socket.h>.  In this situation, the functions
Packit aea12f
     are not yet declared, therefore we cannot provide the C++ aliases.  */
Packit aea12f
Packit aea12f
#@INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
Packit aea12f
Packit aea12f
#else
Packit aea12f
/* Normal invocation convention.  */
Packit aea12f
Packit aea12f
#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
Packit aea12f
Packit aea12f
#if @HAVE_SYS_SOCKET_H@
Packit aea12f
Packit aea12f
# define _GL_ALREADY_INCLUDING_SYS_SOCKET_H
Packit aea12f
Packit aea12f
/* On many platforms, <sys/socket.h> assumes prior inclusion of
Packit aea12f
   <sys/types.h>.  */
Packit aea12f
# include <sys/types.h>
Packit aea12f
Packit aea12f
/* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL
Packit aea12f
   is defined.  */
Packit aea12f
# include <stddef.h>
Packit aea12f
Packit aea12f
/* The include_next requires a split double-inclusion guard.  */
Packit aea12f
# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
Packit aea12f
Packit aea12f
# undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
Packit aea12f
#define _@GUARD_PREFIX@_SYS_SOCKET_H
Packit aea12f
Packit aea12f
#ifndef _GL_INLINE_HEADER_BEGIN
Packit aea12f
 #error "Please include config.h first."
Packit aea12f
#endif
Packit aea12f
_GL_INLINE_HEADER_BEGIN
Packit aea12f
#ifndef _GL_SYS_SOCKET_INLINE
Packit aea12f
# define _GL_SYS_SOCKET_INLINE _GL_INLINE
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
Packit aea12f
Packit aea12f
/* The definition of _GL_ARG_NONNULL is copied here.  */
Packit aea12f
Packit aea12f
/* The definition of _GL_WARN_ON_USE is copied here.  */
Packit aea12f
Packit aea12f
#if !@HAVE_SA_FAMILY_T@
Packit aea12f
# if !GNULIB_defined_sa_family_t
Packit aea12f
/* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
Packit aea12f
#  if !defined __KLIBC__ || defined TCPV40HDRS
Packit aea12f
typedef unsigned short  sa_family_t;
Packit aea12f
#  else
Packit aea12f
typedef unsigned char   sa_family_t;
Packit aea12f
#  endif
Packit aea12f
#  define GNULIB_defined_sa_family_t 1
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @HAVE_STRUCT_SOCKADDR_STORAGE@
Packit aea12f
/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1.  */
Packit aea12f
# if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@
Packit aea12f
#  ifndef ss_family
Packit aea12f
#   define ss_family __ss_family
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
#else
Packit aea12f
# include <stdalign.h>
Packit aea12f
/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
Packit aea12f
   2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
Packit aea12f
# define __ss_aligntype unsigned long int
Packit aea12f
# define _SS_SIZE 256
Packit aea12f
# define _SS_PADSIZE \
Packit aea12f
    (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype)      \
Packit aea12f
                  ? sizeof (sa_family_t)                                \
Packit aea12f
                  : alignof (__ss_aligntype))                           \
Packit aea12f
                 + sizeof (__ss_aligntype)))
Packit aea12f
Packit aea12f
# if !GNULIB_defined_struct_sockaddr_storage
Packit aea12f
struct sockaddr_storage
Packit aea12f
{
Packit aea12f
  sa_family_t ss_family;      /* Address family, etc.  */
Packit aea12f
  __ss_aligntype __ss_align;  /* Force desired alignment.  */
Packit aea12f
  char __ss_padding[_SS_PADSIZE];
Packit aea12f
};
Packit aea12f
#  define GNULIB_defined_struct_sockaddr_storage 1
Packit aea12f
# endif
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Get struct iovec.  */
Packit aea12f
/* But avoid namespace pollution on glibc systems.  */
Packit aea12f
#if ! defined __GLIBC__
Packit aea12f
# include <sys/uio.h>
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @HAVE_SYS_SOCKET_H@
Packit aea12f
Packit aea12f
/* A platform that has <sys/socket.h>.  */
Packit aea12f
Packit aea12f
/* For shutdown().  */
Packit aea12f
# if !defined SHUT_RD
Packit aea12f
#  define SHUT_RD 0
Packit aea12f
# endif
Packit aea12f
# if !defined SHUT_WR
Packit aea12f
#  define SHUT_WR 1
Packit aea12f
# endif
Packit aea12f
# if !defined SHUT_RDWR
Packit aea12f
#  define SHUT_RDWR 2
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# ifdef __VMS                        /* OpenVMS */
Packit aea12f
#  ifndef CMSG_SPACE
Packit aea12f
#   define CMSG_SPACE(length) _CMSG_SPACE(length)
Packit aea12f
#  endif
Packit aea12f
#  ifndef CMSG_LEN
Packit aea12f
#   define CMSG_LEN(length) _CMSG_LEN(length)
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
Packit aea12f
#else
Packit aea12f
Packit aea12f
# ifdef __CYGWIN__
Packit aea12f
#  error "Cygwin does have a sys/socket.h, doesn't it?!?"
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* A platform that lacks <sys/socket.h>.
Packit aea12f
Packit aea12f
   Currently only MinGW is supported.  See the gnulib manual regarding
Packit aea12f
   Windows sockets.  MinGW has the header files winsock2.h and
Packit aea12f
   ws2tcpip.h that declare the sys/socket.h definitions we need.  Note
Packit aea12f
   that you can influence which definitions you get by setting the
Packit aea12f
   WINVER symbol before including these two files.  For example,
Packit aea12f
   getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
Packit aea12f
   symbol is set indirectly through WINVER).  You can set this by
Packit aea12f
   adding AC_DEFINE(WINVER, 0x0501) to configure.ac.  Note that your
Packit aea12f
   code may not run on older Windows releases then.  My Windows 2000
Packit aea12f
   box was not able to run the code, for example.  The situation is
Packit aea12f
   slightly confusing because
Packit aea12f
   <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
Packit aea12f
   suggests that getaddrinfo should be available on all Windows
Packit aea12f
   releases. */
Packit aea12f
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  include <winsock2.h>
Packit aea12f
# endif
Packit aea12f
# if @HAVE_WS2TCPIP_H@
Packit aea12f
#  include <ws2tcpip.h>
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* For shutdown(). */
Packit aea12f
# if !defined SHUT_RD && defined SD_RECEIVE
Packit aea12f
#  define SHUT_RD SD_RECEIVE
Packit aea12f
# endif
Packit aea12f
# if !defined SHUT_WR && defined SD_SEND
Packit aea12f
#  define SHUT_WR SD_SEND
Packit aea12f
# endif
Packit aea12f
# if !defined SHUT_RDWR && defined SD_BOTH
Packit aea12f
#  define SHUT_RDWR SD_BOTH
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
/* Include headers needed by the emulation code.  */
Packit aea12f
#  include <sys/types.h>
Packit aea12f
#  include <io.h>
Packit aea12f
Packit aea12f
#  if !GNULIB_defined_socklen_t
Packit aea12f
typedef int socklen_t;
Packit aea12f
#   define GNULIB_defined_socklen_t 1
Packit aea12f
#  endif
Packit aea12f
Packit aea12f
# endif
Packit aea12f
Packit aea12f
/* Rudimentary 'struct msghdr'; this works as long as you don't try to
Packit aea12f
   access msg_control or msg_controllen.  */
Packit aea12f
struct msghdr {
Packit aea12f
  void *msg_name;
Packit aea12f
  socklen_t msg_namelen;
Packit aea12f
  struct iovec *msg_iov;
Packit aea12f
  int msg_iovlen;
Packit aea12f
  int msg_flags;
Packit aea12f
};
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Ensure SO_REUSEPORT is defined.  */
Packit aea12f
/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
Packit aea12f
   https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
Packit aea12f
   and https://lwn.net/Articles/542629/
Packit aea12f
 */
Packit aea12f
#ifndef SO_REUSEPORT
Packit aea12f
# define SO_REUSEPORT SO_REUSEADDR
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Fix some definitions from <winsock2.h>.  */
Packit aea12f
Packit aea12f
#if @HAVE_WINSOCK2_H@
Packit aea12f
Packit aea12f
# if !GNULIB_defined_rpl_fd_isset
Packit aea12f
Packit aea12f
/* Re-define FD_ISSET to avoid a WSA call while we are not using
Packit aea12f
   network sockets.  */
Packit aea12f
_GL_SYS_SOCKET_INLINE int
Packit aea12f
rpl_fd_isset (SOCKET fd, fd_set * set)
Packit aea12f
{
Packit aea12f
  u_int i;
Packit aea12f
  if (set == NULL)
Packit aea12f
    return 0;
Packit aea12f
Packit aea12f
  for (i = 0; i < set->fd_count; i++)
Packit aea12f
    if (set->fd_array[i] == fd)
Packit aea12f
      return 1;
Packit aea12f
Packit aea12f
  return 0;
Packit aea12f
}
Packit aea12f
Packit aea12f
#  define GNULIB_defined_rpl_fd_isset 1
Packit aea12f
# endif
Packit aea12f
Packit aea12f
# undef FD_ISSET
Packit aea12f
# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
Packit aea12f
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Hide some function declarations from <winsock2.h>.  */
Packit aea12f
Packit aea12f
#if @HAVE_WINSOCK2_H@
Packit aea12f
# if !defined _@GUARD_PREFIX@_UNISTD_H
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef close
Packit aea12f
#   define close close_used_without_including_unistd_h
Packit aea12f
#  else
Packit aea12f
    _GL_WARN_ON_USE (close,
Packit aea12f
                     "close() used without including <unistd.h>");
Packit aea12f
#  endif
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef gethostname
Packit aea12f
#   define gethostname gethostname_used_without_including_unistd_h
Packit aea12f
#  else
Packit aea12f
    _GL_WARN_ON_USE (gethostname,
Packit aea12f
                     "gethostname() used without including <unistd.h>");
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef select
Packit aea12f
#   define select select_used_without_including_sys_select_h
Packit aea12f
#  else
Packit aea12f
    _GL_WARN_ON_USE (select,
Packit aea12f
                     "select() used without including <sys/select.h>");
Packit aea12f
#  endif
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
/* Wrap everything else to use libc file descriptors for sockets.  */
Packit aea12f
Packit aea12f
#if @GNULIB_SOCKET@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef socket
Packit aea12f
#   define socket rpl_socket
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol));
Packit aea12f
_GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol));
Packit aea12f
# else
Packit aea12f
_GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (socket);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef socket
Packit aea12f
# define socket socket_used_without_requesting_gnulib_module_socket
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef socket
Packit aea12f
# if HAVE_RAW_DECL_SOCKET
Packit aea12f
_GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module socket for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_CONNECT@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef connect
Packit aea12f
#   define connect rpl_connect
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (connect, int,
Packit aea12f
                  (int fd, const struct sockaddr *addr, socklen_t addrlen)
Packit aea12f
                  _GL_ARG_NONNULL ((2)));
Packit aea12f
_GL_CXXALIAS_RPL (connect, int,
Packit aea12f
                  (int fd, const struct sockaddr *addr, socklen_t addrlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on NonStop Kernel, the third parameter is
Packit aea12f
                                                     size_t addrlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (connect, int,
Packit aea12f
                       (int fd,
Packit aea12f
                        const struct sockaddr *addr, socklen_t addrlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (connect);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef connect
Packit aea12f
# define connect socket_used_without_requesting_gnulib_module_connect
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef connect
Packit aea12f
# if HAVE_RAW_DECL_CONNECT
Packit aea12f
_GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module connect for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_ACCEPT@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef accept
Packit aea12f
#   define accept rpl_accept
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (accept, int,
Packit Service 991b93
                  (int fd,
Packit Service 991b93
                   struct sockaddr *restrict addr,
Packit Service 991b93
                   socklen_t *restrict addrlen));
Packit aea12f
_GL_CXXALIAS_RPL (accept, int,
Packit Service 991b93
                  (int fd,
Packit Service 991b93
                   struct sockaddr *restrict addr,
Packit Service 991b93
                   socklen_t *restrict addrlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on Solaris 10 systems, the third parameter is
Packit Service 991b93
                        void *addrlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (accept, int,
Packit Service 991b93
                       (int fd,
Packit Service 991b93
                        struct sockaddr *restrict addr,
Packit Service 991b93
                        socklen_t *restrict addrlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (accept);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef accept
Packit aea12f
# define accept accept_used_without_requesting_gnulib_module_accept
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef accept
Packit aea12f
# if HAVE_RAW_DECL_ACCEPT
Packit aea12f
_GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module accept for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_BIND@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef bind
Packit aea12f
#   define bind rpl_bind
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (bind, int,
Packit aea12f
                  (int fd, const struct sockaddr *addr, socklen_t addrlen)
Packit aea12f
                  _GL_ARG_NONNULL ((2)));
Packit aea12f
_GL_CXXALIAS_RPL (bind, int,
Packit aea12f
                  (int fd, const struct sockaddr *addr, socklen_t addrlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on NonStop Kernel, the third parameter is
Packit aea12f
                                                     size_t addrlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (bind, int,
Packit aea12f
                       (int fd,
Packit aea12f
                        const struct sockaddr *addr, socklen_t addrlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (bind);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef bind
Packit aea12f
# define bind bind_used_without_requesting_gnulib_module_bind
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef bind
Packit aea12f
# if HAVE_RAW_DECL_BIND
Packit aea12f
_GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module bind for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_GETPEERNAME@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef getpeername
Packit aea12f
#   define getpeername rpl_getpeername
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (getpeername, int,
Packit Service 991b93
                  (int fd, struct sockaddr *restrict addr,
Packit Service 991b93
                   socklen_t *restrict addrlen)
Packit aea12f
                  _GL_ARG_NONNULL ((2, 3)));
Packit aea12f
_GL_CXXALIAS_RPL (getpeername, int,
Packit Service 991b93
                  (int fd, struct sockaddr *restrict addr,
Packit Service 991b93
                   socklen_t *restrict addrlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on Solaris 10 systems, the third parameter is
Packit Service 991b93
                        void *addrlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (getpeername, int,
Packit Service 991b93
                       (int fd, struct sockaddr *restrict addr,
Packit Service 991b93
                        socklen_t *restrict addrlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (getpeername);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef getpeername
Packit aea12f
# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef getpeername
Packit aea12f
# if HAVE_RAW_DECL_GETPEERNAME
Packit aea12f
_GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module getpeername for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_GETSOCKNAME@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef getsockname
Packit aea12f
#   define getsockname rpl_getsockname
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (getsockname, int,
Packit Service 991b93
                  (int fd, struct sockaddr *restrict addr,
Packit Service 991b93
                   socklen_t *restrict addrlen)
Packit aea12f
                  _GL_ARG_NONNULL ((2, 3)));
Packit aea12f
_GL_CXXALIAS_RPL (getsockname, int,
Packit Service 991b93
                  (int fd, struct sockaddr *restrict addr,
Packit Service 991b93
                   socklen_t *restrict addrlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on Solaris 10 systems, the third parameter is
Packit Service 991b93
                        void *addrlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (getsockname, int,
Packit Service 991b93
                       (int fd, struct sockaddr *restrict addr,
Packit Service 991b93
                        socklen_t *restrict addrlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (getsockname);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef getsockname
Packit aea12f
# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef getsockname
Packit aea12f
# if HAVE_RAW_DECL_GETSOCKNAME
Packit aea12f
_GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module getsockname for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_GETSOCKOPT@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef getsockopt
Packit aea12f
#   define getsockopt rpl_getsockopt
Packit aea12f
#  endif
Packit Service 991b93
_GL_FUNCDECL_RPL (getsockopt, int,
Packit Service 991b93
                  (int fd, int level, int optname,
Packit Service 991b93
                   void *restrict optval, socklen_t *restrict optlen)
Packit Service 991b93
                  _GL_ARG_NONNULL ((4, 5)));
Packit Service 991b93
_GL_CXXALIAS_RPL (getsockopt, int,
Packit Service 991b93
                  (int fd, int level, int optname,
Packit Service 991b93
                   void *restrict optval, socklen_t *restrict optlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on Solaris 10 systems, the fifth parameter is
Packit aea12f
                                                       void *optlen.  */
Packit Service 991b93
_GL_CXXALIAS_SYS_CAST (getsockopt, int,
Packit Service 991b93
                       (int fd, int level, int optname,
Packit Service 991b93
                        void *restrict optval, socklen_t *restrict optlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (getsockopt);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef getsockopt
Packit aea12f
# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef getsockopt
Packit aea12f
# if HAVE_RAW_DECL_GETSOCKOPT
Packit aea12f
_GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module getsockopt for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_LISTEN@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef listen
Packit aea12f
#   define listen rpl_listen
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (listen, int, (int fd, int backlog));
Packit aea12f
_GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
Packit aea12f
# else
Packit aea12f
_GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (listen);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef listen
Packit aea12f
# define listen listen_used_without_requesting_gnulib_module_listen
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef listen
Packit aea12f
# if HAVE_RAW_DECL_LISTEN
Packit aea12f
_GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module listen for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_RECV@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef recv
Packit aea12f
#   define recv rpl_recv
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
Packit aea12f
                                 _GL_ARG_NONNULL ((2)));
Packit aea12f
_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
Packit aea12f
# else
Packit Service 991b93
/* Need to cast, because on HP-UX 11.31 the return type may be
Packit Service 991b93
                             int,
Packit Service 991b93
   depending on compiler options.  */
Packit Service 991b93
_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (recv);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef recv
Packit aea12f
# define recv recv_used_without_requesting_gnulib_module_recv
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef recv
Packit aea12f
# if HAVE_RAW_DECL_RECV
Packit aea12f
_GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module recv for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_SEND@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef send
Packit aea12f
#   define send rpl_send
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (send, ssize_t,
Packit aea12f
                  (int fd, const void *buf, size_t len, int flags)
Packit aea12f
                  _GL_ARG_NONNULL ((2)));
Packit aea12f
_GL_CXXALIAS_RPL (send, ssize_t,
Packit aea12f
                  (int fd, const void *buf, size_t len, int flags));
Packit aea12f
# else
Packit Service 991b93
/* Need to cast, because on HP-UX 11.31 the return type may be
Packit Service 991b93
                             int,
Packit Service 991b93
   depending on compiler options.  */
Packit Service 991b93
_GL_CXXALIAS_SYS_CAST (send, ssize_t,
Packit Service 991b93
                       (int fd, const void *buf, size_t len, int flags));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (send);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef send
Packit aea12f
# define send send_used_without_requesting_gnulib_module_send
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef send
Packit aea12f
# if HAVE_RAW_DECL_SEND
Packit aea12f
_GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module send for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_RECVFROM@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef recvfrom
Packit aea12f
#   define recvfrom rpl_recvfrom
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (recvfrom, ssize_t,
Packit Service 991b93
                  (int fd, void *restrict buf, size_t len, int flags,
Packit Service 991b93
                   struct sockaddr *restrict from,
Packit Service 991b93
                   socklen_t *restrict fromlen)
Packit aea12f
                  _GL_ARG_NONNULL ((2)));
Packit aea12f
_GL_CXXALIAS_RPL (recvfrom, ssize_t,
Packit Service 991b93
                  (int fd, void *restrict buf, size_t len, int flags,
Packit Service 991b93
                   struct sockaddr *restrict from,
Packit Service 991b93
                   socklen_t *restrict fromlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on Solaris 10 systems, the sixth parameter is
Packit aea12f
                                               void *fromlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
Packit Service 991b93
                       (int fd, void *restrict buf, size_t len, int flags,
Packit Service 991b93
                        struct sockaddr *restrict from,
Packit Service 991b93
                        socklen_t *restrict fromlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (recvfrom);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef recvfrom
Packit aea12f
# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef recvfrom
Packit aea12f
# if HAVE_RAW_DECL_RECVFROM
Packit aea12f
_GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module recvfrom for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_SENDTO@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef sendto
Packit aea12f
#   define sendto rpl_sendto
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (sendto, ssize_t,
Packit aea12f
                  (int fd, const void *buf, size_t len, int flags,
Packit aea12f
                   const struct sockaddr *to, socklen_t tolen)
Packit aea12f
                  _GL_ARG_NONNULL ((2)));
Packit aea12f
_GL_CXXALIAS_RPL (sendto, ssize_t,
Packit aea12f
                  (int fd, const void *buf, size_t len, int flags,
Packit aea12f
                   const struct sockaddr *to, socklen_t tolen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on NonStop Kernel, the sixth parameter is
Packit aea12f
                                                   size_t tolen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
Packit aea12f
                       (int fd, const void *buf, size_t len, int flags,
Packit aea12f
                        const struct sockaddr *to, socklen_t tolen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (sendto);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef sendto
Packit aea12f
# define sendto sendto_used_without_requesting_gnulib_module_sendto
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef sendto
Packit aea12f
# if HAVE_RAW_DECL_SENDTO
Packit aea12f
_GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module sendto for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_SETSOCKOPT@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef setsockopt
Packit aea12f
#   define setsockopt rpl_setsockopt
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
Packit aea12f
                                    const void * optval, socklen_t optlen)
Packit aea12f
                                   _GL_ARG_NONNULL ((4)));
Packit aea12f
_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
Packit aea12f
                                    const void * optval, socklen_t optlen));
Packit aea12f
# else
Packit aea12f
/* Need to cast, because on NonStop Kernel, the fifth parameter is
Packit aea12f
                                             size_t optlen.  */
Packit aea12f
_GL_CXXALIAS_SYS_CAST (setsockopt, int,
Packit aea12f
                       (int fd, int level, int optname,
Packit aea12f
                        const void * optval, socklen_t optlen));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (setsockopt);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef setsockopt
Packit aea12f
# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef setsockopt
Packit aea12f
# if HAVE_RAW_DECL_SETSOCKOPT
Packit aea12f
_GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module setsockopt for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_SHUTDOWN@
Packit aea12f
# if @HAVE_WINSOCK2_H@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   undef shutdown
Packit aea12f
#   define shutdown rpl_shutdown
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (shutdown, int, (int fd, int how));
Packit aea12f
_GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
Packit aea12f
# else
Packit aea12f
_GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (shutdown);
Packit aea12f
#elif @HAVE_WINSOCK2_H@
Packit aea12f
# undef shutdown
Packit aea12f
# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef shutdown
Packit aea12f
# if HAVE_RAW_DECL_SHUTDOWN
Packit aea12f
_GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
Packit aea12f
                 "use gnulib module shutdown for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
#if @GNULIB_ACCEPT4@
Packit aea12f
/* Accept a connection on a socket, with specific opening flags.
Packit aea12f
   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
Packit aea12f
   and O_TEXT, O_BINARY (defined in "binary-io.h").
Packit aea12f
   See also the Linux man page at
Packit aea12f
   <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>.  */
Packit aea12f
# if @HAVE_ACCEPT4@
Packit aea12f
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
Packit aea12f
#   define accept4 rpl_accept4
Packit aea12f
#  endif
Packit aea12f
_GL_FUNCDECL_RPL (accept4, int,
Packit aea12f
                  (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
Packit aea12f
                   int flags));
Packit aea12f
_GL_CXXALIAS_RPL (accept4, int,
Packit aea12f
                  (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
Packit aea12f
                   int flags));
Packit aea12f
# else
Packit aea12f
_GL_FUNCDECL_SYS (accept4, int,
Packit aea12f
                  (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
Packit aea12f
                   int flags));
Packit aea12f
_GL_CXXALIAS_SYS (accept4, int,
Packit aea12f
                  (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
Packit aea12f
                   int flags));
Packit aea12f
# endif
Packit aea12f
_GL_CXXALIASWARN (accept4);
Packit aea12f
#elif defined GNULIB_POSIXCHECK
Packit aea12f
# undef accept4
Packit aea12f
# if HAVE_RAW_DECL_ACCEPT4
Packit aea12f
_GL_WARN_ON_USE (accept4, "accept4 is unportable - "
Packit aea12f
                 "use gnulib module accept4 for portability");
Packit aea12f
# endif
Packit aea12f
#endif
Packit aea12f
Packit aea12f
_GL_INLINE_HEADER_END
Packit aea12f
Packit aea12f
#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
Packit aea12f
#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
Packit aea12f
#endif