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