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