sys_socket.in.h 22 KB

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