Blame lib/sys_socket.in.h

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