sys_socket.in.h 23 KB

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