sys_socket.in.h 20 KB

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