(root)/
gettext-0.22.4/
libtextstyle/
lib/
sys_socket.in.h
       1  /* Provide a sys/socket header file for systems lacking it (read: MinGW)
       2     and for systems where it is incomplete.
       3     Copyright (C) 2005-2023 Free Software Foundation, Inc.
       4     Written by Simon Josefsson.
       5  
       6     This file is free software: you can redistribute it and/or modify
       7     it under the terms of the GNU Lesser General Public License as
       8     published by the Free Software Foundation; either version 2.1 of the
       9     License, or (at your option) any later version.
      10  
      11     This file is distributed in the hope that it will be useful,
      12     but WITHOUT ANY WARRANTY; without even the implied warranty of
      13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14     GNU Lesser General Public License for more details.
      15  
      16     You should have received a copy of the GNU Lesser General Public License
      17     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      18  
      19  /* This file is supposed to be used on platforms that lack <sys/socket.h>,
      20     on platforms where <sys/socket.h> cannot be included standalone, and on
      21     platforms where <sys/socket.h> does not provide all necessary definitions.
      22     It is intended to provide definitions and prototypes needed by an
      23     application.  */
      24  
      25  #if __GNUC__ >= 3
      26  @PRAGMA_SYSTEM_HEADER@
      27  #endif
      28  @PRAGMA_COLUMNS@
      29  
      30  #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H
      31  /* Special invocation convention:
      32     - On Cygwin 1.5.x we have a sequence of nested includes
      33       <sys/socket.h> -> <cygwin/socket.h> -> <asm/socket.h> -> <cygwin/if.h>,
      34       and the latter includes <sys/socket.h>.  In this situation, the functions
      35       are not yet declared, therefore we cannot provide the C++ aliases.  */
      36  
      37  #@INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
      38  
      39  #else
      40  /* Normal invocation convention.  */
      41  
      42  #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
      43  
      44  #if @HAVE_SYS_SOCKET_H@
      45  
      46  # define _GL_ALREADY_INCLUDING_SYS_SOCKET_H
      47  
      48  /* On many platforms, <sys/socket.h> assumes prior inclusion of
      49     <sys/types.h>.  */
      50  # include <sys/types.h>
      51  
      52  /* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL
      53     is defined.  */
      54  # include <stddef.h>
      55  
      56  /* The include_next requires a split double-inclusion guard.  */
      57  # @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
      58  
      59  # undef _GL_ALREADY_INCLUDING_SYS_SOCKET_H
      60  
      61  #endif
      62  
      63  #ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
      64  #define _@GUARD_PREFIX@_SYS_SOCKET_H
      65  
      66  /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, GNULIB_POSIXCHECK,
      67     HAVE_RAW_DECL_*, alignof.  */
      68  #if !_GL_CONFIG_H_INCLUDED
      69   #error "Please include config.h first."
      70  #endif
      71  
      72  _GL_INLINE_HEADER_BEGIN
      73  #ifndef _GL_SYS_SOCKET_INLINE
      74  # define _GL_SYS_SOCKET_INLINE _GL_INLINE
      75  #endif
      76  
      77  /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
      78  
      79  /* The definition of _GL_ARG_NONNULL is copied here.  */
      80  
      81  /* The definition of _GL_WARN_ON_USE is copied here.  */
      82  
      83  #if !@HAVE_SA_FAMILY_T@
      84  # if !GNULIB_defined_sa_family_t
      85  /* On OS/2 kLIBC, sa_family_t is unsigned char unless TCPV40HDRS is defined. */
      86  #  if !defined __KLIBC__ || defined TCPV40HDRS
      87  typedef unsigned short  sa_family_t;
      88  #  else
      89  typedef unsigned char   sa_family_t;
      90  #  endif
      91  #  define GNULIB_defined_sa_family_t 1
      92  # endif
      93  #endif
      94  
      95  #if @HAVE_STRUCT_SOCKADDR_STORAGE@
      96  /* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1.  */
      97  # if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@
      98  #  ifndef ss_family
      99  #   define ss_family __ss_family
     100  #  endif
     101  # endif
     102  #else
     103  /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
     104     2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
     105  # define __ss_aligntype unsigned long int
     106  # define _SS_SIZE 256
     107  # define _SS_PADSIZE \
     108      (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype)      \
     109                    ? sizeof (sa_family_t)                                \
     110                    : alignof (__ss_aligntype))                           \
     111                   + sizeof (__ss_aligntype)))
     112  
     113  # if !GNULIB_defined_struct_sockaddr_storage
     114  struct sockaddr_storage
     115  {
     116    sa_family_t ss_family;      /* Address family, etc.  */
     117    __ss_aligntype __ss_align;  /* Force desired alignment.  */
     118    char __ss_padding[_SS_PADSIZE];
     119  };
     120  #  define GNULIB_defined_struct_sockaddr_storage 1
     121  # endif
     122  
     123  #endif
     124  
     125  /* Get struct iovec.  */
     126  /* But avoid namespace pollution on glibc systems.  */
     127  #if ! defined __GLIBC__
     128  # include <sys/uio.h>
     129  #endif
     130  
     131  #if @HAVE_SYS_SOCKET_H@
     132  
     133  /* A platform that has <sys/socket.h>.  */
     134  
     135  /* For shutdown().  */
     136  # if !defined SHUT_RD
     137  #  define SHUT_RD 0
     138  # endif
     139  # if !defined SHUT_WR
     140  #  define SHUT_WR 1
     141  # endif
     142  # if !defined SHUT_RDWR
     143  #  define SHUT_RDWR 2
     144  # endif
     145  
     146  # ifdef __VMS                        /* OpenVMS */
     147  #  ifndef CMSG_SPACE
     148  #   define CMSG_SPACE(length) _CMSG_SPACE(length)
     149  #  endif
     150  #  ifndef CMSG_LEN
     151  #   define CMSG_LEN(length) _CMSG_LEN(length)
     152  #  endif
     153  # endif
     154  
     155  #else
     156  
     157  # ifdef __CYGWIN__
     158  #  error "Cygwin does have a sys/socket.h, doesn't it?!?"
     159  # endif
     160  
     161  /* A platform that lacks <sys/socket.h>.
     162  
     163     Currently only MinGW is supported.  See the gnulib manual regarding
     164     Windows sockets.  MinGW has the header files winsock2.h and
     165     ws2tcpip.h that declare the sys/socket.h definitions we need.  Note
     166     that you can influence which definitions you get by setting the
     167     WINVER symbol before including these two files.  For example,
     168     getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
     169     symbol is set indirectly through WINVER).  You can set this by
     170     adding AC_DEFINE(WINVER, 0x0501) to configure.ac.  Note that your
     171     code may not run on older Windows releases then.  My Windows 2000
     172     box was not able to run the code, for example.  The situation is
     173     slightly confusing because
     174     <https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
     175     suggests that getaddrinfo should be available on all Windows
     176     releases. */
     177  
     178  # if @HAVE_WINSOCK2_H@
     179  #  include <winsock2.h>
     180  # endif
     181  # if @HAVE_WS2TCPIP_H@
     182  #  include <ws2tcpip.h>
     183  # endif
     184  
     185  /* For shutdown(). */
     186  # if !defined SHUT_RD && defined SD_RECEIVE
     187  #  define SHUT_RD SD_RECEIVE
     188  # endif
     189  # if !defined SHUT_WR && defined SD_SEND
     190  #  define SHUT_WR SD_SEND
     191  # endif
     192  # if !defined SHUT_RDWR && defined SD_BOTH
     193  #  define SHUT_RDWR SD_BOTH
     194  # endif
     195  
     196  # if @HAVE_WINSOCK2_H@
     197  /* Include headers needed by the emulation code.  */
     198  #  include <sys/types.h>
     199  #  include <io.h>
     200  /* If these headers don't define socklen_t, <config.h> does.  */
     201  # endif
     202  
     203  /* Rudimentary 'struct msghdr'; this works as long as you don't try to
     204     access msg_control or msg_controllen.  */
     205  struct msghdr {
     206    void *msg_name;
     207    socklen_t msg_namelen;
     208    struct iovec *msg_iov;
     209    int msg_iovlen;
     210    int msg_flags;
     211  };
     212  
     213  #endif
     214  
     215  /* Ensure SO_REUSEPORT is defined.  */
     216  /* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
     217     https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
     218     and https://lwn.net/Articles/542629/
     219   */
     220  #ifndef SO_REUSEPORT
     221  # define SO_REUSEPORT SO_REUSEADDR
     222  #endif
     223  
     224  /* Fix some definitions from <winsock2.h>.  */
     225  
     226  #if @HAVE_WINSOCK2_H@
     227  
     228  # if !GNULIB_defined_rpl_fd_isset
     229  
     230  /* Re-define FD_ISSET to avoid a WSA call while we are not using
     231     network sockets.  */
     232  _GL_SYS_SOCKET_INLINE int
     233  rpl_fd_isset (SOCKET fd, fd_set * set)
     234  {
     235    u_int i;
     236    if (set == NULL)
     237      return 0;
     238  
     239    for (i = 0; i < set->fd_count; i++)
     240      if (set->fd_array[i] == fd)
     241        return 1;
     242  
     243    return 0;
     244  }
     245  
     246  #  define GNULIB_defined_rpl_fd_isset 1
     247  # endif
     248  
     249  # undef FD_ISSET
     250  # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
     251  
     252  #endif
     253  
     254  /* Hide some function declarations from <winsock2.h>.  */
     255  
     256  #if @HAVE_WINSOCK2_H@
     257  # if !defined _@GUARD_PREFIX@_UNISTD_H
     258  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     259  #   undef close
     260  #   define close close_used_without_including_unistd_h
     261  #  elif !defined __clang__
     262      _GL_WARN_ON_USE (close,
     263                       "close() used without including <unistd.h>");
     264  #  endif
     265  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     266  #   undef gethostname
     267  #   define gethostname gethostname_used_without_including_unistd_h
     268  #  else
     269      _GL_WARN_ON_USE (gethostname,
     270                       "gethostname() used without including <unistd.h>");
     271  #  endif
     272  # endif
     273  # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
     274  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     275  #   undef select
     276  #   define select select_used_without_including_sys_select_h
     277  #  else
     278      _GL_WARN_ON_USE (select,
     279                       "select() used without including <sys/select.h>");
     280  #  endif
     281  # endif
     282  #endif
     283  
     284  /* Wrap everything else to use libc file descriptors for sockets.  */
     285  
     286  #if @GNULIB_SOCKET@
     287  # if @HAVE_WINSOCK2_H@
     288  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     289  #   undef socket
     290  #   define socket rpl_socket
     291  #  endif
     292  _GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol));
     293  _GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol));
     294  # else
     295  _GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol));
     296  # endif
     297  _GL_CXXALIASWARN (socket);
     298  #elif @HAVE_WINSOCK2_H@
     299  # undef socket
     300  # define socket socket_used_without_requesting_gnulib_module_socket
     301  #elif defined GNULIB_POSIXCHECK
     302  # undef socket
     303  # if HAVE_RAW_DECL_SOCKET
     304  _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
     305                   "use gnulib module socket for portability");
     306  # endif
     307  #endif
     308  
     309  #if @GNULIB_CONNECT@
     310  # if @HAVE_WINSOCK2_H@
     311  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     312  #   undef connect
     313  #   define connect rpl_connect
     314  #  endif
     315  _GL_FUNCDECL_RPL (connect, int,
     316                    (int fd, const struct sockaddr *addr, socklen_t addrlen)
     317                    _GL_ARG_NONNULL ((2)));
     318  _GL_CXXALIAS_RPL (connect, int,
     319                    (int fd, const struct sockaddr *addr, socklen_t addrlen));
     320  # else
     321  /* Need to cast, because on NonStop Kernel, the third parameter is
     322                                                       size_t addrlen.  */
     323  _GL_CXXALIAS_SYS_CAST (connect, int,
     324                         (int fd,
     325                          const struct sockaddr *addr, socklen_t addrlen));
     326  # endif
     327  _GL_CXXALIASWARN (connect);
     328  #elif @HAVE_WINSOCK2_H@
     329  # undef connect
     330  # define connect socket_used_without_requesting_gnulib_module_connect
     331  #elif defined GNULIB_POSIXCHECK
     332  # undef connect
     333  # if HAVE_RAW_DECL_CONNECT
     334  _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
     335                   "use gnulib module connect for portability");
     336  # endif
     337  #endif
     338  
     339  #if @GNULIB_ACCEPT@
     340  # if @HAVE_WINSOCK2_H@
     341  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     342  #   undef accept
     343  #   define accept rpl_accept
     344  #  endif
     345  _GL_FUNCDECL_RPL (accept, int,
     346                    (int fd,
     347                     struct sockaddr *restrict addr,
     348                     socklen_t *restrict addrlen));
     349  _GL_CXXALIAS_RPL (accept, int,
     350                    (int fd,
     351                     struct sockaddr *restrict addr,
     352                     socklen_t *restrict addrlen));
     353  # else
     354  /* Need to cast, because on Solaris 10 systems, the third parameter is
     355                          void *addrlen.  */
     356  _GL_CXXALIAS_SYS_CAST (accept, int,
     357                         (int fd,
     358                          struct sockaddr *restrict addr,
     359                          socklen_t *restrict addrlen));
     360  # endif
     361  # if __GLIBC__ >= 2
     362  _GL_CXXALIASWARN (accept);
     363  # endif
     364  #elif @HAVE_WINSOCK2_H@
     365  # undef accept
     366  # define accept accept_used_without_requesting_gnulib_module_accept
     367  #elif defined GNULIB_POSIXCHECK
     368  # undef accept
     369  # if HAVE_RAW_DECL_ACCEPT
     370  _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
     371                   "use gnulib module accept for portability");
     372  # endif
     373  #endif
     374  
     375  #if @GNULIB_BIND@
     376  # if @HAVE_WINSOCK2_H@
     377  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     378  #   undef bind
     379  #   define bind rpl_bind
     380  #  endif
     381  _GL_FUNCDECL_RPL (bind, int,
     382                    (int fd, const struct sockaddr *addr, socklen_t addrlen)
     383                    _GL_ARG_NONNULL ((2)));
     384  _GL_CXXALIAS_RPL (bind, int,
     385                    (int fd, const struct sockaddr *addr, socklen_t addrlen));
     386  # else
     387  /* Need to cast, because on NonStop Kernel, the third parameter is
     388                                                       size_t addrlen.  */
     389  _GL_CXXALIAS_SYS_CAST (bind, int,
     390                         (int fd,
     391                          const struct sockaddr *addr, socklen_t addrlen));
     392  # endif
     393  _GL_CXXALIASWARN (bind);
     394  #elif @HAVE_WINSOCK2_H@
     395  # undef bind
     396  # define bind bind_used_without_requesting_gnulib_module_bind
     397  #elif defined GNULIB_POSIXCHECK
     398  # undef bind
     399  # if HAVE_RAW_DECL_BIND
     400  _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
     401                   "use gnulib module bind for portability");
     402  # endif
     403  #endif
     404  
     405  #if @GNULIB_GETPEERNAME@
     406  # if @HAVE_WINSOCK2_H@
     407  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     408  #   undef getpeername
     409  #   define getpeername rpl_getpeername
     410  #  endif
     411  _GL_FUNCDECL_RPL (getpeername, int,
     412                    (int fd, struct sockaddr *restrict addr,
     413                     socklen_t *restrict addrlen)
     414                    _GL_ARG_NONNULL ((2, 3)));
     415  _GL_CXXALIAS_RPL (getpeername, int,
     416                    (int fd, struct sockaddr *restrict addr,
     417                     socklen_t *restrict addrlen));
     418  # else
     419  /* Need to cast, because on Solaris 10 systems, the third parameter is
     420                          void *addrlen.  */
     421  _GL_CXXALIAS_SYS_CAST (getpeername, int,
     422                         (int fd, struct sockaddr *restrict addr,
     423                          socklen_t *restrict addrlen));
     424  # endif
     425  # if __GLIBC__ >= 2
     426  _GL_CXXALIASWARN (getpeername);
     427  # endif
     428  #elif @HAVE_WINSOCK2_H@
     429  # undef getpeername
     430  # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
     431  #elif defined GNULIB_POSIXCHECK
     432  # undef getpeername
     433  # if HAVE_RAW_DECL_GETPEERNAME
     434  _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
     435                   "use gnulib module getpeername for portability");
     436  # endif
     437  #endif
     438  
     439  #if @GNULIB_GETSOCKNAME@
     440  # if @HAVE_WINSOCK2_H@
     441  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     442  #   undef getsockname
     443  #   define getsockname rpl_getsockname
     444  #  endif
     445  _GL_FUNCDECL_RPL (getsockname, int,
     446                    (int fd, struct sockaddr *restrict addr,
     447                     socklen_t *restrict addrlen)
     448                    _GL_ARG_NONNULL ((2, 3)));
     449  _GL_CXXALIAS_RPL (getsockname, int,
     450                    (int fd, struct sockaddr *restrict addr,
     451                     socklen_t *restrict addrlen));
     452  # else
     453  /* Need to cast, because on Solaris 10 systems, the third parameter is
     454                          void *addrlen.  */
     455  _GL_CXXALIAS_SYS_CAST (getsockname, int,
     456                         (int fd, struct sockaddr *restrict addr,
     457                          socklen_t *restrict addrlen));
     458  # endif
     459  # if __GLIBC__ >= 2
     460  _GL_CXXALIASWARN (getsockname);
     461  # endif
     462  #elif @HAVE_WINSOCK2_H@
     463  # undef getsockname
     464  # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
     465  #elif defined GNULIB_POSIXCHECK
     466  # undef getsockname
     467  # if HAVE_RAW_DECL_GETSOCKNAME
     468  _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
     469                   "use gnulib module getsockname for portability");
     470  # endif
     471  #endif
     472  
     473  #if @GNULIB_GETSOCKOPT@
     474  # if @HAVE_WINSOCK2_H@
     475  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     476  #   undef getsockopt
     477  #   define getsockopt rpl_getsockopt
     478  #  endif
     479  _GL_FUNCDECL_RPL (getsockopt, int,
     480                    (int fd, int level, int optname,
     481                     void *restrict optval, socklen_t *restrict optlen)
     482                    _GL_ARG_NONNULL ((4, 5)));
     483  _GL_CXXALIAS_RPL (getsockopt, int,
     484                    (int fd, int level, int optname,
     485                     void *restrict optval, socklen_t *restrict optlen));
     486  # else
     487  /* Need to cast, because on Solaris 10 systems, the fifth parameter is
     488                                                         void *optlen.  */
     489  _GL_CXXALIAS_SYS_CAST (getsockopt, int,
     490                         (int fd, int level, int optname,
     491                          void *restrict optval, socklen_t *restrict optlen));
     492  # endif
     493  _GL_CXXALIASWARN (getsockopt);
     494  #elif @HAVE_WINSOCK2_H@
     495  # undef getsockopt
     496  # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
     497  #elif defined GNULIB_POSIXCHECK
     498  # undef getsockopt
     499  # if HAVE_RAW_DECL_GETSOCKOPT
     500  _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
     501                   "use gnulib module getsockopt for portability");
     502  # endif
     503  #endif
     504  
     505  #if @GNULIB_LISTEN@
     506  # if @HAVE_WINSOCK2_H@
     507  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     508  #   undef listen
     509  #   define listen rpl_listen
     510  #  endif
     511  _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog));
     512  _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
     513  # else
     514  _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
     515  # endif
     516  _GL_CXXALIASWARN (listen);
     517  #elif @HAVE_WINSOCK2_H@
     518  # undef listen
     519  # define listen listen_used_without_requesting_gnulib_module_listen
     520  #elif defined GNULIB_POSIXCHECK
     521  # undef listen
     522  # if HAVE_RAW_DECL_LISTEN
     523  _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
     524                   "use gnulib module listen for portability");
     525  # endif
     526  #endif
     527  
     528  #if @GNULIB_RECV@
     529  # if @HAVE_WINSOCK2_H@
     530  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     531  #   undef recv
     532  #   define recv rpl_recv
     533  #  endif
     534  _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
     535                                   _GL_ARG_NONNULL ((2)));
     536  _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
     537  # else
     538  /* Need to cast, because on HP-UX 11.31 the return type may be
     539                               int,
     540     depending on compiler options.  */
     541  _GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
     542  # endif
     543  _GL_CXXALIASWARN (recv);
     544  #elif @HAVE_WINSOCK2_H@
     545  # undef recv
     546  # define recv recv_used_without_requesting_gnulib_module_recv
     547  #elif defined GNULIB_POSIXCHECK
     548  # undef recv
     549  # if HAVE_RAW_DECL_RECV
     550  _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
     551                   "use gnulib module recv for portability");
     552  # endif
     553  #endif
     554  
     555  #if @GNULIB_SEND@
     556  # if @HAVE_WINSOCK2_H@
     557  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     558  #   undef send
     559  #   define send rpl_send
     560  #  endif
     561  _GL_FUNCDECL_RPL (send, ssize_t,
     562                    (int fd, const void *buf, size_t len, int flags)
     563                    _GL_ARG_NONNULL ((2)));
     564  _GL_CXXALIAS_RPL (send, ssize_t,
     565                    (int fd, const void *buf, size_t len, int flags));
     566  # else
     567  /* Need to cast, because on HP-UX 11.31 the return type may be
     568                               int,
     569     depending on compiler options.  */
     570  _GL_CXXALIAS_SYS_CAST (send, ssize_t,
     571                         (int fd, const void *buf, size_t len, int flags));
     572  # endif
     573  _GL_CXXALIASWARN (send);
     574  #elif @HAVE_WINSOCK2_H@
     575  # undef send
     576  # define send send_used_without_requesting_gnulib_module_send
     577  #elif defined GNULIB_POSIXCHECK
     578  # undef send
     579  # if HAVE_RAW_DECL_SEND
     580  _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
     581                   "use gnulib module send for portability");
     582  # endif
     583  #endif
     584  
     585  #if @GNULIB_RECVFROM@
     586  # if @HAVE_WINSOCK2_H@
     587  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     588  #   undef recvfrom
     589  #   define recvfrom rpl_recvfrom
     590  #  endif
     591  _GL_FUNCDECL_RPL (recvfrom, ssize_t,
     592                    (int fd, void *restrict buf, size_t len, int flags,
     593                     struct sockaddr *restrict from,
     594                     socklen_t *restrict fromlen)
     595                    _GL_ARG_NONNULL ((2)));
     596  _GL_CXXALIAS_RPL (recvfrom, ssize_t,
     597                    (int fd, void *restrict buf, size_t len, int flags,
     598                     struct sockaddr *restrict from,
     599                     socklen_t *restrict fromlen));
     600  # else
     601  /* Need to cast, because on Solaris 10 systems, the sixth parameter is
     602                                                 void *fromlen.  */
     603  _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
     604                         (int fd, void *restrict buf, size_t len, int flags,
     605                          struct sockaddr *restrict from,
     606                          socklen_t *restrict fromlen));
     607  # endif
     608  # if __GLIBC__ >= 2
     609  _GL_CXXALIASWARN (recvfrom);
     610  # endif
     611  #elif @HAVE_WINSOCK2_H@
     612  # undef recvfrom
     613  # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
     614  #elif defined GNULIB_POSIXCHECK
     615  # undef recvfrom
     616  # if HAVE_RAW_DECL_RECVFROM
     617  _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
     618                   "use gnulib module recvfrom for portability");
     619  # endif
     620  #endif
     621  
     622  #if @GNULIB_SENDTO@
     623  # if @HAVE_WINSOCK2_H@
     624  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     625  #   undef sendto
     626  #   define sendto rpl_sendto
     627  #  endif
     628  _GL_FUNCDECL_RPL (sendto, ssize_t,
     629                    (int fd, const void *buf, size_t len, int flags,
     630                     const struct sockaddr *to, socklen_t tolen)
     631                    _GL_ARG_NONNULL ((2)));
     632  _GL_CXXALIAS_RPL (sendto, ssize_t,
     633                    (int fd, const void *buf, size_t len, int flags,
     634                     const struct sockaddr *to, socklen_t tolen));
     635  # else
     636  /* Need to cast, because on NonStop Kernel, the sixth parameter is
     637                                                     size_t tolen.  */
     638  _GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
     639                         (int fd, const void *buf, size_t len, int flags,
     640                          const struct sockaddr *to, socklen_t tolen));
     641  # endif
     642  _GL_CXXALIASWARN (sendto);
     643  #elif @HAVE_WINSOCK2_H@
     644  # undef sendto
     645  # define sendto sendto_used_without_requesting_gnulib_module_sendto
     646  #elif defined GNULIB_POSIXCHECK
     647  # undef sendto
     648  # if HAVE_RAW_DECL_SENDTO
     649  _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
     650                   "use gnulib module sendto for portability");
     651  # endif
     652  #endif
     653  
     654  #if @GNULIB_SETSOCKOPT@
     655  # if @HAVE_WINSOCK2_H@
     656  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     657  #   undef setsockopt
     658  #   define setsockopt rpl_setsockopt
     659  #  endif
     660  _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
     661                                      const void * optval, socklen_t optlen)
     662                                     _GL_ARG_NONNULL ((4)));
     663  _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
     664                                      const void * optval, socklen_t optlen));
     665  # else
     666  /* Need to cast, because on NonStop Kernel, the fifth parameter is
     667                                               size_t optlen.  */
     668  _GL_CXXALIAS_SYS_CAST (setsockopt, int,
     669                         (int fd, int level, int optname,
     670                          const void * optval, socklen_t optlen));
     671  # endif
     672  _GL_CXXALIASWARN (setsockopt);
     673  #elif @HAVE_WINSOCK2_H@
     674  # undef setsockopt
     675  # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
     676  #elif defined GNULIB_POSIXCHECK
     677  # undef setsockopt
     678  # if HAVE_RAW_DECL_SETSOCKOPT
     679  _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
     680                   "use gnulib module setsockopt for portability");
     681  # endif
     682  #endif
     683  
     684  #if @GNULIB_SHUTDOWN@
     685  # if @HAVE_WINSOCK2_H@
     686  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     687  #   undef shutdown
     688  #   define shutdown rpl_shutdown
     689  #  endif
     690  _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how));
     691  _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
     692  # else
     693  _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
     694  # endif
     695  _GL_CXXALIASWARN (shutdown);
     696  #elif @HAVE_WINSOCK2_H@
     697  # undef shutdown
     698  # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
     699  #elif defined GNULIB_POSIXCHECK
     700  # undef shutdown
     701  # if HAVE_RAW_DECL_SHUTDOWN
     702  _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
     703                   "use gnulib module shutdown for portability");
     704  # endif
     705  #endif
     706  
     707  #if @GNULIB_ACCEPT4@
     708  /* Accept a connection on a socket, with specific opening flags.
     709     The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
     710     and O_TEXT, O_BINARY (defined in "binary-io.h").
     711     See also the Linux man page at
     712     <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>.  */
     713  # if @HAVE_ACCEPT4@
     714  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     715  #   define accept4 rpl_accept4
     716  #  endif
     717  _GL_FUNCDECL_RPL (accept4, int,
     718                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     719                     int flags));
     720  _GL_CXXALIAS_RPL (accept4, int,
     721                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     722                     int flags));
     723  # else
     724  _GL_FUNCDECL_SYS (accept4, int,
     725                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     726                     int flags));
     727  _GL_CXXALIAS_SYS (accept4, int,
     728                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     729                     int flags));
     730  # endif
     731  _GL_CXXALIASWARN (accept4);
     732  #elif defined GNULIB_POSIXCHECK
     733  # undef accept4
     734  # if HAVE_RAW_DECL_ACCEPT4
     735  _GL_WARN_ON_USE (accept4, "accept4 is unportable - "
     736                   "use gnulib module accept4 for portability");
     737  # endif
     738  #endif
     739  
     740  _GL_INLINE_HEADER_END
     741  
     742  #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
     743  #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
     744  #endif