sys_socket.in.h 22 KB

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