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