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