diff options
author | Peter Harris <pharris@opentext.com> | 2021-02-01 17:43:52 -0500 |
---|---|---|
committer | Peter Harris <pharris@opentext.com> | 2021-06-04 14:31:13 +0000 |
commit | 4b0d9d3868aad8d5f4266821e9eda586e6c2bfa7 (patch) | |
tree | d31a073fa5d036d5ec404b539fac44cbc5be18d3 /src/xcb_conn.c | |
parent | cd0fba98a2d0867d505ff1a7ca8d7a7c757acfa2 (diff) |
Fix build on Windows
Notable changes: Protect include of unistd.h (and other POSIX headers).
Use SOCKET (which is larger than int) and closesocket (because close is
not compatible) for sockets. Use <stdint.h>'s intptr_t instead of the
non-portable ssize_t.
Signed-off-by: Peter Harris <pharris@opentext.com>
Diffstat (limited to 'src/xcb_conn.c')
-rw-r--r-- | src/xcb_conn.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 8dab658..158f676 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -32,7 +32,6 @@ #include <assert.h> #include <string.h> #include <stdio.h> -#include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <errno.h> @@ -48,7 +47,9 @@ #ifdef _WIN32 #include "xcb_windefs.h" +#include <io.h> #else +#include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #endif /* _WIN32 */ @@ -345,7 +346,11 @@ xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info) c = calloc(1, sizeof(xcb_connection_t)); if(!c) { +#ifdef _WIN32 + closesocket(fd); +#else close(fd); +#endif return _xcb_conn_ret_error(XCB_CONN_CLOSED_MEM_INSUFFICIENT) ; } @@ -378,7 +383,11 @@ void xcb_disconnect(xcb_connection_t *c) /* disallow further sends and receives */ shutdown(c->fd, SHUT_RDWR); +#ifdef _WIN32 + closesocket(c->fd); +#else close(c->fd); +#endif pthread_mutex_destroy(&c->iolock); _xcb_in_destroy(&c->in); |