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