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