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