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