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