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-2026 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 if (set == NULL)
239 return 0;
240
241 for (u_int i = 0; i < set->fd_count; i++)
242 if (set->fd_array[i] == fd)
243 return 1;
244
245 return 0;
246 }
247
248 # define GNULIB_defined_rpl_fd_isset 1
249 # endif
250
251 # undef FD_ISSET
252 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
253
254 #endif
255
256 /* Hide some function declarations from <winsock2.h>. */
257
258 #if @HAVE_WINSOCK2_H@
259 # if !defined _@GUARD_PREFIX@_UNISTD_H
260 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
261 # undef close
262 # define close close_used_without_including_unistd_h
263 # elif !defined __clang__
264 _GL_WARN_ON_USE (close,
265 "close() used without including <unistd.h>");
266 # endif
267 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
268 # undef gethostname
269 # define gethostname gethostname_used_without_including_unistd_h
270 # else
271 _GL_WARN_ON_USE (gethostname,
272 "gethostname() used without including <unistd.h>");
273 # endif
274 # endif
275 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
276 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
277 # undef select
278 # define select select_used_without_including_sys_select_h
279 # else
280 _GL_WARN_ON_USE (select,
281 "select() used without including <sys/select.h>");
282 # endif
283 # endif
284 #endif
285
286 /* Wrap everything else to use libc file descriptors for sockets. */
287
288 #if @GNULIB_SOCKET@
289 # if @HAVE_WINSOCK2_H@
290 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
291 # undef socket
292 # define socket rpl_socket
293 # endif
294 _GL_FUNCDECL_RPL (socket, int, (int domain, int type, int protocol), );
295 _GL_CXXALIAS_RPL (socket, int, (int domain, int type, int protocol));
296 # else
297 _GL_CXXALIAS_SYS (socket, int, (int domain, int type, int protocol));
298 # endif
299 _GL_CXXALIASWARN (socket);
300 #elif @HAVE_WINSOCK2_H@
301 # if !GNULIB_SOCKET
302 # undef socket
303 # define socket socket_used_without_requesting_gnulib_module_socket
304 # endif
305 #elif defined GNULIB_POSIXCHECK
306 # if HAVE_RAW_DECL_SOCKET
307 _GL_WARN_ON_USE (socket, "socket is not always POSIX compliant - "
308 "use gnulib module socket for portability");
309 # endif
310 #endif
311
312 #if @GNULIB_CONNECT@
313 # if @HAVE_WINSOCK2_H@
314 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315 # undef connect
316 # define connect rpl_connect
317 # endif
318 _GL_FUNCDECL_RPL (connect, int,
319 (int fd, const struct sockaddr *addr, socklen_t addrlen),
320 _GL_ARG_NONNULL ((2)));
321 _GL_CXXALIAS_RPL (connect, int,
322 (int fd, const struct sockaddr *addr, socklen_t addrlen));
323 # else
324 /* Need to cast, because on NonStop Kernel, the third parameter is
325 size_t addrlen. */
326 _GL_CXXALIAS_SYS_CAST (connect, int,
327 (int fd,
328 const struct sockaddr *addr, socklen_t addrlen));
329 # endif
330 _GL_CXXALIASWARN (connect);
331 #elif @HAVE_WINSOCK2_H@
332 # if !GNULIB_CONNECT
333 # undef connect
334 # define connect connect_used_without_requesting_gnulib_module_connect
335 # endif
336 #elif defined GNULIB_POSIXCHECK
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 # if HAVE_RAW_DECL_ACCEPT
375 _GL_WARN_ON_USE (accept, "accept is not always POSIX compliant - "
376 "use gnulib module accept for portability");
377 # endif
378 #endif
379
380 #if @GNULIB_BIND@
381 # if @HAVE_WINSOCK2_H@
382 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
383 # undef bind
384 # define bind rpl_bind
385 # endif
386 _GL_FUNCDECL_RPL (bind, int,
387 (int fd, const struct sockaddr *addr, socklen_t addrlen),
388 _GL_ARG_NONNULL ((2)));
389 _GL_CXXALIAS_RPL (bind, int,
390 (int fd, const struct sockaddr *addr, socklen_t addrlen));
391 # else
392 /* Need to cast, because on NonStop Kernel, the third parameter is
393 size_t addrlen. */
394 _GL_CXXALIAS_SYS_CAST (bind, int,
395 (int fd,
396 const struct sockaddr *addr, socklen_t addrlen));
397 # endif
398 _GL_CXXALIASWARN (bind);
399 #elif @HAVE_WINSOCK2_H@
400 # if !GNULIB_BIND
401 # undef bind
402 # define bind bind_used_without_requesting_gnulib_module_bind
403 # endif
404 #elif defined GNULIB_POSIXCHECK
405 # if HAVE_RAW_DECL_BIND
406 _GL_WARN_ON_USE (bind, "bind is not always POSIX compliant - "
407 "use gnulib module bind for portability");
408 # endif
409 #endif
410
411 #if @GNULIB_GETPEERNAME@
412 # if @HAVE_WINSOCK2_H@
413 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
414 # undef getpeername
415 # define getpeername rpl_getpeername
416 # endif
417 _GL_FUNCDECL_RPL (getpeername, int,
418 (int fd, struct sockaddr *restrict addr,
419 socklen_t *restrict addrlen),
420 _GL_ARG_NONNULL ((2, 3)));
421 _GL_CXXALIAS_RPL (getpeername, int,
422 (int fd, struct sockaddr *restrict addr,
423 socklen_t *restrict addrlen));
424 # else
425 /* Need to cast, because on Solaris 10 systems, the third parameter is
426 void *addrlen. */
427 _GL_CXXALIAS_SYS_CAST (getpeername, int,
428 (int fd, struct sockaddr *restrict addr,
429 socklen_t *restrict addrlen));
430 # endif
431 # if __GLIBC__ >= 2
432 _GL_CXXALIASWARN (getpeername);
433 # endif
434 #elif @HAVE_WINSOCK2_H@
435 # if !GNULIB_GETPEERNAME
436 # undef getpeername
437 # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
438 # endif
439 #elif defined GNULIB_POSIXCHECK
440 # if HAVE_RAW_DECL_GETPEERNAME
441 _GL_WARN_ON_USE (getpeername, "getpeername is not always POSIX compliant - "
442 "use gnulib module getpeername for portability");
443 # endif
444 #endif
445
446 #if @GNULIB_GETSOCKNAME@
447 # if @HAVE_WINSOCK2_H@
448 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
449 # undef getsockname
450 # define getsockname rpl_getsockname
451 # endif
452 _GL_FUNCDECL_RPL (getsockname, int,
453 (int fd, struct sockaddr *restrict addr,
454 socklen_t *restrict addrlen),
455 _GL_ARG_NONNULL ((2, 3)));
456 _GL_CXXALIAS_RPL (getsockname, int,
457 (int fd, struct sockaddr *restrict addr,
458 socklen_t *restrict addrlen));
459 # else
460 /* Need to cast, because on Solaris 10 systems, the third parameter is
461 void *addrlen. */
462 _GL_CXXALIAS_SYS_CAST (getsockname, int,
463 (int fd, struct sockaddr *restrict addr,
464 socklen_t *restrict addrlen));
465 # endif
466 # if __GLIBC__ >= 2
467 _GL_CXXALIASWARN (getsockname);
468 # endif
469 #elif @HAVE_WINSOCK2_H@
470 # if !GNULIB_GETSOCKNAME
471 # undef getsockname
472 # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
473 # endif
474 #elif defined GNULIB_POSIXCHECK
475 # if HAVE_RAW_DECL_GETSOCKNAME
476 _GL_WARN_ON_USE (getsockname, "getsockname is not always POSIX compliant - "
477 "use gnulib module getsockname for portability");
478 # endif
479 #endif
480
481 #if @GNULIB_GETSOCKOPT@
482 # if @HAVE_WINSOCK2_H@
483 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
484 # undef getsockopt
485 # define getsockopt rpl_getsockopt
486 # endif
487 _GL_FUNCDECL_RPL (getsockopt, int,
488 (int fd, int level, int optname,
489 void *restrict optval, socklen_t *restrict optlen),
490 _GL_ARG_NONNULL ((4, 5)));
491 _GL_CXXALIAS_RPL (getsockopt, int,
492 (int fd, int level, int optname,
493 void *restrict optval, socklen_t *restrict optlen));
494 # else
495 /* Need to cast, because on Solaris 10 systems, the fifth parameter is
496 void *optlen. */
497 _GL_CXXALIAS_SYS_CAST (getsockopt, int,
498 (int fd, int level, int optname,
499 void *restrict optval, socklen_t *restrict optlen));
500 # endif
501 _GL_CXXALIASWARN (getsockopt);
502 #elif @HAVE_WINSOCK2_H@
503 # if !GNULIB_GETSOCKOPT
504 # undef getsockopt
505 # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
506 # endif
507 #elif defined GNULIB_POSIXCHECK
508 # if HAVE_RAW_DECL_GETSOCKOPT
509 _GL_WARN_ON_USE (getsockopt, "getsockopt is not always POSIX compliant - "
510 "use gnulib module getsockopt for portability");
511 # endif
512 #endif
513
514 #if @GNULIB_LISTEN@
515 # if @HAVE_WINSOCK2_H@
516 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
517 # undef listen
518 # define listen rpl_listen
519 # endif
520 _GL_FUNCDECL_RPL (listen, int, (int fd, int backlog), );
521 _GL_CXXALIAS_RPL (listen, int, (int fd, int backlog));
522 # else
523 _GL_CXXALIAS_SYS (listen, int, (int fd, int backlog));
524 # endif
525 _GL_CXXALIASWARN (listen);
526 #elif @HAVE_WINSOCK2_H@
527 # if !GNULIB_LISTEN
528 # undef listen
529 # define listen listen_used_without_requesting_gnulib_module_listen
530 # endif
531 #elif defined GNULIB_POSIXCHECK
532 # if HAVE_RAW_DECL_LISTEN
533 _GL_WARN_ON_USE (listen, "listen is not always POSIX compliant - "
534 "use gnulib module listen for portability");
535 # endif
536 #endif
537
538 #if @GNULIB_RECV@
539 # if @HAVE_WINSOCK2_H@
540 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
541 # undef recv
542 # define recv rpl_recv
543 # endif
544 _GL_FUNCDECL_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags),
545 _GL_ARG_NONNULL ((2)));
546 _GL_CXXALIAS_RPL (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
547 # else
548 /* Need to cast, because on HP-UX 11.31 the return type may be
549 int,
550 depending on compiler options. */
551 _GL_CXXALIAS_SYS_CAST (recv, ssize_t, (int fd, void *buf, size_t len, int flags));
552 # endif
553 _GL_CXXALIASWARN (recv);
554 #elif @HAVE_WINSOCK2_H@
555 # if !GNULIB_RECV
556 # undef recv
557 # define recv recv_used_without_requesting_gnulib_module_recv
558 # endif
559 #elif defined GNULIB_POSIXCHECK
560 # if HAVE_RAW_DECL_RECV
561 _GL_WARN_ON_USE (recv, "recv is not always POSIX compliant - "
562 "use gnulib module recv for portability");
563 # endif
564 #endif
565
566 #if @GNULIB_SEND@
567 # if @HAVE_WINSOCK2_H@
568 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569 # undef send
570 # define send rpl_send
571 # endif
572 _GL_FUNCDECL_RPL (send, ssize_t,
573 (int fd, const void *buf, size_t len, int flags),
574 _GL_ARG_NONNULL ((2)));
575 _GL_CXXALIAS_RPL (send, ssize_t,
576 (int fd, const void *buf, size_t len, int flags));
577 # else
578 /* Need to cast, because on HP-UX 11.31 the return type may be
579 int,
580 depending on compiler options. */
581 _GL_CXXALIAS_SYS_CAST (send, ssize_t,
582 (int fd, const void *buf, size_t len, int flags));
583 # endif
584 _GL_CXXALIASWARN (send);
585 #elif @HAVE_WINSOCK2_H@
586 # if !GNULIB_SEND
587 # undef send
588 # define send send_used_without_requesting_gnulib_module_send
589 # endif
590 #elif defined GNULIB_POSIXCHECK
591 # if HAVE_RAW_DECL_SEND
592 _GL_WARN_ON_USE (send, "send is not always POSIX compliant - "
593 "use gnulib module send for portability");
594 # endif
595 #endif
596
597 #if @GNULIB_RECVFROM@
598 # if @HAVE_WINSOCK2_H@
599 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
600 # undef recvfrom
601 # define recvfrom rpl_recvfrom
602 # endif
603 _GL_FUNCDECL_RPL (recvfrom, ssize_t,
604 (int fd, void *restrict buf, size_t len, int flags,
605 struct sockaddr *restrict from,
606 socklen_t *restrict fromlen),
607 _GL_ARG_NONNULL ((2)));
608 _GL_CXXALIAS_RPL (recvfrom, ssize_t,
609 (int fd, void *restrict buf, size_t len, int flags,
610 struct sockaddr *restrict from,
611 socklen_t *restrict fromlen));
612 # else
613 /* Need to cast, because on Solaris 10 systems, the sixth parameter is
614 void *fromlen. */
615 _GL_CXXALIAS_SYS_CAST (recvfrom, ssize_t,
616 (int fd, void *restrict buf, size_t len, int flags,
617 struct sockaddr *restrict from,
618 socklen_t *restrict fromlen));
619 # endif
620 # if __GLIBC__ >= 2
621 _GL_CXXALIASWARN (recvfrom);
622 # endif
623 #elif @HAVE_WINSOCK2_H@
624 # if !GNULIB_RECVFROM
625 # undef recvfrom
626 # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
627 # endif
628 #elif defined GNULIB_POSIXCHECK
629 # if HAVE_RAW_DECL_RECVFROM
630 _GL_WARN_ON_USE (recvfrom, "recvfrom is not always POSIX compliant - "
631 "use gnulib module recvfrom for portability");
632 # endif
633 #endif
634
635 #if @GNULIB_SENDTO@
636 # if @HAVE_WINSOCK2_H@
637 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
638 # undef sendto
639 # define sendto rpl_sendto
640 # endif
641 _GL_FUNCDECL_RPL (sendto, ssize_t,
642 (int fd, const void *buf, size_t len, int flags,
643 const struct sockaddr *to, socklen_t tolen),
644 _GL_ARG_NONNULL ((2)));
645 _GL_CXXALIAS_RPL (sendto, ssize_t,
646 (int fd, const void *buf, size_t len, int flags,
647 const struct sockaddr *to, socklen_t tolen));
648 # else
649 /* Need to cast, because on NonStop Kernel, the sixth parameter is
650 size_t tolen. */
651 _GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
652 (int fd, const void *buf, size_t len, int flags,
653 const struct sockaddr *to, socklen_t tolen));
654 # endif
655 _GL_CXXALIASWARN (sendto);
656 #elif @HAVE_WINSOCK2_H@
657 # if !GNULIB_SENDTO
658 # undef sendto
659 # define sendto sendto_used_without_requesting_gnulib_module_sendto
660 # endif
661 #elif defined GNULIB_POSIXCHECK
662 # if HAVE_RAW_DECL_SENDTO
663 _GL_WARN_ON_USE (sendto, "sendto is not always POSIX compliant - "
664 "use gnulib module sendto for portability");
665 # endif
666 #endif
667
668 #if @GNULIB_SETSOCKOPT@
669 # if @HAVE_WINSOCK2_H@
670 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
671 # undef setsockopt
672 # define setsockopt rpl_setsockopt
673 # endif
674 _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
675 const void * optval, socklen_t optlen),
676 _GL_ARG_NONNULL ((4)));
677 _GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
678 const void * optval, socklen_t optlen));
679 # else
680 /* Need to cast, because on NonStop Kernel, the fifth parameter is
681 size_t optlen. */
682 _GL_CXXALIAS_SYS_CAST (setsockopt, int,
683 (int fd, int level, int optname,
684 const void * optval, socklen_t optlen));
685 # endif
686 _GL_CXXALIASWARN (setsockopt);
687 #elif @HAVE_WINSOCK2_H@
688 # if !GNULIB_SETSOCKOPT
689 # undef setsockopt
690 # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
691 # endif
692 #elif defined GNULIB_POSIXCHECK
693 # if HAVE_RAW_DECL_SETSOCKOPT
694 _GL_WARN_ON_USE (setsockopt, "setsockopt is not always POSIX compliant - "
695 "use gnulib module setsockopt for portability");
696 # endif
697 #endif
698
699 #if @GNULIB_SHUTDOWN@
700 # if @HAVE_WINSOCK2_H@
701 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
702 # undef shutdown
703 # define shutdown rpl_shutdown
704 # endif
705 _GL_FUNCDECL_RPL (shutdown, int, (int fd, int how), );
706 _GL_CXXALIAS_RPL (shutdown, int, (int fd, int how));
707 # else
708 _GL_CXXALIAS_SYS (shutdown, int, (int fd, int how));
709 # endif
710 _GL_CXXALIASWARN (shutdown);
711 #elif @HAVE_WINSOCK2_H@
712 # if !GNULIB_SHUTDOWN
713 # undef shutdown
714 # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
715 # endif
716 #elif defined GNULIB_POSIXCHECK
717 # if HAVE_RAW_DECL_SHUTDOWN
718 _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
719 "use gnulib module shutdown for portability");
720 # endif
721 #endif
722
723 #if @GNULIB_ACCEPT4@
724 /* Accept a connection on a socket, with specific opening flags.
725 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
726 and O_TEXT, O_BINARY (defined in "binary-io.h").
727 See also the Linux man page at
728 <https://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>. */
729 # if @HAVE_ACCEPT4@
730 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
731 # define accept4 rpl_accept4
732 # endif
733 _GL_FUNCDECL_RPL (accept4, int,
734 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
735 int flags), );
736 _GL_CXXALIAS_RPL (accept4, int,
737 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
738 int flags));
739 # else
740 _GL_FUNCDECL_SYS (accept4, int,
741 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
742 int flags), );
743 _GL_CXXALIAS_SYS (accept4, int,
744 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
745 int flags));
746 # endif
747 _GL_CXXALIASWARN (accept4);
748 #elif defined GNULIB_POSIXCHECK
749 # if HAVE_RAW_DECL_ACCEPT4
750 _GL_WARN_ON_USE (accept4, "accept4 is unportable - "
751 "use gnulib module accept4 for portability");
752 # endif
753 #endif
754
755 _GL_INLINE_HEADER_END
756
757 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
758 #endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
759 #endif