sys_socket.in.h 22 KB

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