Debian Codegraph @

lib/sys_socket.in.h

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