diff options
Diffstat (limited to 'libxcb/src/xcb_conn.c')
-rw-r--r-- | libxcb/src/xcb_conn.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libxcb/src/xcb_conn.c b/libxcb/src/xcb_conn.c index 251d62e01..cdb71e4e1 100644 --- a/libxcb/src/xcb_conn.c +++ b/libxcb/src/xcb_conn.c @@ -30,7 +30,12 @@ #include <stdio.h> #include <unistd.h> #include <stdlib.h> +#ifdef _MSC_VER +#include <X11/Xwinsock.h> +#define STDERR_FILENO stderr +#else #include <netinet/in.h> +#endif #include <fcntl.h> #include <errno.h> @@ -42,6 +47,8 @@ #include <sys/select.h> #endif +#include <X11/Xtrans/Xtrans.h> + typedef struct { uint8_t status; uint8_t pad0[5]; @@ -50,8 +57,50 @@ typedef struct { static const int error_connection = 1; +#ifdef _MSC_VER +#undef close +#define close(fd) closesocket(fd) + +size_t writev(int fildes, const struct iovec *iov, int iovcnt) +{ + int i, r; + char *p; + size_t l, sum; + + /* We should buffer */ + sum= 0; + for (i= 0; i<iovcnt; i++) + { + p= iov[i].iov_base; + l= iov[i].iov_len; + while (l > 0) + { + r= send(fildes, p, l, 0); + if (r <= 0) + { + errno =WSAGetLastError(); + if(errno == WSAEWOULDBLOCK) + errno = EAGAIN; + if (sum) + return sum; + else + return r; + } + p += r; + l -= r; + sum += r; + } + } + return sum; +} +#endif + static int set_fd_flags(const int fd) { +#ifdef _MSC_VER + unsigned long arg = 1; + int ret = ioctlsocket (fd, FIONBIO, &arg); +#else int flags = fcntl(fd, F_GETFL, 0); if(flags == -1) return 0; @@ -60,6 +109,7 @@ static int set_fd_flags(const int fd) return 0; if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) return 0; +#endif return 1; } @@ -306,6 +356,13 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec ret = poll(&fd, 1, -1); #else ret = select(c->fd + 1, &rfds, &wfds, 0, 0); + if (ret==SOCKET_ERROR) + { + ret=-1; + errno = WSAGetLastError(); + if (errno == WSAEINTR) + errno=EINTR; + } #endif } while (ret == -1 && errno == EINTR); if (ret < 0) |