Debian Codegraph @

gnulib-tests/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-2025 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 _@GUARD_PREFIX@_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 _@GUARD_PREFIX@_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 _@GUARD_PREFIX@_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 # if !defined GNULIB_defined_struct_msghdr
206 struct msghdr {
207 void *msg_name;
208 socklen_t msg_namelen;
209 struct iovec *msg_iov;
210 int msg_iovlen;
211 int msg_flags;
212 };
213 # define GNULIB_defined_struct_msghdr 1
214 # endif
215
216 #endif
217
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
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
236 rpl_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 # elif !defined __clang__
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 # if !GNULIB_SOCKET
303 # undef socket
304 # define socket socket_used_without_requesting_gnulib_module_socket
305 # endif
306 #elif defined GNULIB_POSIXCHECK
307 # undef socket
308 # if HAVE_RAW_DECL_SOCKET
309 _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
310 "use gnulib module socket for portability");
311 # endif
312 #endif
313
314 #if @GNULIB_CONNECT@
315 # if @HAVE_WINSOCK2_H@
316 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
317 # undef connect
318 # define connect rpl_connect
319 # endif
320 _GL_FUNCDECL_RPL (connect, int,
321 (int fd, const struct sockaddr *addr, socklen_t addrlen),
322 _GL_ARG_NONNULL ((2)));
323 _GL_CXXALIAS_RPL (connect, int,
324 (int fd, const struct sockaddr *addr, socklen_t addrlen));
325 # else
326 /* Need to cast, because on NonStop Kernel, the third parameter is
327 size_t addrlen. */
328 _GL_CXXALIAS_SYS_CAST (connect, int,
329 (int fd,
330 const struct sockaddr *addr, socklen_t addrlen));
331 # endif
332 _GL_CXXALIASWARN (connect);
333 #elif @HAVE_WINSOCK2_H@
334 # if !GNULIB_CONNECT
335 # undef connect
336 # define connect connect_used_without_requesting_gnulib_module_connect
337 # endif
338 #elif defined GNULIB_POSIXCHECK
339 # undef connect
340 # if HAVE_RAW_DECL_CONNECT
341 _GL_WARN_ON_USE (connect, "connect is not always POSIX compliant - "
342 "use gnulib module connect for portability");
343 # endif
344 #endif
345
346 #if @GNULIB_ACCEPT@
347 # if @HAVE_WINSOCK2_H@
348 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
349 # undef accept
350 # define accept rpl_accept
351 # endif
352 _GL_FUNCDECL_RPL (accept, int,
353 (int fd,
354 struct sockaddr *restrict addr,
355 socklen_t *restrict addrlen), );
356 _GL_CXXALIAS_RPL (accept, int,
357 (int fd,
358 struct sockaddr *restrict addr,
359 socklen_t *restrict addrlen));
360 # else
361 /* Need to cast, because on Solaris 10 systems, the third parameter is
362 void *addrlen. */
363 _GL_CXXALIAS_SYS_CAST (accept, int,
364 (int fd,
365 struct sockaddr *restrict addr,
366 socklen_t *restrict addrlen));
367 # endif
368 # if __GLIBC__ >= 2
369 _GL_CXXALIASWARN (accept);
370 # endif
371 #elif @HAVE_WINSOCK2_H@
372 # if !GNULIB_ACCEPT
373 # undef accept
374 # define accept accept_used_without_requesting_gnulib_module_accept
375 # endif
376 #elif defined GNULIB_POSIXCHECK
377 # undef accept
378 # if HAVE_RAW_DECL_ACCEPT
379 _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
380 "use gnulib module accept for portability");
381 # endif
382 #endif
383
384 #if @GNULIB_BIND@
385 # if @HAVE_WINSOCK2_H@
386 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
387 # undef bind
388 # define bind rpl_bind
389 # endif
390 _GL_FUNCDECL_RPL (bind, int,
391 (int fd, const struct sockaddr *addr, socklen_t addrlen),
392 _GL_ARG_NONNULL ((2)));
393 _GL_CXXALIAS_RPL (bind, int,
394 (int fd, const struct sockaddr *addr, socklen_t addrlen));
395 # else
396 /* Need to cast, because on NonStop Kernel, the third parameter is
397 size_t addrlen. */
398 _GL_CXXALIAS_SYS_CAST (bind, int,
399 (int fd,
400 const struct sockaddr *addr, socklen_t addrlen));
401 # endif
402 _GL_CXXALIASWARN (bind);
403 #elif @HAVE_WINSOCK2_H@
404 # if !GNULIB_BIND
405 # undef bind
406 # define bind bind_used_without_requesting_gnulib_module_bind
407 # endif
408 #elif defined GNULIB_POSIXCHECK
409 # undef bind
410 # if HAVE_RAW_DECL_BIND
411 _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
412 "use gnulib module bind for portability");
413 # endif
414 #endif
415
416 #if @GNULIB_GETPEERNAME@
417 # if @HAVE_WINSOCK2_H@
418 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
419 # undef getpeername
420 # define getpeername rpl_getpeername
421 # endif
422 _GL_FUNCDECL_RPL (getpeername, int,
423 (int fd, struct sockaddr *restrict addr,
424 socklen_t *restrict addrlen),
425 _GL_ARG_NONNULL ((2, 3)));
426 _GL_CXXALIAS_RPL (getpeername, int,
427 (int fd, struct sockaddr *restrict addr,
428 socklen_t *restrict addrlen));
429 # else
430 /* Need to cast, because on Solaris 10 systems, the third parameter is
431 void *addrlen. */
432 _GL_CXXALIAS_SYS_CAST (getpeername, int,
433 (int fd, struct sockaddr *restrict addr,
434 socklen_t *restrict addrlen));
435 # endif
436 # if __GLIBC__ >= 2
437 _GL_CXXALIASWARN (getpeername);
438 # endif
439 #elif @HAVE_WINSOCK2_H@
440 # if !GNULIB_GETPEERNAME
441 # undef getpeername
442 # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
443 # endif
444 #elif defined GNULIB_POSIXCHECK
445 # undef getpeername
446 # if HAVE_RAW_DECL_GETPEERNAME
447 _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
448 "use gnulib module getpeername for portability");
449 # endif
450 #endif
451
452 #if @GNULIB_GETSOCKNAME@
453 # if @HAVE_WINSOCK2_H@
454 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
455 # undef getsockname
456 # define getsockname rpl_getsockname
457 # endif
458 _GL_FUNCDECL_RPL (getsockname, int,
459 (int fd, struct sockaddr *restrict addr,
460 socklen_t *restrict addrlen),
461 _GL_ARG_NONNULL ((2, 3)));
462 _GL_CXXALIAS_RPL (getsockname, int,
463 (int fd, struct sockaddr *restrict addr,
464 socklen_t *restrict addrlen));
465 # else
466 /* Need to cast, because on Solaris 10 systems, the third parameter is
467 void *addrlen. */
468 _GL_CXXALIAS_SYS_CAST (getsockname, int,
469 (int fd, struct sockaddr *restrict addr,
470 socklen_t *restrict addrlen));
471 # endif
472 # if __GLIBC__ >= 2
473 _GL_CXXALIASWARN (getsockname);
474 # endif
475 #elif @HAVE_WINSOCK2_H@
476 # if !GNULIB_GETSOCKNAME
477 # undef getsockname
478 # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
479 # endif
480 #elif defined GNULIB_POSIXCHECK
481 # undef getsockname
482 # if HAVE_RAW_DECL_GETSOCKNAME
483 _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
484 "use gnulib module getsockname for portability");
485 # endif
486 #endif
487
488 #if @GNULIB_GETSOCKOPT@
489 # if @HAVE_WINSOCK2_H@
490 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
491 # undef getsockopt
492 # define getsockopt rpl_getsockopt
493 # endif
494 _GL_FUNCDECL_RPL (getsockopt, int,
495 (int fd, int level, int optname,
496 void *restrict optval, socklen_t *restrict optlen),
497 _GL_ARG_NONNULL ((4, 5)));
498 _GL_CXXALIAS_RPL (getsockopt, int,
499 (int fd, int level, int optname,
500 void *restrict optval, socklen_t *restrict optlen));
501 # else
502 /* Need to cast, because on Solaris 10 systems, the fifth parameter is
503 void *optlen. */
504 _GL_CXXALIAS_SYS_CAST (getsockopt, int,
505 (int fd, int level, int optname,
506 void *restrict optval, socklen_t *restrict optlen));
507 # endif
508 _GL_CXXALIASWARN (getsockopt);
509 #elif @HAVE_WINSOCK2_H@
510 # if !GNULIB_GETSOCKOPT
511 # undef getsockopt
512 # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
513 # endif
514 #elif defined GNULIB_POSIXCHECK
515 # undef getsockopt
516 # if HAVE_RAW_DECL_GETSOCKOPT
517 _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
518 "use gnulib module getsockopt for portability");
519 # endif
520 #endif
521
522 #if @GNULIB_LISTEN@
523 # if @HAVE_WINSOCK2_H@
524 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
525 # undef listen
526 # define listen rpl_listen
527 # endif
528 _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog), );
529 _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
530 # else
531 _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
532 # endif
533 _GL_CXXALIASWARN (listen);
534 #elif @HAVE_WINSOCK2_H@
535 # if !GNULIB_LISTEN
536 # undef listen
537 # define listen listen_used_without_requesting_gnulib_module_listen
538 # endif
539 #elif defined GNULIB_POSIXCHECK
540 # undef listen
541 # if HAVE_RAW_DECL_LISTEN
542 _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
543 "use gnulib module listen for portability");
544 # endif
545 #endif
546
547 #if @GNULIB_RECV@
548 # if @HAVE_WINSOCK2_H@
549 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
550 # undef recv
551 # define recv rpl_recv
552 # endif
553 _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags),
554 _GL_ARG_NONNULL ((2)));
555 _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
556 # else
557 /* Need to cast, because on HP-UX 11.31 the return type may be
558 int,
559 depending on compiler options. */
560 _GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
561 # endif
562 _GL_CXXALIASWARN (recv);
563 #elif @HAVE_WINSOCK2_H@
564 # if !GNULIB_RECV
565 # undef recv
566 # define recv recv_used_without_requesting_gnulib_module_recv
567 # endif
568 #elif defined GNULIB_POSIXCHECK
569 # undef recv
570 # if HAVE_RAW_DECL_RECV
571 _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
572 "use gnulib module recv for portability");
573 # endif
574 #endif
575
576 #if @GNULIB_SEND@
577 # if @HAVE_WINSOCK2_H@
578 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
579 # undef send
580 # define send rpl_send
581 # endif
582 _GL_FUNCDECL_RPL (send, ssize_t,
583 (int fd, const void *buf, size_t len, int flags),
584 _GL_ARG_NONNULL ((2)));
585 _GL_CXXALIAS_RPL (send, ssize_t,
586 (int fd, const void *buf, size_t len, int flags));
587 # else
588 /* Need to cast, because on HP-UX 11.31 the return type may be
589 int,
590 depending on compiler options. */
591 _GL_CXXALIAS_SYS_CAST (send, ssize_t,
592 (int fd, const void *buf, size_t len, int flags));
593 # endif
594 _GL_CXXALIASWARN (send);
595 #elif @HAVE_WINSOCK2_H@
596 # if !GNULIB_SEND
597 # undef send
598 # define send send_used_without_requesting_gnulib_module_send
599 # endif
600 #elif defined GNULIB_POSIXCHECK
601 # undef send
602 # if HAVE_RAW_DECL_SEND
603 _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
604 "use gnulib module send for portability");
605 # endif
606 #endif
607
608 #if @GNULIB_RECVFROM@
609 # if @HAVE_WINSOCK2_H@
610 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
611 # undef recvfrom
612 # define recvfrom rpl_recvfrom
613 # endif
614 _GL_FUNCDECL_RPL (recvfrom, ssize_t,
615 (int fd, void *restrict buf, size_t len, int flags,
616 struct sockaddr *restrict from,
617 socklen_t *restrict fromlen),
618 _GL_ARG_NONNULL ((2)));
619 _GL_CXXALIAS_RPL (recvfrom, ssize_t,
620 (int fd, void *restrict buf, size_t len, int flags,
621 struct sockaddr *restrict from,
622 socklen_t *restrict fromlen));
623 # else
624 /* Need to cast, because on Solaris 10 systems, the sixth parameter is
625 void *fromlen. */
626 _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
627 (int fd, void *restrict buf, size_t len, int flags,
628 struct sockaddr *restrict from,
629 socklen_t *restrict fromlen));
630 # endif
631 # if __GLIBC__ >= 2
632 _GL_CXXALIASWARN (recvfrom);
633 # endif
634 #elif @HAVE_WINSOCK2_H@
635 # if !GNULIB_RECVFROM
636 # undef recvfrom
637 # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
638 # endif
639 #elif defined GNULIB_POSIXCHECK
640 # undef recvfrom
641 # if HAVE_RAW_DECL_RECVFROM
642 _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
643 "use gnulib module recvfrom for portability");
644 # endif
645 #endif
646
647 #if @GNULIB_SENDTO@
648 # if @HAVE_WINSOCK2_H@
649 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650 # undef sendto
651 # define sendto rpl_sendto
652 # endif
653 _GL_FUNCDECL_RPL (sendto, ssize_t,
654 (int fd, const void *buf, size_t len, int flags,
655 const struct sockaddr *to, socklen_t tolen),
656 _GL_ARG_NONNULL ((2)));
657 _GL_CXXALIAS_RPL (sendto, ssize_t,
658 (int fd, const void *buf, size_t len, int flags,
659 const struct sockaddr *to, socklen_t tolen));
660 # else
661 /* Need to cast, because on NonStop Kernel, the sixth parameter is
662 size_t tolen. */
663 _GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
664 (int fd, const void *buf, size_t len, int flags,
665 const struct sockaddr *to, socklen_t tolen));
666 # endif
667 _GL_CXXALIASWARN (sendto);
668 #elif @HAVE_WINSOCK2_H@
669 # if !GNULIB_SENDTO
670 # undef sendto
671 # define sendto sendto_used_without_requesting_gnulib_module_sendto
672 # endif
673 #elif defined GNULIB_POSIXCHECK
674 # undef sendto
675 # if HAVE_RAW_DECL_SENDTO
676 _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
677 "use gnulib module sendto for portability");
678 # endif
679 #endif
680
681 #if @GNULIB_SETSOCKOPT@
682 # if @HAVE_WINSOCK2_H@
683 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
684 # undef setsockopt
685 # define setsockopt rpl_setsockopt
686 # endif
687 _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
688 const void * optval, socklen_t optlen),
689 _GL_ARG_NONNULL ((4)));
690 _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
691 const void * optval, socklen_t optlen));
692 # else
693 /* Need to cast, because on NonStop Kernel, the fifth parameter is
694 size_t optlen. */
695 _GL_CXXALIAS_SYS_CAST (setsockopt, int,
696 (int fd, int level, int optname,
697 const void * optval, socklen_t optlen));
698 # endif
699 _GL_CXXALIASWARN (setsockopt);
700 #elif @HAVE_WINSOCK2_H@
701 # if !GNULIB_SETSOCKOPT
702 # undef setsockopt
703 # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
704 # endif
705 #elif defined GNULIB_POSIXCHECK
706 # undef setsockopt
707 # if HAVE_RAW_DECL_SETSOCKOPT
708 _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
709 "use gnulib module setsockopt for portability");
710 # endif
711 #endif
712
713 #if @GNULIB_SHUTDOWN@
714 # if @HAVE_WINSOCK2_H@
715 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
716 # undef shutdown
717 # define shutdown rpl_shutdown
718 # endif
719 _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how), );
720 _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
721 # else
722 _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
723 # endif
724 _GL_CXXALIASWARN (shutdown);
725 #elif @HAVE_WINSOCK2_H@
726 # if !GNULIB_SHUTDOWN
727 # undef shutdown
728 # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
729 # endif
730 #elif defined GNULIB_POSIXCHECK
731 # undef shutdown
732 # if HAVE_RAW_DECL_SHUTDOWN
733 _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
734 "use gnulib module shutdown for portability");
735 # endif
736 #endif
737
738 #if @GNULIB_ACCEPT4@
739 /* Accept a connection on a socket, with specific opening flags.
740 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
741 and O_TEXT, O_BINARY (defined in "binary-io.h").
742 See also the Linux man page at
743 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
744 # if @HAVE_ACCEPT4@
745 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
746 # define accept4 rpl_accept4
747 # endif
748 _GL_FUNCDECL_RPL (accept4, int,
749 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
750 int flags), );
751 _GL_CXXALIAS_RPL (accept4, int,
752 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
753 int flags));
754 # else
755 _GL_FUNCDECL_SYS (accept4, int,
756 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
757 int flags), );
758 _GL_CXXALIAS_SYS (accept4, int,
759 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
760 int flags));
761 # endif
762 _GL_CXXALIASWARN (accept4);
763 #elif defined GNULIB_POSIXCHECK
764 # undef accept4
765 # if HAVE_RAW_DECL_ACCEPT4
766 _GL_WARN_ON_USE (accept4, "accept4 is unportable - "
767 "use gnulib module accept4 for portability");
768 # endif
769 #endif
770
771 _GL_INLINE_HEADER_END
772
773 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
774 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
775 #endif