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