aboutsummaryrefslogtreecommitdiff
path: root/libxcb/src/xcb_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'libxcb/src/xcb_util.c')
-rwxr-xr-x[-rw-r--r--]libxcb/src/xcb_util.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libxcb/src/xcb_util.c b/libxcb/src/xcb_util.c
index ba0f10867..0f4193d4c 100644..100755
--- a/libxcb/src/xcb_util.c
+++ b/libxcb/src/xcb_util.c
@@ -64,6 +64,13 @@
#include <sys/stat.h>
#endif
+#ifdef _MSC_VER
+#ifdef close
+#undef close
+#endif
+#define close(fd) closesocket(fd)
+#endif
+
int xcb_popcount(uint32_t mask)
{
uint32_t y;
@@ -327,7 +334,7 @@ static int _xcb_socket(int family, int type, int proto)
static int _xcb_do_connect(int fd, const struct sockaddr* addr, int addrlen) {
- int on = 1;
+ char on = 1;
if(fd < 0)
return -1;
@@ -338,6 +345,23 @@ static int _xcb_do_connect(int fd, const struct sockaddr* addr, int addrlen) {
return connect(fd, addr, addrlen);
}
+#ifdef WIN32
+int InitWSA(void)
+{
+ static WSADATA wsadata;
+
+ if (!wsadata.wVersion)
+ {
+ ptw32_processInitialize();
+ if (WSAStartup(0x0202, &wsadata))
+ return -1;
+ }
+ return 0;
+}
+#else
+#define InitWSA()
+#endif
+
static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short port)
{
int fd = -1;
@@ -377,6 +401,11 @@ static int _xcb_open_tcp(const char *host, char *protocol, const unsigned short
}
#endif
+#ifdef WIN32
+ if (InitWSA()<0)
+ return -1;
+#endif
+
snprintf(service, sizeof(service), "%hu", port);
if(getaddrinfo(host, service, &hints, &results))
/* FIXME: use gai_strerror, and fill in error connection */