aboutsummaryrefslogtreecommitdiff
path: root/libxcb/src
diff options
context:
space:
mode:
Diffstat (limited to 'libxcb/src')
-rw-r--r--libxcb/src/xcb_conn.c7
-rw-r--r--libxcb/src/xcb_in.c28
-rw-r--r--libxcb/src/xcb_out.c16
-rw-r--r--libxcb/src/xcbint.h4
4 files changed, 26 insertions, 29 deletions
diff --git a/libxcb/src/xcb_conn.c b/libxcb/src/xcb_conn.c
index cdb71e4e1..ffd9519fb 100644
--- a/libxcb/src/xcb_conn.c
+++ b/libxcb/src/xcb_conn.c
@@ -134,7 +134,7 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
out.authorization_protocol_name_len = 0;
out.authorization_protocol_data_len = 0;
parts[count].iov_len = sizeof(xcb_setup_request_t);
- parts[count++].iov_base = &out;
+ parts[count++].iov_base = (caddr_t) &out;
parts[count].iov_len = XCB_PAD(sizeof(xcb_setup_request_t));
parts[count++].iov_base = (char *) pad;
@@ -152,10 +152,7 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
pthread_mutex_lock(&c->iolock);
- {
- struct iovec *parts_ptr = parts;
- ret = _xcb_out_send(c, &parts_ptr, &count);
- }
+ ret = _xcb_out_send(c, parts, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
diff --git a/libxcb/src/xcb_in.c b/libxcb/src/xcb_in.c
index 0e55dc42e..7ab880952 100644
--- a/libxcb/src/xcb_in.c
+++ b/libxcb/src/xcb_in.c
@@ -72,16 +72,6 @@ typedef struct reader_list {
struct reader_list *next;
} reader_list;
-static void wake_up_next_reader(xcb_connection_t *c)
-{
- int pthreadret;
- if(c->in.readers)
- pthreadret = pthread_cond_signal(c->in.readers->data);
- else
- pthreadret = pthread_cond_signal(&c->in.event_cond);
- assert(pthreadret == 0);
-}
-
static int read_packet(xcb_connection_t *c)
{
xcb_generic_reply_t genrep;
@@ -157,9 +147,7 @@ static int read_packet(xcb_connection_t *c)
/* XGE events may have sizes > 32 */
if (genrep.response_type == XCB_XGE_EVENT)
- {
- eventlength = ((xcb_ge_event_t*)&genrep)->length * 4;
- }
+ eventlength = genrep.length * 4;
buf = malloc(length + eventlength +
(genrep.response_type == XCB_REPLY ? 0 : sizeof(uint32_t)));
@@ -439,7 +427,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
pthread_cond_destroy(&cond);
}
- wake_up_next_reader(c);
+ _xcb_in_wake_up_next_reader(c);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@@ -472,7 +460,7 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
if(!_xcb_conn_wait(c, &c->in.event_cond, 0, 0))
break;
- wake_up_next_reader(c);
+ _xcb_in_wake_up_next_reader(c);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@@ -556,6 +544,16 @@ void _xcb_in_destroy(_xcb_in *in)
}
}
+void _xcb_in_wake_up_next_reader(xcb_connection_t *c)
+{
+ int pthreadret;
+ if(c->in.readers)
+ pthreadret = pthread_cond_signal(c->in.readers->data);
+ else
+ pthreadret = pthread_cond_signal(&c->in.event_cond);
+ assert(pthreadret == 0);
+}
+
int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags)
{
pending_reply *pend = malloc(sizeof(pending_reply));
diff --git a/libxcb/src/xcb_out.c b/libxcb/src/xcb_out.c
index ab08d7da9..8347c37cd 100644
--- a/libxcb/src/xcb_out.c
+++ b/libxcb/src/xcb_out.c
@@ -53,7 +53,7 @@ static int write_block(xcb_connection_t *c, struct iovec *vector, int count)
vector[0].iov_base = c->out.queue;
vector[0].iov_len = c->out.queue_len;
c->out.queue_len = 0;
- return _xcb_out_send(c, &vector, &count);
+ return _xcb_out_send(c, vector, count);
}
static void get_socket_back(xcb_connection_t *c)
@@ -284,7 +284,7 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
return 0;
pthread_mutex_lock(&c->iolock);
c->out.request += requests;
- ret = _xcb_out_send(c, &vector, &count);
+ ret = _xcb_out_send(c, vector, count);
pthread_mutex_unlock(&c->iolock);
return ret;
}
@@ -332,13 +332,14 @@ void _xcb_out_destroy(_xcb_out *out)
pthread_mutex_destroy(&out->reqlenlock);
}
-int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count)
+int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count)
{
int ret = 1;
- while(ret && *count)
- ret = _xcb_conn_wait(c, &c->out.cond, vector, count);
+ while(ret && count)
+ ret = _xcb_conn_wait(c, &c->out.cond, &vector, &count);
c->out.request_written = c->out.request;
pthread_cond_broadcast(&c->out.cond);
+ _xcb_in_wake_up_next_reader(c);
return ret;
}
@@ -349,12 +350,11 @@ int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request)
return 1;
if(c->out.queue_len)
{
- struct iovec vec, *vec_ptr = &vec;
- int count = 1;
+ struct iovec vec;
vec.iov_base = c->out.queue;
vec.iov_len = c->out.queue_len;
c->out.queue_len = 0;
- return _xcb_out_send(c, &vec_ptr, &count);
+ return _xcb_out_send(c, &vec, 1);
}
while(c->out.writing)
pthread_cond_wait(&c->out.cond, &c->iolock);
diff --git a/libxcb/src/xcbint.h b/libxcb/src/xcbint.h
index 1a7a44182..2de7e3f22 100644
--- a/libxcb/src/xcbint.h
+++ b/libxcb/src/xcbint.h
@@ -107,7 +107,7 @@ typedef struct _xcb_out {
int _xcb_out_init(_xcb_out *out);
void _xcb_out_destroy(_xcb_out *out);
-int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
+int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
@@ -138,6 +138,8 @@ typedef struct _xcb_in {
int _xcb_in_init(_xcb_in *in);
void _xcb_in_destroy(_xcb_in *in);
+void _xcb_in_wake_up_next_reader(xcb_connection_t *c);
+
int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
void _xcb_in_replies_done(xcb_connection_t *c);