gnulib: update to 776af40e0
[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.
9c9d63b1 3 Copyright (C) 2005-2021 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>
698be2d8 198/* If these headers don't define socklen_t, <config.h> does. */
725e2999
JB
199# endif
200
201/* Rudimentary 'struct msghdr'; this works as long as you don't try to
202 access msg_control or msg_controllen. */
203struct msghdr {
204 void *msg_name;
205 socklen_t msg_namelen;
206 struct iovec *msg_iov;
207 int msg_iovlen;
208 int msg_flags;
209};
210
211#endif
212
c0c3707f
CB
213/* Ensure SO_REUSEPORT is defined. */
214/* For the subtle differences between SO_REUSEPORT and SO_REUSEADDR, see
215 https://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t
216 and https://lwn.net/Articles/542629/
217 */
218#ifndef SO_REUSEPORT
219# define SO_REUSEPORT SO_REUSEADDR
220#endif
221
725e2999
JB
222/* Fix some definitions from <winsock2.h>. */
223
224#if @HAVE_WINSOCK2_H@
225
226# if !GNULIB_defined_rpl_fd_isset
227
228/* Re-define FD_ISSET to avoid a WSA call while we are not using
229 network sockets. */
230_GL_SYS_SOCKET_INLINE int
231rpl_fd_isset (SOCKET fd, fd_set * set)
232{
233 u_int i;
234 if (set == NULL)
235 return 0;
236
237 for (i = 0; i < set->fd_count; i++)
238 if (set->fd_array[i] == fd)
239 return 1;
240
241 return 0;
242}
243
244# define GNULIB_defined_rpl_fd_isset 1
245# endif
246
247# undef FD_ISSET
248# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
249
250#endif
251
252/* Hide some function declarations from <winsock2.h>. */
253
254#if @HAVE_WINSOCK2_H@
255# if !defined _@GUARD_PREFIX@_UNISTD_H
256# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
257# undef close
258# define close close_used_without_including_unistd_h
9c9d63b1 259# elif !defined __clang__
725e2999
JB
260 _GL_WARN_ON_USE (close,
261 "close() used without including <unistd.h>");
262# endif
263# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
264# undef gethostname
265# define gethostname gethostname_used_without_including_unistd_h
266# else
267 _GL_WARN_ON_USE (gethostname,
268 "gethostname() used without including <unistd.h>");
269# endif
270# endif
271# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
272# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273# undef select
274# define select select_used_without_including_sys_select_h
275# else
276 _GL_WARN_ON_USE (select,
277 "select() used without including <sys/select.h>");
278# endif
279# endif
280#endif
281
282/* Wrap everything else to use libc file descriptors for sockets. */
283
284#if @GNULIB_SOCKET@
285# if @HAVE_WINSOCK2_H@
286# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
287# undef socket
288# define socket rpl_socket
289# endif
290_GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol));
291_GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol));
292# else
293_GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol));
294# endif
295_GL_CXXALIASWARN (socket);
296#elif @HAVE_WINSOCK2_H@
297# undef socket
298# define socket socket_used_without_requesting_gnulib_module_socket
299#elif defined GNULIB_POSIXCHECK
300# undef socket
301# if HAVE_RAW_DECL_SOCKET
302_GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
303 "use gnulib module socket for portability");
304# endif
305#endif
306
307#if @GNULIB_CONNECT@
308# if @HAVE_WINSOCK2_H@
309# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
310# undef connect
311# define connect rpl_connect
312# endif
313_GL_FUNCDECL_RPL (connect, int,
314 (int fd, const struct sockaddr *addr, socklen_t addrlen)
315 _GL_ARG_NONNULL ((2)));
316_GL_CXXALIAS_RPL (connect, int,
317 (int fd, const struct sockaddr *addr, socklen_t addrlen));
318# else
319/* Need to cast, because on NonStop Kernel, the third parameter is
320 size_t addrlen. */
321_GL_CXXALIAS_SYS_CAST (connect, int,
322 (int fd,
323 const struct sockaddr *addr, socklen_t addrlen));
324# endif
325_GL_CXXALIASWARN (connect);
326#elif @HAVE_WINSOCK2_H@
327# undef connect
328# define connect socket_used_without_requesting_gnulib_module_connect
329#elif defined GNULIB_POSIXCHECK
330# undef connect
331# if HAVE_RAW_DECL_CONNECT
332_GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
333 "use gnulib module connect for portability");
334# endif
335#endif
336
337#if @GNULIB_ACCEPT@
338# if @HAVE_WINSOCK2_H@
339# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
340# undef accept
341# define accept rpl_accept
342# endif
343_GL_FUNCDECL_RPL (accept, int,
698be2d8
CB
344 (int fd,
345 struct sockaddr *restrict addr,
346 socklen_t *restrict addrlen));
725e2999 347_GL_CXXALIAS_RPL (accept, int,
698be2d8
CB
348 (int fd,
349 struct sockaddr *restrict addr,
350 socklen_t *restrict addrlen));
725e2999
JB
351# else
352/* Need to cast, because on Solaris 10 systems, the third parameter is
698be2d8 353 void *addrlen. */
725e2999 354_GL_CXXALIAS_SYS_CAST (accept, int,
698be2d8
CB
355 (int fd,
356 struct sockaddr *restrict addr,
357 socklen_t *restrict addrlen));
725e2999
JB
358# endif
359_GL_CXXALIASWARN (accept);
360#elif @HAVE_WINSOCK2_H@
361# undef accept
362# define accept accept_used_without_requesting_gnulib_module_accept
363#elif defined GNULIB_POSIXCHECK
364# undef accept
365# if HAVE_RAW_DECL_ACCEPT
366_GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
367 "use gnulib module accept for portability");
368# endif
369#endif
370
371#if @GNULIB_BIND@
372# if @HAVE_WINSOCK2_H@
373# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
374# undef bind
375# define bind rpl_bind
376# endif
377_GL_FUNCDECL_RPL (bind, int,
378 (int fd, const struct sockaddr *addr, socklen_t addrlen)
379 _GL_ARG_NONNULL ((2)));
380_GL_CXXALIAS_RPL (bind, int,
381 (int fd, const struct sockaddr *addr, socklen_t addrlen));
382# else
383/* Need to cast, because on NonStop Kernel, the third parameter is
384 size_t addrlen. */
385_GL_CXXALIAS_SYS_CAST (bind, int,
386 (int fd,
387 const struct sockaddr *addr, socklen_t addrlen));
388# endif
389_GL_CXXALIASWARN (bind);
390#elif @HAVE_WINSOCK2_H@
391# undef bind
392# define bind bind_used_without_requesting_gnulib_module_bind
393#elif defined GNULIB_POSIXCHECK
394# undef bind
395# if HAVE_RAW_DECL_BIND
396_GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
397 "use gnulib module bind for portability");
398# endif
399#endif
400
401#if @GNULIB_GETPEERNAME@
402# if @HAVE_WINSOCK2_H@
403# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
404# undef getpeername
405# define getpeername rpl_getpeername
406# endif
407_GL_FUNCDECL_RPL (getpeername, int,
698be2d8
CB
408 (int fd, struct sockaddr *restrict addr,
409 socklen_t *restrict addrlen)
725e2999
JB
410 _GL_ARG_NONNULL ((2, 3)));
411_GL_CXXALIAS_RPL (getpeername, int,
698be2d8
CB
412 (int fd, struct sockaddr *restrict addr,
413 socklen_t *restrict addrlen));
725e2999
JB
414# else
415/* Need to cast, because on Solaris 10 systems, the third parameter is
698be2d8 416 void *addrlen. */
725e2999 417_GL_CXXALIAS_SYS_CAST (getpeername, int,
698be2d8
CB
418 (int fd, struct sockaddr *restrict addr,
419 socklen_t *restrict addrlen));
725e2999
JB
420# endif
421_GL_CXXALIASWARN (getpeername);
422#elif @HAVE_WINSOCK2_H@
423# undef getpeername
424# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
425#elif defined GNULIB_POSIXCHECK
426# undef getpeername
427# if HAVE_RAW_DECL_GETPEERNAME
428_GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
429 "use gnulib module getpeername for portability");
430# endif
431#endif
432
433#if @GNULIB_GETSOCKNAME@
434# if @HAVE_WINSOCK2_H@
435# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
436# undef getsockname
437# define getsockname rpl_getsockname
438# endif
439_GL_FUNCDECL_RPL (getsockname, int,
698be2d8
CB
440 (int fd, struct sockaddr *restrict addr,
441 socklen_t *restrict addrlen)
725e2999
JB
442 _GL_ARG_NONNULL ((2, 3)));
443_GL_CXXALIAS_RPL (getsockname, int,
698be2d8
CB
444 (int fd, struct sockaddr *restrict addr,
445 socklen_t *restrict addrlen));
725e2999
JB
446# else
447/* Need to cast, because on Solaris 10 systems, the third parameter is
698be2d8 448 void *addrlen. */
725e2999 449_GL_CXXALIAS_SYS_CAST (getsockname, int,
698be2d8
CB
450 (int fd, struct sockaddr *restrict addr,
451 socklen_t *restrict addrlen));
725e2999
JB
452# endif
453_GL_CXXALIASWARN (getsockname);
454#elif @HAVE_WINSOCK2_H@
455# undef getsockname
456# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
457#elif defined GNULIB_POSIXCHECK
458# undef getsockname
459# if HAVE_RAW_DECL_GETSOCKNAME
460_GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
461 "use gnulib module getsockname for portability");
462# endif
463#endif
464
465#if @GNULIB_GETSOCKOPT@
466# if @HAVE_WINSOCK2_H@
467# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
468# undef getsockopt
469# define getsockopt rpl_getsockopt
470# endif
698be2d8
CB
471_GL_FUNCDECL_RPL (getsockopt, int,
472 (int fd, int level, int optname,
473 void *restrict optval, socklen_t *restrict optlen)
474 _GL_ARG_NONNULL ((4, 5)));
475_GL_CXXALIAS_RPL (getsockopt, int,
476 (int fd, int level, int optname,
477 void *restrict optval, socklen_t *restrict optlen));
725e2999
JB
478# else
479/* Need to cast, because on Solaris 10 systems, the fifth parameter is
480 void *optlen. */
698be2d8
CB
481_GL_CXXALIAS_SYS_CAST (getsockopt, int,
482 (int fd, int level, int optname,
483 void *restrict optval, socklen_t *restrict optlen));
725e2999
JB
484# endif
485_GL_CXXALIASWARN (getsockopt);
486#elif @HAVE_WINSOCK2_H@
487# undef getsockopt
488# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
489#elif defined GNULIB_POSIXCHECK
490# undef getsockopt
491# if HAVE_RAW_DECL_GETSOCKOPT
492_GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
493 "use gnulib module getsockopt for portability");
494# endif
495#endif
496
497#if @GNULIB_LISTEN@
498# if @HAVE_WINSOCK2_H@
499# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500# undef listen
501# define listen rpl_listen
502# endif
503_GL_FUNCDECL_RPL (listen, int, (int fd, int backlog));
504_GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
505# else
506_GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
507# endif
508_GL_CXXALIASWARN (listen);
509#elif @HAVE_WINSOCK2_H@
510# undef listen
511# define listen listen_used_without_requesting_gnulib_module_listen
512#elif defined GNULIB_POSIXCHECK
513# undef listen
514# if HAVE_RAW_DECL_LISTEN
515_GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
516 "use gnulib module listen for portability");
517# endif
518#endif
519
520#if @GNULIB_RECV@
521# if @HAVE_WINSOCK2_H@
522# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
523# undef recv
524# define recv rpl_recv
525# endif
526_GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags)
527 _GL_ARG_NONNULL ((2)));
528_GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
529# else
c0c3707f
CB
530/* Need to cast, because on HP-UX 11.31 the return type may be
531 int,
532 depending on compiler options. */
533_GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
725e2999
JB
534# endif
535_GL_CXXALIASWARN (recv);
536#elif @HAVE_WINSOCK2_H@
537# undef recv
538# define recv recv_used_without_requesting_gnulib_module_recv
539#elif defined GNULIB_POSIXCHECK
540# undef recv
541# if HAVE_RAW_DECL_RECV
542_GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
543 "use gnulib module recv for portability");
544# endif
545#endif
546
547#if @GNULIB_SEND@
548# if @HAVE_WINSOCK2_H@
549# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
550# undef send
551# define send rpl_send
552# endif
553_GL_FUNCDECL_RPL (send, ssize_t,
554 (int fd, const void *buf, size_t len, int flags)
555 _GL_ARG_NONNULL ((2)));
556_GL_CXXALIAS_RPL (send, ssize_t,
557 (int fd, const void *buf, size_t len, int flags));
558# else
c0c3707f
CB
559/* Need to cast, because on HP-UX 11.31 the return type may be
560 int,
561 depending on compiler options. */
562_GL_CXXALIAS_SYS_CAST (send, ssize_t,
563 (int fd, const void *buf, size_t len, int flags));
725e2999
JB
564# endif
565_GL_CXXALIASWARN (send);
566#elif @HAVE_WINSOCK2_H@
567# undef send
568# define send send_used_without_requesting_gnulib_module_send
569#elif defined GNULIB_POSIXCHECK
570# undef send
571# if HAVE_RAW_DECL_SEND
572_GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
573 "use gnulib module send for portability");
574# endif
575#endif
576
577#if @GNULIB_RECVFROM@
578# if @HAVE_WINSOCK2_H@
579# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
580# undef recvfrom
581# define recvfrom rpl_recvfrom
582# endif
583_GL_FUNCDECL_RPL (recvfrom, ssize_t,
698be2d8
CB
584 (int fd, void *restrict buf, size_t len, int flags,
585 struct sockaddr *restrict from,
586 socklen_t *restrict fromlen)
725e2999
JB
587 _GL_ARG_NONNULL ((2)));
588_GL_CXXALIAS_RPL (recvfrom, ssize_t,
698be2d8
CB
589 (int fd, void *restrict buf, size_t len, int flags,
590 struct sockaddr *restrict from,
591 socklen_t *restrict fromlen));
725e2999
JB
592# else
593/* Need to cast, because on Solaris 10 systems, the sixth parameter is
594 void *fromlen. */
595_GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
698be2d8
CB
596 (int fd, void *restrict buf, size_t len, int flags,
597 struct sockaddr *restrict from,
598 socklen_t *restrict fromlen));
725e2999
JB
599# endif
600_GL_CXXALIASWARN (recvfrom);
601#elif @HAVE_WINSOCK2_H@
602# undef recvfrom
603# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
604#elif defined GNULIB_POSIXCHECK
605# undef recvfrom
606# if HAVE_RAW_DECL_RECVFROM
607_GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
608 "use gnulib module recvfrom for portability");
609# endif
610#endif
611
612#if @GNULIB_SENDTO@
613# if @HAVE_WINSOCK2_H@
614# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
615# undef sendto
616# define sendto rpl_sendto
617# endif
618_GL_FUNCDECL_RPL (sendto, ssize_t,
619 (int fd, const void *buf, size_t len, int flags,
620 const struct sockaddr *to, socklen_t tolen)
621 _GL_ARG_NONNULL ((2)));
622_GL_CXXALIAS_RPL (sendto, ssize_t,
623 (int fd, const void *buf, size_t len, int flags,
624 const struct sockaddr *to, socklen_t tolen));
625# else
626/* Need to cast, because on NonStop Kernel, the sixth parameter is
627 size_t tolen. */
628_GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
629 (int fd, const void *buf, size_t len, int flags,
630 const struct sockaddr *to, socklen_t tolen));
631# endif
632_GL_CXXALIASWARN (sendto);
633#elif @HAVE_WINSOCK2_H@
634# undef sendto
635# define sendto sendto_used_without_requesting_gnulib_module_sendto
636#elif defined GNULIB_POSIXCHECK
637# undef sendto
638# if HAVE_RAW_DECL_SENDTO
639_GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
640 "use gnulib module sendto for portability");
641# endif
642#endif
643
644#if @GNULIB_SETSOCKOPT@
645# if @HAVE_WINSOCK2_H@
646# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
647# undef setsockopt
648# define setsockopt rpl_setsockopt
649# endif
650_GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
651 const void * optval, socklen_t optlen)
652 _GL_ARG_NONNULL ((4)));
653_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
654 const void * optval, socklen_t optlen));
655# else
656/* Need to cast, because on NonStop Kernel, the fifth parameter is
657 size_t optlen. */
658_GL_CXXALIAS_SYS_CAST (setsockopt, int,
659 (int fd, int level, int optname,
660 const void * optval, socklen_t optlen));
661# endif
662_GL_CXXALIASWARN (setsockopt);
663#elif @HAVE_WINSOCK2_H@
664# undef setsockopt
665# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
666#elif defined GNULIB_POSIXCHECK
667# undef setsockopt
668# if HAVE_RAW_DECL_SETSOCKOPT
669_GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
670 "use gnulib module setsockopt for portability");
671# endif
672#endif
673
674#if @GNULIB_SHUTDOWN@
675# if @HAVE_WINSOCK2_H@
676# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
677# undef shutdown
678# define shutdown rpl_shutdown
679# endif
680_GL_FUNCDECL_RPL (shutdown, int, (int fd, int how));
681_GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
682# else
683_GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
684# endif
685_GL_CXXALIASWARN (shutdown);
686#elif @HAVE_WINSOCK2_H@
687# undef shutdown
688# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
689#elif defined GNULIB_POSIXCHECK
690# undef shutdown
691# if HAVE_RAW_DECL_SHUTDOWN
692_GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
693 "use gnulib module shutdown for portability");
694# endif
695#endif
696
697#if @GNULIB_ACCEPT4@
698/* Accept a connection on a socket, with specific opening flags.
699 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
700 and O_TEXT, O_BINARY (defined in "binary-io.h").
701 See also the Linux man page at
c0c3707f 702 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
725e2999
JB
703# if @HAVE_ACCEPT4@
704# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
705# define accept4 rpl_accept4
706# endif
707_GL_FUNCDECL_RPL (accept4, int,
708 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
709 int flags));
710_GL_CXXALIAS_RPL (accept4, int,
711 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
712 int flags));
713# else
714_GL_FUNCDECL_SYS (accept4, int,
715 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
716 int flags));
717_GL_CXXALIAS_SYS (accept4, int,
718 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
719 int flags));
720# endif
721_GL_CXXALIASWARN (accept4);
722#elif defined GNULIB_POSIXCHECK
723# undef accept4
724# if HAVE_RAW_DECL_ACCEPT4
725_GL_WARN_ON_USE (accept4, "accept4 is unportable - "
726 "use gnulib module accept4 for portability");
727# endif
728#endif
729
730_GL_INLINE_HEADER_END
731
732#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
733#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
734#endif
This page took 0.235471 seconds and 4 git commands to generate.