(root)/
grep-3.11/
gnulib-tests/
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  _GL_CXXALIASWARN (accept);
     362  #elif @HAVE_WINSOCK2_H@
     363  # undef accept
     364  # define accept accept_used_without_requesting_gnulib_module_accept
     365  #elif defined GNULIB_POSIXCHECK
     366  # undef accept
     367  # if HAVE_RAW_DECL_ACCEPT
     368  _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
     369                   "use gnulib module accept for portability");
     370  # endif
     371  #endif
     372  
     373  #if @GNULIB_BIND@
     374  # if @HAVE_WINSOCK2_H@
     375  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     376  #   undef bind
     377  #   define bind rpl_bind
     378  #  endif
     379  _GL_FUNCDECL_RPL (bind, int,
     380                    (int fd, const struct sockaddr *addr, socklen_t addrlen)
     381                    _GL_ARG_NONNULL ((2)));
     382  _GL_CXXALIAS_RPL (bind, int,
     383                    (int fd, const struct sockaddr *addr, socklen_t addrlen));
     384  # else
     385  /* Need to cast, because on NonStop Kernel, the third parameter is
     386                                                       size_t addrlen.  */
     387  _GL_CXXALIAS_SYS_CAST (bind, int,
     388                         (int fd,
     389                          const struct sockaddr *addr, socklen_t addrlen));
     390  # endif
     391  _GL_CXXALIASWARN (bind);
     392  #elif @HAVE_WINSOCK2_H@
     393  # undef bind
     394  # define bind bind_used_without_requesting_gnulib_module_bind
     395  #elif defined GNULIB_POSIXCHECK
     396  # undef bind
     397  # if HAVE_RAW_DECL_BIND
     398  _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
     399                   "use gnulib module bind for portability");
     400  # endif
     401  #endif
     402  
     403  #if @GNULIB_GETPEERNAME@
     404  # if @HAVE_WINSOCK2_H@
     405  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     406  #   undef getpeername
     407  #   define getpeername rpl_getpeername
     408  #  endif
     409  _GL_FUNCDECL_RPL (getpeername, int,
     410                    (int fd, struct sockaddr *restrict addr,
     411                     socklen_t *restrict addrlen)
     412                    _GL_ARG_NONNULL ((2, 3)));
     413  _GL_CXXALIAS_RPL (getpeername, int,
     414                    (int fd, struct sockaddr *restrict addr,
     415                     socklen_t *restrict addrlen));
     416  # else
     417  /* Need to cast, because on Solaris 10 systems, the third parameter is
     418                          void *addrlen.  */
     419  _GL_CXXALIAS_SYS_CAST (getpeername, int,
     420                         (int fd, struct sockaddr *restrict addr,
     421                          socklen_t *restrict addrlen));
     422  # endif
     423  _GL_CXXALIASWARN (getpeername);
     424  #elif @HAVE_WINSOCK2_H@
     425  # undef getpeername
     426  # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
     427  #elif defined GNULIB_POSIXCHECK
     428  # undef getpeername
     429  # if HAVE_RAW_DECL_GETPEERNAME
     430  _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
     431                   "use gnulib module getpeername for portability");
     432  # endif
     433  #endif
     434  
     435  #if @GNULIB_GETSOCKNAME@
     436  # if @HAVE_WINSOCK2_H@
     437  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     438  #   undef getsockname
     439  #   define getsockname rpl_getsockname
     440  #  endif
     441  _GL_FUNCDECL_RPL (getsockname, int,
     442                    (int fd, struct sockaddr *restrict addr,
     443                     socklen_t *restrict addrlen)
     444                    _GL_ARG_NONNULL ((2, 3)));
     445  _GL_CXXALIAS_RPL (getsockname, int,
     446                    (int fd, struct sockaddr *restrict addr,
     447                     socklen_t *restrict addrlen));
     448  # else
     449  /* Need to cast, because on Solaris 10 systems, the third parameter is
     450                          void *addrlen.  */
     451  _GL_CXXALIAS_SYS_CAST (getsockname, int,
     452                         (int fd, struct sockaddr *restrict addr,
     453                          socklen_t *restrict addrlen));
     454  # endif
     455  _GL_CXXALIASWARN (getsockname);
     456  #elif @HAVE_WINSOCK2_H@
     457  # undef getsockname
     458  # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
     459  #elif defined GNULIB_POSIXCHECK
     460  # undef getsockname
     461  # if HAVE_RAW_DECL_GETSOCKNAME
     462  _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
     463                   "use gnulib module getsockname for portability");
     464  # endif
     465  #endif
     466  
     467  #if @GNULIB_GETSOCKOPT@
     468  # if @HAVE_WINSOCK2_H@
     469  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     470  #   undef getsockopt
     471  #   define getsockopt rpl_getsockopt
     472  #  endif
     473  _GL_FUNCDECL_RPL (getsockopt, int,
     474                    (int fd, int level, int optname,
     475                     void *restrict optval, socklen_t *restrict optlen)
     476                    _GL_ARG_NONNULL ((4, 5)));
     477  _GL_CXXALIAS_RPL (getsockopt, int,
     478                    (int fd, int level, int optname,
     479                     void *restrict optval, socklen_t *restrict optlen));
     480  # else
     481  /* Need to cast, because on Solaris 10 systems, the fifth parameter is
     482                                                         void *optlen.  */
     483  _GL_CXXALIAS_SYS_CAST (getsockopt, int,
     484                         (int fd, int level, int optname,
     485                          void *restrict optval, socklen_t *restrict optlen));
     486  # endif
     487  _GL_CXXALIASWARN (getsockopt);
     488  #elif @HAVE_WINSOCK2_H@
     489  # undef getsockopt
     490  # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
     491  #elif defined GNULIB_POSIXCHECK
     492  # undef getsockopt
     493  # if HAVE_RAW_DECL_GETSOCKOPT
     494  _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
     495                   "use gnulib module getsockopt for portability");
     496  # endif
     497  #endif
     498  
     499  #if @GNULIB_LISTEN@
     500  # if @HAVE_WINSOCK2_H@
     501  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     502  #   undef listen
     503  #   define listen rpl_listen
     504  #  endif
     505  _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog));
     506  _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
     507  # else
     508  _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
     509  # endif
     510  _GL_CXXALIASWARN (listen);
     511  #elif @HAVE_WINSOCK2_H@
     512  # undef listen
     513  # define listen listen_used_without_requesting_gnulib_module_listen
     514  #elif defined GNULIB_POSIXCHECK
     515  # undef listen
     516  # if HAVE_RAW_DECL_LISTEN
     517  _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
     518                   "use gnulib module listen for portability");
     519  # endif
     520  #endif
     521  
     522  #if @GNULIB_RECV@
     523  # if @HAVE_WINSOCK2_H@
     524  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     525  #   undef recv
     526  #   define recv rpl_recv
     527  #  endif
     528  _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
     529                                   _GL_ARG_NONNULL ((2)));
     530  _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
     531  # else
     532  /* Need to cast, because on HP-UX 11.31 the return type may be
     533                               int,
     534     depending on compiler options.  */
     535  _GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
     536  # endif
     537  _GL_CXXALIASWARN (recv);
     538  #elif @HAVE_WINSOCK2_H@
     539  # undef recv
     540  # define recv recv_used_without_requesting_gnulib_module_recv
     541  #elif defined GNULIB_POSIXCHECK
     542  # undef recv
     543  # if HAVE_RAW_DECL_RECV
     544  _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
     545                   "use gnulib module recv for portability");
     546  # endif
     547  #endif
     548  
     549  #if @GNULIB_SEND@
     550  # if @HAVE_WINSOCK2_H@
     551  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     552  #   undef send
     553  #   define send rpl_send
     554  #  endif
     555  _GL_FUNCDECL_RPL (send, ssize_t,
     556                    (int fd, const void *buf, size_t len, int flags)
     557                    _GL_ARG_NONNULL ((2)));
     558  _GL_CXXALIAS_RPL (send, ssize_t,
     559                    (int fd, const void *buf, size_t len, int flags));
     560  # else
     561  /* Need to cast, because on HP-UX 11.31 the return type may be
     562                               int,
     563     depending on compiler options.  */
     564  _GL_CXXALIAS_SYS_CAST (send, ssize_t,
     565                         (int fd, const void *buf, size_t len, int flags));
     566  # endif
     567  _GL_CXXALIASWARN (send);
     568  #elif @HAVE_WINSOCK2_H@
     569  # undef send
     570  # define send send_used_without_requesting_gnulib_module_send
     571  #elif defined GNULIB_POSIXCHECK
     572  # undef send
     573  # if HAVE_RAW_DECL_SEND
     574  _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
     575                   "use gnulib module send for portability");
     576  # endif
     577  #endif
     578  
     579  #if @GNULIB_RECVFROM@
     580  # if @HAVE_WINSOCK2_H@
     581  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     582  #   undef recvfrom
     583  #   define recvfrom rpl_recvfrom
     584  #  endif
     585  _GL_FUNCDECL_RPL (recvfrom, ssize_t,
     586                    (int fd, void *restrict buf, size_t len, int flags,
     587                     struct sockaddr *restrict from,
     588                     socklen_t *restrict fromlen)
     589                    _GL_ARG_NONNULL ((2)));
     590  _GL_CXXALIAS_RPL (recvfrom, ssize_t,
     591                    (int fd, void *restrict buf, size_t len, int flags,
     592                     struct sockaddr *restrict from,
     593                     socklen_t *restrict fromlen));
     594  # else
     595  /* Need to cast, because on Solaris 10 systems, the sixth parameter is
     596                                                 void *fromlen.  */
     597  _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
     598                         (int fd, void *restrict buf, size_t len, int flags,
     599                          struct sockaddr *restrict from,
     600                          socklen_t *restrict fromlen));
     601  # endif
     602  _GL_CXXALIASWARN (recvfrom);
     603  #elif @HAVE_WINSOCK2_H@
     604  # undef recvfrom
     605  # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
     606  #elif defined GNULIB_POSIXCHECK
     607  # undef recvfrom
     608  # if HAVE_RAW_DECL_RECVFROM
     609  _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
     610                   "use gnulib module recvfrom for portability");
     611  # endif
     612  #endif
     613  
     614  #if @GNULIB_SENDTO@
     615  # if @HAVE_WINSOCK2_H@
     616  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     617  #   undef sendto
     618  #   define sendto rpl_sendto
     619  #  endif
     620  _GL_FUNCDECL_RPL (sendto, ssize_t,
     621                    (int fd, const void *buf, size_t len, int flags,
     622                     const struct sockaddr *to, socklen_t tolen)
     623                    _GL_ARG_NONNULL ((2)));
     624  _GL_CXXALIAS_RPL (sendto, ssize_t,
     625                    (int fd, const void *buf, size_t len, int flags,
     626                     const struct sockaddr *to, socklen_t tolen));
     627  # else
     628  /* Need to cast, because on NonStop Kernel, the sixth parameter is
     629                                                     size_t tolen.  */
     630  _GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
     631                         (int fd, const void *buf, size_t len, int flags,
     632                          const struct sockaddr *to, socklen_t tolen));
     633  # endif
     634  _GL_CXXALIASWARN (sendto);
     635  #elif @HAVE_WINSOCK2_H@
     636  # undef sendto
     637  # define sendto sendto_used_without_requesting_gnulib_module_sendto
     638  #elif defined GNULIB_POSIXCHECK
     639  # undef sendto
     640  # if HAVE_RAW_DECL_SENDTO
     641  _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
     642                   "use gnulib module sendto for portability");
     643  # endif
     644  #endif
     645  
     646  #if @GNULIB_SETSOCKOPT@
     647  # if @HAVE_WINSOCK2_H@
     648  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     649  #   undef setsockopt
     650  #   define setsockopt rpl_setsockopt
     651  #  endif
     652  _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
     653                                      const void * optval, socklen_t optlen)
     654                                     _GL_ARG_NONNULL ((4)));
     655  _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
     656                                      const void * optval, socklen_t optlen));
     657  # else
     658  /* Need to cast, because on NonStop Kernel, the fifth parameter is
     659                                               size_t optlen.  */
     660  _GL_CXXALIAS_SYS_CAST (setsockopt, int,
     661                         (int fd, int level, int optname,
     662                          const void * optval, socklen_t optlen));
     663  # endif
     664  _GL_CXXALIASWARN (setsockopt);
     665  #elif @HAVE_WINSOCK2_H@
     666  # undef setsockopt
     667  # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
     668  #elif defined GNULIB_POSIXCHECK
     669  # undef setsockopt
     670  # if HAVE_RAW_DECL_SETSOCKOPT
     671  _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
     672                   "use gnulib module setsockopt for portability");
     673  # endif
     674  #endif
     675  
     676  #if @GNULIB_SHUTDOWN@
     677  # if @HAVE_WINSOCK2_H@
     678  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     679  #   undef shutdown
     680  #   define shutdown rpl_shutdown
     681  #  endif
     682  _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how));
     683  _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
     684  # else
     685  _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
     686  # endif
     687  _GL_CXXALIASWARN (shutdown);
     688  #elif @HAVE_WINSOCK2_H@
     689  # undef shutdown
     690  # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
     691  #elif defined GNULIB_POSIXCHECK
     692  # undef shutdown
     693  # if HAVE_RAW_DECL_SHUTDOWN
     694  _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
     695                   "use gnulib module shutdown for portability");
     696  # endif
     697  #endif
     698  
     699  #if @GNULIB_ACCEPT4@
     700  /* Accept a connection on a socket, with specific opening flags.
     701     The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
     702     and O_TEXT, O_BINARY (defined in "binary-io.h").
     703     See also the Linux man page at
     704     <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>.  */
     705  # if @HAVE_ACCEPT4@
     706  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     707  #   define accept4 rpl_accept4
     708  #  endif
     709  _GL_FUNCDECL_RPL (accept4, int,
     710                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     711                     int flags));
     712  _GL_CXXALIAS_RPL (accept4, int,
     713                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     714                     int flags));
     715  # else
     716  _GL_FUNCDECL_SYS (accept4, int,
     717                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     718                     int flags));
     719  _GL_CXXALIAS_SYS (accept4, int,
     720                    (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
     721                     int flags));
     722  # endif
     723  _GL_CXXALIASWARN (accept4);
     724  #elif defined GNULIB_POSIXCHECK
     725  # undef accept4
     726  # if HAVE_RAW_DECL_ACCEPT4
     727  _GL_WARN_ON_USE (accept4, "accept4 is unportable - "
     728                   "use gnulib module accept4 for portability");
     729  # endif
     730  #endif
     731  
     732  _GL_INLINE_HEADER_END
     733  
     734  #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
     735  #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
     736  #endif