diff options
Diffstat (limited to 'gl/sys_socket.in.h')
| -rw-r--r-- | gl/sys_socket.in.h | 338 |
1 files changed, 325 insertions, 13 deletions
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h index 5e0b097d..5d9b3cdb 100644 --- a/gl/sys_socket.in.h +++ b/gl/sys_socket.in.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* Provide a sys/socket header file for systems lacking it (read: MinGW). | 1 | /* Provide a sys/socket header file for systems lacking it (read: MinGW) |
| 2 | Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. | 2 | and for systems where it is incomplete. |
| 3 | Copyright (C) 2005-2008 Free Software Foundation, Inc. | ||
| 3 | Written by Simon Josefsson. | 4 | Written by Simon Josefsson. |
| 4 | 5 | ||
| 5 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
| @@ -16,8 +17,9 @@ | |||
| 16 | along with this program; if not, write to the Free Software Foundation, | 17 | along with this program; if not, write to the Free Software Foundation, |
| 17 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 18 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
| 18 | 19 | ||
| 19 | /* This file is supposed to be used on platforms that lack <sys/socket.h> | 20 | /* This file is supposed to be used on platforms that lack <sys/socket.h>, |
| 20 | and on platforms where <sys/socket.h> cannot be included standalone. | 21 | on platforms where <sys/socket.h> cannot be included standalone, and on |
| 22 | platforms where <sys/socket.h> does not provide all necessary definitions. | ||
| 21 | It is intended to provide definitions and prototypes needed by an | 23 | It is intended to provide definitions and prototypes needed by an |
| 22 | application. */ | 24 | application. */ |
| 23 | 25 | ||
| @@ -25,6 +27,10 @@ | |||
| 25 | 27 | ||
| 26 | #if @HAVE_SYS_SOCKET_H@ | 28 | #if @HAVE_SYS_SOCKET_H@ |
| 27 | 29 | ||
| 30 | # if __GNUC__ >= 3 | ||
| 31 | @PRAGMA_SYSTEM_HEADER@ | ||
| 32 | # endif | ||
| 33 | |||
| 28 | /* On many platforms, <sys/socket.h> assumes prior inclusion of | 34 | /* On many platforms, <sys/socket.h> assumes prior inclusion of |
| 29 | <sys/types.h>. */ | 35 | <sys/types.h>. */ |
| 30 | # include <sys/types.h> | 36 | # include <sys/types.h> |
| @@ -37,7 +43,26 @@ | |||
| 37 | #ifndef _GL_SYS_SOCKET_H | 43 | #ifndef _GL_SYS_SOCKET_H |
| 38 | #define _GL_SYS_SOCKET_H | 44 | #define _GL_SYS_SOCKET_H |
| 39 | 45 | ||
| 40 | #if !@HAVE_SYS_SOCKET_H@ | 46 | #if @HAVE_SYS_SOCKET_H@ |
| 47 | |||
| 48 | /* A platform that has <sys/socket.h>. */ | ||
| 49 | |||
| 50 | /* For shutdown(). */ | ||
| 51 | # if !defined SHUT_RD | ||
| 52 | # define SHUT_RD 0 | ||
| 53 | # endif | ||
| 54 | # if !defined SHUT_WR | ||
| 55 | # define SHUT_WR 1 | ||
| 56 | # endif | ||
| 57 | # if !defined SHUT_RDWR | ||
| 58 | # define SHUT_RDWR 2 | ||
| 59 | # endif | ||
| 60 | |||
| 61 | #else | ||
| 62 | |||
| 63 | # ifdef __CYGWIN__ | ||
| 64 | # error "Cygwin does have a sys/socket.h, doesn't it?!?" | ||
| 65 | # endif | ||
| 41 | 66 | ||
| 42 | /* A platform that lacks <sys/socket.h>. | 67 | /* A platform that lacks <sys/socket.h>. |
| 43 | 68 | ||
| @@ -75,14 +100,301 @@ | |||
| 75 | # define SHUT_RDWR SD_BOTH | 100 | # define SHUT_RDWR SD_BOTH |
| 76 | # endif | 101 | # endif |
| 77 | 102 | ||
| 78 | # if defined _WIN32 || defined __WIN32__ | 103 | /* The definition of GL_LINK_WARNING is copied here. */ |
| 79 | # define ENOTSOCK WSAENOTSOCK | 104 | |
| 80 | # define EADDRINUSE WSAEADDRINUSE | 105 | # if @HAVE_WINSOCK2_H@ |
| 81 | # define ENETRESET WSAENETRESET | 106 | /* Include headers needed by the emulation code. */ |
| 82 | # define ECONNABORTED WSAECONNABORTED | 107 | # include <sys/types.h> |
| 83 | # define ECONNRESET WSAECONNRESET | 108 | # include <io.h> |
| 84 | # define ENOTCONN WSAENOTCONN | 109 | |
| 85 | # define ESHUTDOWN WSAESHUTDOWN | 110 | typedef int socklen_t; |
| 111 | |||
| 112 | # endif | ||
| 113 | |||
| 114 | # ifdef __cplusplus | ||
| 115 | extern "C" { | ||
| 116 | # endif | ||
| 117 | |||
| 118 | # if @HAVE_WINSOCK2_H@ | ||
| 119 | |||
| 120 | /* Re-define FD_ISSET to avoid a WSA call while we are not using | ||
| 121 | network sockets. */ | ||
| 122 | static inline int | ||
| 123 | rpl_fd_isset (SOCKET fd, fd_set * set) | ||
| 124 | { | ||
| 125 | u_int i; | ||
| 126 | if (set == NULL) | ||
| 127 | return 0; | ||
| 128 | |||
| 129 | for (i = 0; i < set->fd_count; i++) | ||
| 130 | if (set->fd_array[i] == fd) | ||
| 131 | return 1; | ||
| 132 | |||
| 133 | return 0; | ||
| 134 | } | ||
| 135 | |||
| 136 | # undef FD_ISSET | ||
| 137 | # define FD_ISSET(fd, set) rpl_fd_isset(fd, set) | ||
| 138 | |||
| 139 | # endif | ||
| 140 | |||
| 141 | /* Wrap everything else to use libc file descriptors for sockets. */ | ||
| 142 | |||
| 143 | # if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H | ||
| 144 | # undef close | ||
| 145 | # define close close_used_without_including_unistd_h | ||
| 146 | # endif | ||
| 147 | |||
| 148 | # if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H | ||
| 149 | # undef gethostname | ||
| 150 | # define gethostname gethostname_used_without_including_unistd_h | ||
| 151 | # endif | ||
| 152 | |||
| 153 | # if @GNULIB_SOCKET@ | ||
| 154 | # if @HAVE_WINSOCK2_H@ | ||
| 155 | # undef socket | ||
| 156 | # define socket rpl_socket | ||
| 157 | extern int rpl_socket (int, int, int protocol); | ||
| 158 | # endif | ||
| 159 | # elif @HAVE_WINSOCK2_H@ | ||
| 160 | # undef socket | ||
| 161 | # define socket socket_used_without_requesting_gnulib_module_socket | ||
| 162 | # elif defined GNULIB_POSIXCHECK | ||
| 163 | # undef socket | ||
| 164 | # define socket(d,t,p) \ | ||
| 165 | (GL_LINK_WARNING ("socket is not always POSIX compliant - " \ | ||
| 166 | "use gnulib module socket for portability"), \ | ||
| 167 | socket (d, t, p)) | ||
| 168 | # endif | ||
| 169 | |||
| 170 | # if @GNULIB_CONNECT@ | ||
| 171 | # if @HAVE_WINSOCK2_H@ | ||
| 172 | # undef connect | ||
| 173 | # define connect rpl_connect | ||
| 174 | extern int rpl_connect (int, struct sockaddr *, int); | ||
| 175 | # endif | ||
| 176 | # elif @HAVE_WINSOCK2_H@ | ||
| 177 | # undef connect | ||
| 178 | # define connect socket_used_without_requesting_gnulib_module_connect | ||
| 179 | # elif defined GNULIB_POSIXCHECK | ||
| 180 | # undef connect | ||
| 181 | # define connect(s,a,l) \ | ||
| 182 | (GL_LINK_WARNING ("connect is not always POSIX compliant - " \ | ||
| 183 | "use gnulib module connect for portability"), \ | ||
| 184 | connect (s, a, l)) | ||
| 185 | # endif | ||
| 186 | |||
| 187 | # if @GNULIB_ACCEPT@ | ||
| 188 | # if @HAVE_WINSOCK2_H@ | ||
| 189 | # undef accept | ||
| 190 | # define accept rpl_accept | ||
| 191 | extern int rpl_accept (int, struct sockaddr *, int *); | ||
| 192 | # endif | ||
| 193 | # elif @HAVE_WINSOCK2_H@ | ||
| 194 | # undef accept | ||
| 195 | # define accept accept_used_without_requesting_gnulib_module_accept | ||
| 196 | # elif defined GNULIB_POSIXCHECK | ||
| 197 | # undef accept | ||
| 198 | # define accept(s,a,l) \ | ||
| 199 | (GL_LINK_WARNING ("accept is not always POSIX compliant - " \ | ||
| 200 | "use gnulib module accept for portability"), \ | ||
| 201 | accept (s, a, l)) | ||
| 202 | # endif | ||
| 203 | |||
| 204 | # if @GNULIB_BIND@ | ||
| 205 | # if @HAVE_WINSOCK2_H@ | ||
| 206 | # undef bind | ||
| 207 | # define bind rpl_bind | ||
| 208 | extern int rpl_bind (int, struct sockaddr *, int); | ||
| 209 | # endif | ||
| 210 | # elif @HAVE_WINSOCK2_H@ | ||
| 211 | # undef bind | ||
| 212 | # define bind bind_used_without_requesting_gnulib_module_bind | ||
| 213 | # elif defined GNULIB_POSIXCHECK | ||
| 214 | # undef bind | ||
| 215 | # define bind(s,a,l) \ | ||
| 216 | (GL_LINK_WARNING ("bind is not always POSIX compliant - " \ | ||
| 217 | "use gnulib module bind for portability"), \ | ||
| 218 | bind (s, a, l)) | ||
| 219 | # endif | ||
| 220 | |||
| 221 | # if @GNULIB_GETPEERNAME@ | ||
| 222 | # if @HAVE_WINSOCK2_H@ | ||
| 223 | # undef getpeername | ||
| 224 | # define getpeername rpl_getpeername | ||
| 225 | extern int rpl_getpeername (int, struct sockaddr *, int *); | ||
| 226 | # endif | ||
| 227 | # elif @HAVE_WINSOCK2_H@ | ||
| 228 | # undef getpeername | ||
| 229 | # define getpeername getpeername_used_without_requesting_gnulib_module_getpeername | ||
| 230 | # elif defined GNULIB_POSIXCHECK | ||
| 231 | # undef getpeername | ||
| 232 | # define getpeername(s,a,l) \ | ||
| 233 | (GL_LINK_WARNING ("getpeername is not always POSIX compliant - " \ | ||
| 234 | "use gnulib module getpeername for portability"), \ | ||
| 235 | getpeername (s, a, l)) | ||
| 236 | # endif | ||
| 237 | |||
| 238 | # if @GNULIB_GETSOCKNAME@ | ||
| 239 | # if @HAVE_WINSOCK2_H@ | ||
| 240 | # undef getsockname | ||
| 241 | # define getsockname rpl_getsockname | ||
| 242 | extern int rpl_getsockname (int, struct sockaddr *, int *); | ||
| 243 | # endif | ||
| 244 | # elif @HAVE_WINSOCK2_H@ | ||
| 245 | # undef getsockname | ||
| 246 | # define getsockname getsockname_used_without_requesting_gnulib_module_getsockname | ||
| 247 | # elif defined GNULIB_POSIXCHECK | ||
| 248 | # undef getsockname | ||
| 249 | # define getsockname(s,a,l) \ | ||
| 250 | (GL_LINK_WARNING ("getsockname is not always POSIX compliant - " \ | ||
| 251 | "use gnulib module getsockname for portability"), \ | ||
| 252 | getsockname (s, a, l)) | ||
| 253 | # endif | ||
| 254 | |||
| 255 | # if @GNULIB_GETSOCKOPT@ | ||
| 256 | # if @HAVE_WINSOCK2_H@ | ||
| 257 | # undef getsockopt | ||
| 258 | # define getsockopt rpl_getsockopt | ||
| 259 | extern int rpl_getsockopt (int, int, int, void *, int *); | ||
| 260 | # endif | ||
| 261 | # elif @HAVE_WINSOCK2_H@ | ||
| 262 | # undef getsockopt | ||
| 263 | # define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt | ||
| 264 | # elif defined GNULIB_POSIXCHECK | ||
| 265 | # undef getsockopt | ||
| 266 | # define getsockopt(s,lvl,o,v,l) \ | ||
| 267 | (GL_LINK_WARNING ("getsockopt is not always POSIX compliant - " \ | ||
| 268 | "use gnulib module getsockopt for portability"), \ | ||
| 269 | getsockopt (s, lvl, o, v, l)) | ||
| 270 | # endif | ||
| 271 | |||
| 272 | # if @GNULIB_LISTEN@ | ||
| 273 | # if @HAVE_WINSOCK2_H@ | ||
| 274 | # undef listen | ||
| 275 | # define listen rpl_listen | ||
| 276 | extern int rpl_listen (int, int); | ||
| 277 | # endif | ||
| 278 | # elif @HAVE_WINSOCK2_H@ | ||
| 279 | # undef listen | ||
| 280 | # define listen listen_used_without_requesting_gnulib_module_listen | ||
| 281 | # elif defined GNULIB_POSIXCHECK | ||
| 282 | # undef listen | ||
| 283 | # define listen(s,b) \ | ||
| 284 | (GL_LINK_WARNING ("listen is not always POSIX compliant - " \ | ||
| 285 | "use gnulib module listen for portability"), \ | ||
| 286 | listen (s, b)) | ||
| 287 | # endif | ||
| 288 | |||
| 289 | # if @GNULIB_RECV@ | ||
| 290 | # if @HAVE_WINSOCK2_H@ | ||
| 291 | # undef recv | ||
| 292 | # define recv rpl_recv | ||
| 293 | extern int rpl_recv (int, void *, int, int); | ||
| 294 | # endif | ||
| 295 | # elif @HAVE_WINSOCK2_H@ | ||
| 296 | # undef recv | ||
| 297 | # define recv recv_used_without_requesting_gnulib_module_recv | ||
| 298 | # elif defined GNULIB_POSIXCHECK | ||
| 299 | # undef recv | ||
| 300 | # define recv(s,b,n,f) \ | ||
| 301 | (GL_LINK_WARNING ("recv is not always POSIX compliant - " \ | ||
| 302 | "use gnulib module recv for portability"), \ | ||
| 303 | recv (s, b, n, f)) | ||
| 304 | # endif | ||
| 305 | |||
| 306 | # if @GNULIB_SEND@ | ||
| 307 | # if @HAVE_WINSOCK2_H@ | ||
| 308 | # undef send | ||
| 309 | # define send rpl_send | ||
| 310 | extern int rpl_send (int, const void *, int, int); | ||
| 311 | # endif | ||
| 312 | # elif @HAVE_WINSOCK2_H@ | ||
| 313 | # undef send | ||
| 314 | # define send send_used_without_requesting_gnulib_module_send | ||
| 315 | # elif defined GNULIB_POSIXCHECK | ||
| 316 | # undef send | ||
| 317 | # define send(s,b,n,f) \ | ||
| 318 | (GL_LINK_WARNING ("send is not always POSIX compliant - " \ | ||
| 319 | "use gnulib module send for portability"), \ | ||
| 320 | send (s, b, n, f)) | ||
| 321 | # endif | ||
| 322 | |||
| 323 | # if @GNULIB_RECVFROM@ | ||
| 324 | # if @HAVE_WINSOCK2_H@ | ||
| 325 | # undef recvfrom | ||
| 326 | # define recvfrom rpl_recvfrom | ||
| 327 | extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *); | ||
| 328 | # endif | ||
| 329 | # elif @HAVE_WINSOCK2_H@ | ||
| 330 | # undef recvfrom | ||
| 331 | # define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom | ||
| 332 | # elif defined GNULIB_POSIXCHECK | ||
| 333 | # undef recvfrom | ||
| 334 | # define recvfrom(s,b,n,f,a,l) \ | ||
| 335 | (GL_LINK_WARNING ("recvfrom is not always POSIX compliant - " \ | ||
| 336 | "use gnulib module recvfrom for portability"), \ | ||
| 337 | recvfrom (s, b, n, f, a, l)) | ||
| 338 | # endif | ||
| 339 | |||
| 340 | # if @GNULIB_SENDTO@ | ||
| 341 | # if @HAVE_WINSOCK2_H@ | ||
| 342 | # undef sendto | ||
| 343 | # define sendto rpl_sendto | ||
| 344 | extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int); | ||
| 345 | # endif | ||
| 346 | # elif @HAVE_WINSOCK2_H@ | ||
| 347 | # undef sendto | ||
| 348 | # define sendto sendto_used_without_requesting_gnulib_module_sendto | ||
| 349 | # elif defined GNULIB_POSIXCHECK | ||
| 350 | # undef sendto | ||
| 351 | # define sendto(s,b,n,f,a,l) \ | ||
| 352 | (GL_LINK_WARNING ("sendto is not always POSIX compliant - " \ | ||
| 353 | "use gnulib module sendto for portability"), \ | ||
| 354 | sendto (s, b, n, f, a, l)) | ||
| 355 | # endif | ||
| 356 | |||
| 357 | # if @GNULIB_SETSOCKOPT@ | ||
| 358 | # if @HAVE_WINSOCK2_H@ | ||
| 359 | # undef setsockopt | ||
| 360 | # define setsockopt rpl_setsockopt | ||
| 361 | extern int rpl_setsockopt (int, int, int, const void *, int); | ||
| 362 | # endif | ||
| 363 | # elif @HAVE_WINSOCK2_H@ | ||
| 364 | # undef setsockopt | ||
| 365 | # define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt | ||
| 366 | # elif defined GNULIB_POSIXCHECK | ||
| 367 | # undef setsockopt | ||
| 368 | # define setsockopt(s,lvl,o,v,l) \ | ||
| 369 | (GL_LINK_WARNING ("setsockopt is not always POSIX compliant - " \ | ||
| 370 | "use gnulib module setsockopt for portability"), \ | ||
| 371 | setsockopt (s, lvl, o, v, l)) | ||
| 372 | # endif | ||
| 373 | |||
| 374 | # if @GNULIB_SHUTDOWN@ | ||
| 375 | # if @HAVE_WINSOCK2_H@ | ||
| 376 | # undef shutdown | ||
| 377 | # define shutdown rpl_shutdown | ||
| 378 | extern int rpl_shutdown (int, int); | ||
| 379 | # endif | ||
| 380 | # elif @HAVE_WINSOCK2_H@ | ||
| 381 | # undef shutdown | ||
| 382 | # define shutdown shutdown_used_without_requesting_gnulib_module_shutdown | ||
| 383 | # elif defined GNULIB_POSIXCHECK | ||
| 384 | # undef shutdown | ||
| 385 | # define shutdown(s,h) \ | ||
| 386 | (GL_LINK_WARNING ("shutdown is not always POSIX compliant - " \ | ||
| 387 | "use gnulib module shutdown for portability"), \ | ||
| 388 | shutdown (s, h)) | ||
| 389 | # endif | ||
| 390 | |||
| 391 | # if @HAVE_WINSOCK2_H@ | ||
| 392 | # undef select | ||
| 393 | # define select select_used_without_including_sys_select_h | ||
| 394 | # endif | ||
| 395 | |||
| 396 | # ifdef __cplusplus | ||
| 397 | } | ||
| 86 | # endif | 398 | # endif |
| 87 | 399 | ||
| 88 | #endif /* HAVE_SYS_SOCKET_H */ | 400 | #endif /* HAVE_SYS_SOCKET_H */ |
