sys_socket.in.h 22 KB

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