sys_socket.in.h 22 KB

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