Inline _xcb_lock_io, _xcb_unlock_io, and _xcb_wait_io.
authorJamey Sharp <jamey@minilop.net>
Fri, 14 Mar 2008 19:08:58 +0000 (12:08 -0700)
committerJamey Sharp <jamey@minilop.net>
Wed, 29 Oct 2008 22:40:41 +0000 (15:40 -0700)
These functions are once again a single pthread call, so just make that
call directly.

src/xcb_conn.c
src/xcb_in.c
src/xcb_out.c
src/xcbint.h

index 2bb8661..5b097f7 100644 (file)
@@ -97,12 +97,12 @@ static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
     }
     assert(count <= (int) (sizeof(parts) / sizeof(*parts)));
 
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
     {
         struct iovec *parts_ptr = parts;
         ret = _xcb_out_send(c, &parts_ptr, &count);
     }
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     return ret;
 }
 
@@ -255,21 +255,6 @@ void _xcb_conn_shutdown(xcb_connection_t *c)
     c->has_error = 1;
 }
 
-void _xcb_lock_io(xcb_connection_t *c)
-{
-    pthread_mutex_lock(&c->iolock);
-}
-
-void _xcb_unlock_io(xcb_connection_t *c)
-{
-    pthread_mutex_unlock(&c->iolock);
-}
-
-void _xcb_wait_io(xcb_connection_t *c, pthread_cond_t *cond)
-{
-    pthread_cond_wait(cond, &c->iolock);
-}
-
 int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count)
 {
     int ret;
@@ -278,7 +263,7 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
     /* If the thing I should be doing is already being done, wait for it. */
     if(count ? c->out.writing : c->in.reading)
     {
-        _xcb_wait_io(c, cond);
+        pthread_cond_wait(cond, &c->iolock);
         return 1;
     }
 
@@ -293,7 +278,7 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
         ++c->out.writing;
     }
 
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     do {
        ret = select(c->fd + 1, &rfds, &wfds, 0, 0);
     } while (ret == -1 && errno == EINTR);
@@ -302,7 +287,7 @@ int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vec
         _xcb_conn_shutdown(c);
        ret = 0;
     }
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
 
     if(ret)
     {
index f613772..a0e5e10 100644 (file)
@@ -341,7 +341,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
     if(c->has_error)
         return 0;
 
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
 
     /* If this request has not been written yet, write it. */
     if(_xcb_out_flush_to(c, request))
@@ -381,7 +381,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
     }
 
     wake_up_next_reader(c);
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     return ret;
 }
 
@@ -396,9 +396,9 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply,
         return 1; /* would not block */
     }
     assert(reply != 0);
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
     ret = poll_for_reply(c, request, reply, error);
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     return ret;
 }
 
@@ -407,14 +407,14 @@ xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
     xcb_generic_event_t *ret;
     if(c->has_error)
         return 0;
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
     /* get_event returns 0 on empty list. */
     while(!(ret = get_event(c)))
         if(!_xcb_conn_wait(c, &c->in.event_cond, 0, 0))
             break;
 
     wake_up_next_reader(c);
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     return ret;
 }
 
@@ -423,12 +423,12 @@ xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c)
     xcb_generic_event_t *ret = 0;
     if(!c->has_error)
     {
-        _xcb_lock_io(c);
+        pthread_mutex_lock(&c->iolock);
         /* FIXME: follow X meets Z architecture changes. */
         ret = get_event(c);
         if(!ret && _xcb_in_read(c)) /* _xcb_in_read shuts down the connection on error */
             ret = get_event(c);
-        _xcb_unlock_io(c);
+        pthread_mutex_unlock(&c->iolock);
     }
     return ret;
 }
index 000b121..ad4240a 100644 (file)
@@ -187,10 +187,10 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
         workaround = WORKAROUND_GLX_GET_FB_CONFIGS_BUG;
 
     /* get a sequence number and arrange for delivery. */
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
     /* wait for other writing threads to get out of my way. */
     while(c->out.writing)
-        _xcb_wait_io(c, &c->out.cond);
+        pthread_cond_wait(&c->out.cond, &c->iolock);
 
     request = ++c->out.request;
     /* send GetInputFocus (sync_req) when 64k-2 requests have been sent without
@@ -231,7 +231,7 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
         _xcb_conn_shutdown(c);
         request = 0;
     }
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     return request;
 }
 
@@ -240,9 +240,9 @@ int xcb_flush(xcb_connection_t *c)
     int ret;
     if(c->has_error)
         return 0;
-    _xcb_lock_io(c);
+    pthread_mutex_lock(&c->iolock);
     ret = _xcb_out_flush_to(c, c->out.request);
-    _xcb_unlock_io(c);
+    pthread_mutex_unlock(&c->iolock);
     return ret;
 }
 
@@ -297,7 +297,7 @@ int _xcb_out_flush_to(xcb_connection_t *c, unsigned int request)
         return _xcb_out_send(c, &vec_ptr, &count);
     }
     while(c->out.writing)
-        _xcb_wait_io(c, &c->out.cond);
+        pthread_cond_wait(&c->out.cond, &c->iolock);
     assert(XCB_SEQUENCE_COMPARE(c->out.request_written, >=, request));
     return 1;
 }
index 909f043..a85b04e 100644 (file)
@@ -172,9 +172,6 @@ struct xcb_connection_t {
 };
 
 void _xcb_conn_shutdown(xcb_connection_t *c);
-void _xcb_lock_io(xcb_connection_t *c);
-void _xcb_unlock_io(xcb_connection_t *c);
-void _xcb_wait_io(xcb_connection_t *c, pthread_cond_t *cond);
 int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);