[Xcb] [RFC libxcb 5/5] Complete uint64_t sequence changes

Daniel Martin consume.noise at gmail.com
Tue Jun 4 15:52:06 PDT 2013


Change the type of the sequence in a cookie and related functions to
uint64_t sequences, too. With that, we use 64bit sequences from the
beginning to the end in libxcb.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 src/c_client.py |  2 +-
 src/xcb.h       |  4 ++--
 src/xcb_in.c    | 22 +++++++---------------
 src/xcb_list.c  |  6 +++---
 src/xcb_out.c   |  6 +++---
 src/xcbext.h    |  6 +++---
 src/xcbint.h    |  4 ++--
 7 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/src/c_client.py b/src/c_client.py
index 942e78a..3b71cb4 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -2271,7 +2271,7 @@ def _c_cookie(self, name):
     _h(' * @brief %s', self.c_cookie_type)
     _h(' **/')
     _h('typedef struct %s {', self.c_cookie_type)
-    _h('    unsigned int sequence; /**<  */')
+    _h('    uint64_t sequence; /**<  */')
     _h('} %s;', self.c_cookie_type)
 
 def _man_request(self, name, cookie_type, void, aux):
diff --git a/src/xcb.h b/src/xcb.h
index 3cc85c0..d6c905e 100644
--- a/src/xcb.h
+++ b/src/xcb.h
@@ -174,7 +174,7 @@ typedef struct {
  * A generic cookie structure.
  */
 typedef struct {
-    unsigned int sequence;  /**< Sequence number */
+    uint64_t sequence;  /**< Sequence number */
 } xcb_void_cookie_t;
 
 
@@ -359,7 +359,7 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
  * Note that the sequence really does have to come from an xcb cookie;
  * this function is not designed to operate on socket-handoff replies.
  */
-void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
+void xcb_discard_reply(xcb_connection_t *c, uint64_t sequence);
 
 
 /* xcb_ext.c */
diff --git a/src/xcb_in.c b/src/xcb_in.c
index b8eeeb0..6239bad 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -439,17 +439,9 @@ static void *wait_for_reply(xcb_connection_t *c, uint64_t request, xcb_generic_e
     return ret;
 }
 
-static uint64_t widen(xcb_connection_t *c, unsigned int request)
-{
-    uint64_t widened_request = (c->out.request & UINT64_C(0xffffffff00000000)) | request;
-    if(widened_request > c->out.request)
-        widened_request -= UINT64_C(1) << 32;
-    return widened_request;
-}
-
 /* Public interface */
 
-void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e)
+void *xcb_wait_for_reply(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e)
 {
     void *ret;
     if(e)
@@ -458,7 +450,7 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
         return 0;
 
     pthread_mutex_lock(&c->iolock);
-    ret = wait_for_reply(c, widen(c, request), e);
+    ret = wait_for_reply(c, request, e);
     pthread_mutex_unlock(&c->iolock);
     return ret;
 }
@@ -516,7 +508,7 @@ static void discard_reply(xcb_connection_t *c, uint64_t request)
     insert_pending_discard(c, prev_pend, request);
 }
 
-void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
+void xcb_discard_reply(xcb_connection_t *c, uint64_t sequence)
 {
     if(c->has_error)
         return;
@@ -526,11 +518,11 @@ void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
         return;
 
     pthread_mutex_lock(&c->iolock);
-    discard_reply(c, widen(c, sequence));
+    discard_reply(c, sequence);
     pthread_mutex_unlock(&c->iolock);
 }
 
-int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error)
+int xcb_poll_for_reply(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error)
 {
     int ret;
     if(c->has_error)
@@ -542,7 +534,7 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply,
     }
     assert(reply != 0);
     pthread_mutex_lock(&c->iolock);
-    ret = poll_for_reply(c, widen(c, request), reply, error);
+    ret = poll_for_reply(c, request, reply, error);
     pthread_mutex_unlock(&c->iolock);
     return ret;
 }
@@ -575,7 +567,7 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
     if(c->has_error)
         return 0;
     pthread_mutex_lock(&c->iolock);
-    request = widen(c, cookie.sequence);
+    request = cookie.sequence;
     if(XCB_SEQUENCE_COMPARE(request, >=, c->in.request_expected)
        && XCB_SEQUENCE_COMPARE(request, >, c->in.request_completed))
     {
diff --git a/src/xcb_list.c b/src/xcb_list.c
index 6f5c611..5f11476 100644
--- a/src/xcb_list.c
+++ b/src/xcb_list.c
@@ -36,7 +36,7 @@
 
 typedef struct node {
     struct node *next;
-    unsigned int key;
+    uint64_t key;
     void *data;
 } node;
 
@@ -73,7 +73,7 @@ void _xcb_map_delete(_xcb_map *list, xcb_list_free_func_t do_free)
     free(list);
 }
 
-int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
+int _xcb_map_put(_xcb_map *list, uint64_t key, void *data)
 {
     node *cur = malloc(sizeof(node));
     if(!cur)
@@ -86,7 +86,7 @@ int _xcb_map_put(_xcb_map *list, unsigned int key, void *data)
     return 1;
 }
 
-void *_xcb_map_remove(_xcb_map *list, unsigned int key)
+void *_xcb_map_remove(_xcb_map *list, uint64_t key)
 {
     node **cur;
     for(cur = &list->head; *cur; cur = &(*cur)->next)
diff --git a/src/xcb_out.c b/src/xcb_out.c
index a4f52fb..3498851 100644
--- a/src/xcb_out.c
+++ b/src/xcb_out.c
@@ -150,7 +150,7 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c)
     return c->out.maximum_request_length.value;
 }
 
-unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
+uint64_t xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
 {
     uint64_t request;
     uint32_t prefix[2];
@@ -245,10 +245,10 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
      * a reply. */
     if(req->isvoid && c->out.request == c->in.request_expected + (1 << 16) - 2)
         send_sync(c);
-    /* Also send sync_req (could use NoOp) at 32-bit wrap to avoid having
+    /* Also send sync_req (could use NoOp) at 64-bit wrap to avoid having
      * applications see sequence 0 as that is used to indicate
      * an error in sending the request */
-    if((unsigned int) (c->out.request + 1) == 0)
+    if((c->out.request + 1) == 0)
         send_sync(c);
 
     /* The above send_sync calls could drop the I/O lock, but this
diff --git a/src/xcbext.h b/src/xcbext.h
index 98b3c93..8a2ec81 100644
--- a/src/xcbext.h
+++ b/src/xcbext.h
@@ -57,7 +57,7 @@ enum xcb_send_request_flags_t {
     XCB_REQUEST_DISCARD_REPLY = 1 << 2
 };
 
-unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
+uint64_t xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
 
 /* xcb_take_socket allows external code to ask XCB for permission to
  * take over the write side of the socket and send raw data with
@@ -86,8 +86,8 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
 
 /* xcb_in.c */
 
-void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
-int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
+void *xcb_wait_for_reply(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
+int xcb_poll_for_reply(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
 
 
 /* xcb_util.c */
diff --git a/src/xcbint.h b/src/xcbint.h
index f9e5a52..314133c 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -73,8 +73,8 @@ typedef struct _xcb_map _xcb_map;
 
 _xcb_map *_xcb_map_new(void);
 void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
-int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
-void *_xcb_map_remove(_xcb_map *q, unsigned int key);
+int _xcb_map_put(_xcb_map *q, uint64_t key, void *data);
+void *_xcb_map_remove(_xcb_map *q, uint64_t key);
 
 
 /* xcb_out.c */
-- 
1.8.3



More information about the Xcb mailing list