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