diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xcb_conn.c | 16 | ||||
-rw-r--r-- | src/xcb_util.c | 20 | ||||
-rw-r--r-- | src/xcbint.h | 9 |
3 files changed, 17 insertions, 28 deletions
diff --git a/src/xcb_conn.c b/src/xcb_conn.c index 698cf51..5839ed8 100644 --- a/src/xcb_conn.c +++ b/src/xcb_conn.c @@ -32,10 +32,24 @@ #include <stdlib.h> #include <netinet/in.h> #include <sys/select.h> +#include <sys/fcntl.h> #include "xcb.h" #include "xcbint.h" +static int set_fd_flags(const int fd) +{ + long flags = fcntl(fd, F_GETFL, 0); + if(flags == -1) + return 0; + flags |= O_NONBLOCK; + if(fcntl(fd, F_SETFL, flags) == -1) + return 0; + if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) + return 0; + return 1; +} + static int write_setup(XCBConnection *c, XCBAuthInfo *auth_info) { static const char pad[3]; @@ -147,7 +161,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info) c->fd = fd; if(!( - _xcb_set_fd_flags(fd) && + set_fd_flags(fd) && pthread_mutex_init(&c->iolock, 0) == 0 && _xcb_in_init(&c->in) && _xcb_out_init(&c->out) && diff --git a/src/xcb_util.c b/src/xcb_util.c index b7f5ffa..3d6006c 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -28,7 +28,6 @@ #include <assert.h> #include <sys/select.h> #include <sys/socket.h> -#include <sys/fcntl.h> #include <sys/un.h> #include <netinet/in.h> #include <netdb.h> @@ -197,22 +196,3 @@ int XCBSync(XCBConnection *c, XCBGenericError **e) free(reply); return reply != 0; } - -/* The functions beyond this point still use only public interfaces, - * but are not themselves part of the public interface. So their - * prototypes are in xcbint.h. */ - -#include "xcbint.h" - -int _xcb_set_fd_flags(const int fd) -{ - long flags = fcntl(fd, F_GETFL, 0); - if(flags == -1) - return 0; - flags |= O_NONBLOCK; - if(fcntl(fd, F_SETFL, flags) == -1) - return 0; - if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - return 0; - return 1; -} diff --git a/src/xcbint.h b/src/xcbint.h index ae36ac5..34b7197 100644 --- a/src/xcbint.h +++ b/src/xcbint.h @@ -37,6 +37,8 @@ enum workarounds { WORKAROUND_GLX_GET_FB_CONFIGS_BUG }; +#define XCB_PAD(i) (-(i) & 3) + /* xcb_list.c */ typedef struct _xcb_list _xcb_list; @@ -68,13 +70,6 @@ void *_xcb_map_get(_xcb_map *q, unsigned int key); void *_xcb_map_remove(_xcb_map *q, unsigned int key); -/* xcb_util.c */ - -#define XCB_PAD(i) (-(i) & 3) - -int _xcb_set_fd_flags(const int fd); - - /* xcb_out.c */ typedef struct _xcb_out { |