+typedef struct {
+ uint8_t status;
+ uint8_t pad0[5];
+ uint16_t length;
+} xcb_setup_generic_t;
+
+static const int error_connection = 1;
+
+static int set_fd_flags(const int fd)
+{
+ int 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 _xcb_xlib_init(_xcb_xlib *xlib)
+{
+ xlib->lock = 0;
+ pthread_cond_init(&xlib->cond, 0);
+ return 1;
+}
+
+static void _xcb_xlib_destroy(_xcb_xlib *xlib)
+{
+ pthread_cond_destroy(&xlib->cond);
+}
+
+static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)