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