Home | History | Annotate | Line # | Download | only in files
      1 /*
      2  * This file generated automatically from dri2.xml by c_client.py.
      3  * Edit at your peril.
      4  */
      5 
      6 #ifdef HAVE_CONFIG_H
      7 #include "config.h"
      8 #endif
      9 #include <stdlib.h>
     10 #include <string.h>
     11 #include <assert.h>
     12 #include <stddef.h>  /* for offsetof() */
     13 #include "xcbext.h"
     14 #include "dri2.h"
     15 
     16 #define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)
     17 #include "xproto.h"
     18 
     19 xcb_extension_t xcb_dri2_id = { "DRI2", 0 };
     20 
     21 void
     22 xcb_dri2_dri2_buffer_next (xcb_dri2_dri2_buffer_iterator_t *i)
     23 {
     24     --i->rem;
     25     ++i->data;
     26     i->index += sizeof(xcb_dri2_dri2_buffer_t);
     27 }
     28 
     29 xcb_generic_iterator_t
     30 xcb_dri2_dri2_buffer_end (xcb_dri2_dri2_buffer_iterator_t i)
     31 {
     32     xcb_generic_iterator_t ret;
     33     ret.data = i.data + i.rem;
     34     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     35     ret.rem = 0;
     36     return ret;
     37 }
     38 
     39 void
     40 xcb_dri2_attach_format_next (xcb_dri2_attach_format_iterator_t *i)
     41 {
     42     --i->rem;
     43     ++i->data;
     44     i->index += sizeof(xcb_dri2_attach_format_t);
     45 }
     46 
     47 xcb_generic_iterator_t
     48 xcb_dri2_attach_format_end (xcb_dri2_attach_format_iterator_t i)
     49 {
     50     xcb_generic_iterator_t ret;
     51     ret.data = i.data + i.rem;
     52     ret.index = i.index + ((char *) ret.data - (char *) i.data);
     53     ret.rem = 0;
     54     return ret;
     55 }
     56 
     57 xcb_dri2_query_version_cookie_t
     58 xcb_dri2_query_version (xcb_connection_t *c,
     59                         uint32_t          major_version,
     60                         uint32_t          minor_version)
     61 {
     62     static const xcb_protocol_request_t xcb_req = {
     63         .count = 2,
     64         .ext = &xcb_dri2_id,
     65         .opcode = XCB_DRI2_QUERY_VERSION,
     66         .isvoid = 0
     67     };
     68 
     69     struct iovec xcb_parts[4];
     70     xcb_dri2_query_version_cookie_t xcb_ret;
     71     xcb_dri2_query_version_request_t xcb_out;
     72 
     73     xcb_out.major_version = major_version;
     74     xcb_out.minor_version = minor_version;
     75 
     76     xcb_parts[2].iov_base = (char *) &xcb_out;
     77     xcb_parts[2].iov_len = sizeof(xcb_out);
     78     xcb_parts[3].iov_base = 0;
     79     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
     80 
     81     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
     82     return xcb_ret;
     83 }
     84 
     85 xcb_dri2_query_version_cookie_t
     86 xcb_dri2_query_version_unchecked (xcb_connection_t *c,
     87                                   uint32_t          major_version,
     88                                   uint32_t          minor_version)
     89 {
     90     static const xcb_protocol_request_t xcb_req = {
     91         .count = 2,
     92         .ext = &xcb_dri2_id,
     93         .opcode = XCB_DRI2_QUERY_VERSION,
     94         .isvoid = 0
     95     };
     96 
     97     struct iovec xcb_parts[4];
     98     xcb_dri2_query_version_cookie_t xcb_ret;
     99     xcb_dri2_query_version_request_t xcb_out;
    100 
    101     xcb_out.major_version = major_version;
    102     xcb_out.minor_version = minor_version;
    103 
    104     xcb_parts[2].iov_base = (char *) &xcb_out;
    105     xcb_parts[2].iov_len = sizeof(xcb_out);
    106     xcb_parts[3].iov_base = 0;
    107     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    108 
    109     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    110     return xcb_ret;
    111 }
    112 
    113 xcb_dri2_query_version_reply_t *
    114 xcb_dri2_query_version_reply (xcb_connection_t                 *c,
    115                               xcb_dri2_query_version_cookie_t   cookie  /**< */,
    116                               xcb_generic_error_t             **e)
    117 {
    118     return (xcb_dri2_query_version_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    119 }
    120 
    121 int
    122 xcb_dri2_connect_sizeof (const void  *_buffer)
    123 {
    124     char *xcb_tmp = (char *)_buffer;
    125     const xcb_dri2_connect_reply_t *_aux = (xcb_dri2_connect_reply_t *)_buffer;
    126     unsigned int xcb_buffer_len = 0;
    127     unsigned int xcb_block_len = 0;
    128     unsigned int xcb_pad = 0;
    129     unsigned int xcb_align_to = 0;
    130 
    131 
    132     xcb_block_len += sizeof(xcb_dri2_connect_reply_t);
    133     xcb_tmp += xcb_block_len;
    134     xcb_buffer_len += xcb_block_len;
    135     xcb_block_len = 0;
    136     /* driver_name */
    137     xcb_block_len += _aux->driver_name_length * sizeof(char);
    138     xcb_tmp += xcb_block_len;
    139     xcb_align_to = ALIGNOF(char);
    140     /* insert padding */
    141     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    142     xcb_buffer_len += xcb_block_len + xcb_pad;
    143     if (0 != xcb_pad) {
    144         xcb_tmp += xcb_pad;
    145         xcb_pad = 0;
    146     }
    147     xcb_block_len = 0;
    148     /* alignment_pad */
    149     xcb_block_len += (((_aux->driver_name_length + 3) & (~3)) - _aux->driver_name_length) * sizeof(char);
    150     xcb_tmp += xcb_block_len;
    151     xcb_align_to = ALIGNOF(char);
    152     /* insert padding */
    153     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    154     xcb_buffer_len += xcb_block_len + xcb_pad;
    155     if (0 != xcb_pad) {
    156         xcb_tmp += xcb_pad;
    157         xcb_pad = 0;
    158     }
    159     xcb_block_len = 0;
    160     /* device_name */
    161     xcb_block_len += _aux->device_name_length * sizeof(char);
    162     xcb_tmp += xcb_block_len;
    163     xcb_align_to = ALIGNOF(char);
    164     /* insert padding */
    165     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    166     xcb_buffer_len += xcb_block_len + xcb_pad;
    167     if (0 != xcb_pad) {
    168         xcb_tmp += xcb_pad;
    169         xcb_pad = 0;
    170     }
    171     xcb_block_len = 0;
    172 
    173     return xcb_buffer_len;
    174 }
    175 
    176 xcb_dri2_connect_cookie_t
    177 xcb_dri2_connect (xcb_connection_t *c,
    178                   xcb_window_t      window,
    179                   uint32_t          driver_type)
    180 {
    181     static const xcb_protocol_request_t xcb_req = {
    182         .count = 2,
    183         .ext = &xcb_dri2_id,
    184         .opcode = XCB_DRI2_CONNECT,
    185         .isvoid = 0
    186     };
    187 
    188     struct iovec xcb_parts[4];
    189     xcb_dri2_connect_cookie_t xcb_ret;
    190     xcb_dri2_connect_request_t xcb_out;
    191 
    192     xcb_out.window = window;
    193     xcb_out.driver_type = driver_type;
    194 
    195     xcb_parts[2].iov_base = (char *) &xcb_out;
    196     xcb_parts[2].iov_len = sizeof(xcb_out);
    197     xcb_parts[3].iov_base = 0;
    198     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    199 
    200     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    201     return xcb_ret;
    202 }
    203 
    204 xcb_dri2_connect_cookie_t
    205 xcb_dri2_connect_unchecked (xcb_connection_t *c,
    206                             xcb_window_t      window,
    207                             uint32_t          driver_type)
    208 {
    209     static const xcb_protocol_request_t xcb_req = {
    210         .count = 2,
    211         .ext = &xcb_dri2_id,
    212         .opcode = XCB_DRI2_CONNECT,
    213         .isvoid = 0
    214     };
    215 
    216     struct iovec xcb_parts[4];
    217     xcb_dri2_connect_cookie_t xcb_ret;
    218     xcb_dri2_connect_request_t xcb_out;
    219 
    220     xcb_out.window = window;
    221     xcb_out.driver_type = driver_type;
    222 
    223     xcb_parts[2].iov_base = (char *) &xcb_out;
    224     xcb_parts[2].iov_len = sizeof(xcb_out);
    225     xcb_parts[3].iov_base = 0;
    226     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    227 
    228     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    229     return xcb_ret;
    230 }
    231 
    232 char *
    233 xcb_dri2_connect_driver_name (const xcb_dri2_connect_reply_t *R)
    234 {
    235     return (char *) (R + 1);
    236 }
    237 
    238 int
    239 xcb_dri2_connect_driver_name_length (const xcb_dri2_connect_reply_t *R)
    240 {
    241     return R->driver_name_length;
    242 }
    243 
    244 xcb_generic_iterator_t
    245 xcb_dri2_connect_driver_name_end (const xcb_dri2_connect_reply_t *R)
    246 {
    247     xcb_generic_iterator_t i;
    248     i.data = ((char *) (R + 1)) + (R->driver_name_length);
    249     i.rem = 0;
    250     i.index = (char *) i.data - (char *) R;
    251     return i;
    252 }
    253 
    254 void *
    255 xcb_dri2_connect_alignment_pad (const xcb_dri2_connect_reply_t *R)
    256 {
    257     xcb_generic_iterator_t prev = xcb_dri2_connect_driver_name_end(R);
    258     return (void *) ((char *) prev.data + XCB_TYPE_PAD(char, prev.index) + 0);
    259 }
    260 
    261 int
    262 xcb_dri2_connect_alignment_pad_length (const xcb_dri2_connect_reply_t *R)
    263 {
    264     return (((R->driver_name_length + 3) & (~3)) - R->driver_name_length);
    265 }
    266 
    267 xcb_generic_iterator_t
    268 xcb_dri2_connect_alignment_pad_end (const xcb_dri2_connect_reply_t *R)
    269 {
    270     xcb_generic_iterator_t i;
    271     xcb_generic_iterator_t prev = xcb_dri2_connect_driver_name_end(R);
    272     i.data = ((char *) ((char*) prev.data + XCB_TYPE_PAD(char, prev.index))) + ((((R->driver_name_length + 3) & (~3)) - R->driver_name_length));
    273     i.rem = 0;
    274     i.index = (char *) i.data - (char *) R;
    275     return i;
    276 }
    277 
    278 char *
    279 xcb_dri2_connect_device_name (const xcb_dri2_connect_reply_t *R)
    280 {
    281     xcb_generic_iterator_t prev = xcb_dri2_connect_alignment_pad_end(R);
    282     return (char *) ((char *) prev.data + XCB_TYPE_PAD(char, prev.index) + 0);
    283 }
    284 
    285 int
    286 xcb_dri2_connect_device_name_length (const xcb_dri2_connect_reply_t *R)
    287 {
    288     return R->device_name_length;
    289 }
    290 
    291 xcb_generic_iterator_t
    292 xcb_dri2_connect_device_name_end (const xcb_dri2_connect_reply_t *R)
    293 {
    294     xcb_generic_iterator_t i;
    295     xcb_generic_iterator_t prev = xcb_dri2_connect_alignment_pad_end(R);
    296     i.data = ((char *) ((char*) prev.data + XCB_TYPE_PAD(char, prev.index))) + (R->device_name_length);
    297     i.rem = 0;
    298     i.index = (char *) i.data - (char *) R;
    299     return i;
    300 }
    301 
    302 xcb_dri2_connect_reply_t *
    303 xcb_dri2_connect_reply (xcb_connection_t           *c,
    304                         xcb_dri2_connect_cookie_t   cookie  /**< */,
    305                         xcb_generic_error_t       **e)
    306 {
    307     return (xcb_dri2_connect_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    308 }
    309 
    310 xcb_dri2_authenticate_cookie_t
    311 xcb_dri2_authenticate (xcb_connection_t *c,
    312                        xcb_window_t      window,
    313                        uint32_t          magic)
    314 {
    315     static const xcb_protocol_request_t xcb_req = {
    316         .count = 2,
    317         .ext = &xcb_dri2_id,
    318         .opcode = XCB_DRI2_AUTHENTICATE,
    319         .isvoid = 0
    320     };
    321 
    322     struct iovec xcb_parts[4];
    323     xcb_dri2_authenticate_cookie_t xcb_ret;
    324     xcb_dri2_authenticate_request_t xcb_out;
    325 
    326     xcb_out.window = window;
    327     xcb_out.magic = magic;
    328 
    329     xcb_parts[2].iov_base = (char *) &xcb_out;
    330     xcb_parts[2].iov_len = sizeof(xcb_out);
    331     xcb_parts[3].iov_base = 0;
    332     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    333 
    334     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    335     return xcb_ret;
    336 }
    337 
    338 xcb_dri2_authenticate_cookie_t
    339 xcb_dri2_authenticate_unchecked (xcb_connection_t *c,
    340                                  xcb_window_t      window,
    341                                  uint32_t          magic)
    342 {
    343     static const xcb_protocol_request_t xcb_req = {
    344         .count = 2,
    345         .ext = &xcb_dri2_id,
    346         .opcode = XCB_DRI2_AUTHENTICATE,
    347         .isvoid = 0
    348     };
    349 
    350     struct iovec xcb_parts[4];
    351     xcb_dri2_authenticate_cookie_t xcb_ret;
    352     xcb_dri2_authenticate_request_t xcb_out;
    353 
    354     xcb_out.window = window;
    355     xcb_out.magic = magic;
    356 
    357     xcb_parts[2].iov_base = (char *) &xcb_out;
    358     xcb_parts[2].iov_len = sizeof(xcb_out);
    359     xcb_parts[3].iov_base = 0;
    360     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    361 
    362     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    363     return xcb_ret;
    364 }
    365 
    366 xcb_dri2_authenticate_reply_t *
    367 xcb_dri2_authenticate_reply (xcb_connection_t                *c,
    368                              xcb_dri2_authenticate_cookie_t   cookie  /**< */,
    369                              xcb_generic_error_t            **e)
    370 {
    371     return (xcb_dri2_authenticate_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    372 }
    373 
    374 xcb_void_cookie_t
    375 xcb_dri2_create_drawable_checked (xcb_connection_t *c,
    376                                   xcb_drawable_t    drawable)
    377 {
    378     static const xcb_protocol_request_t xcb_req = {
    379         .count = 2,
    380         .ext = &xcb_dri2_id,
    381         .opcode = XCB_DRI2_CREATE_DRAWABLE,
    382         .isvoid = 1
    383     };
    384 
    385     struct iovec xcb_parts[4];
    386     xcb_void_cookie_t xcb_ret;
    387     xcb_dri2_create_drawable_request_t xcb_out;
    388 
    389     xcb_out.drawable = drawable;
    390 
    391     xcb_parts[2].iov_base = (char *) &xcb_out;
    392     xcb_parts[2].iov_len = sizeof(xcb_out);
    393     xcb_parts[3].iov_base = 0;
    394     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    395 
    396     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    397     return xcb_ret;
    398 }
    399 
    400 xcb_void_cookie_t
    401 xcb_dri2_create_drawable (xcb_connection_t *c,
    402                           xcb_drawable_t    drawable)
    403 {
    404     static const xcb_protocol_request_t xcb_req = {
    405         .count = 2,
    406         .ext = &xcb_dri2_id,
    407         .opcode = XCB_DRI2_CREATE_DRAWABLE,
    408         .isvoid = 1
    409     };
    410 
    411     struct iovec xcb_parts[4];
    412     xcb_void_cookie_t xcb_ret;
    413     xcb_dri2_create_drawable_request_t xcb_out;
    414 
    415     xcb_out.drawable = drawable;
    416 
    417     xcb_parts[2].iov_base = (char *) &xcb_out;
    418     xcb_parts[2].iov_len = sizeof(xcb_out);
    419     xcb_parts[3].iov_base = 0;
    420     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    421 
    422     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    423     return xcb_ret;
    424 }
    425 
    426 xcb_void_cookie_t
    427 xcb_dri2_destroy_drawable_checked (xcb_connection_t *c,
    428                                    xcb_drawable_t    drawable)
    429 {
    430     static const xcb_protocol_request_t xcb_req = {
    431         .count = 2,
    432         .ext = &xcb_dri2_id,
    433         .opcode = XCB_DRI2_DESTROY_DRAWABLE,
    434         .isvoid = 1
    435     };
    436 
    437     struct iovec xcb_parts[4];
    438     xcb_void_cookie_t xcb_ret;
    439     xcb_dri2_destroy_drawable_request_t xcb_out;
    440 
    441     xcb_out.drawable = drawable;
    442 
    443     xcb_parts[2].iov_base = (char *) &xcb_out;
    444     xcb_parts[2].iov_len = sizeof(xcb_out);
    445     xcb_parts[3].iov_base = 0;
    446     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    447 
    448     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    449     return xcb_ret;
    450 }
    451 
    452 xcb_void_cookie_t
    453 xcb_dri2_destroy_drawable (xcb_connection_t *c,
    454                            xcb_drawable_t    drawable)
    455 {
    456     static const xcb_protocol_request_t xcb_req = {
    457         .count = 2,
    458         .ext = &xcb_dri2_id,
    459         .opcode = XCB_DRI2_DESTROY_DRAWABLE,
    460         .isvoid = 1
    461     };
    462 
    463     struct iovec xcb_parts[4];
    464     xcb_void_cookie_t xcb_ret;
    465     xcb_dri2_destroy_drawable_request_t xcb_out;
    466 
    467     xcb_out.drawable = drawable;
    468 
    469     xcb_parts[2].iov_base = (char *) &xcb_out;
    470     xcb_parts[2].iov_len = sizeof(xcb_out);
    471     xcb_parts[3].iov_base = 0;
    472     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    473 
    474     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    475     return xcb_ret;
    476 }
    477 
    478 int
    479 xcb_dri2_get_buffers_sizeof (const void  *_buffer,
    480                              uint32_t     attachments_len)
    481 {
    482     char *xcb_tmp = (char *)_buffer;
    483     unsigned int xcb_buffer_len = 0;
    484     unsigned int xcb_block_len = 0;
    485     unsigned int xcb_pad = 0;
    486     unsigned int xcb_align_to = 0;
    487 
    488 
    489     xcb_block_len += sizeof(xcb_dri2_get_buffers_request_t);
    490     xcb_tmp += xcb_block_len;
    491     xcb_buffer_len += xcb_block_len;
    492     xcb_block_len = 0;
    493     /* attachments */
    494     xcb_block_len += attachments_len * sizeof(uint32_t);
    495     xcb_tmp += xcb_block_len;
    496     xcb_align_to = ALIGNOF(uint32_t);
    497     /* insert padding */
    498     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    499     xcb_buffer_len += xcb_block_len + xcb_pad;
    500     if (0 != xcb_pad) {
    501         xcb_tmp += xcb_pad;
    502         xcb_pad = 0;
    503     }
    504     xcb_block_len = 0;
    505 
    506     return xcb_buffer_len;
    507 }
    508 
    509 xcb_dri2_get_buffers_cookie_t
    510 xcb_dri2_get_buffers (xcb_connection_t *c,
    511                       xcb_drawable_t    drawable,
    512                       uint32_t          count,
    513                       uint32_t          attachments_len,
    514                       const uint32_t   *attachments)
    515 {
    516     static const xcb_protocol_request_t xcb_req = {
    517         .count = 4,
    518         .ext = &xcb_dri2_id,
    519         .opcode = XCB_DRI2_GET_BUFFERS,
    520         .isvoid = 0
    521     };
    522 
    523     struct iovec xcb_parts[6];
    524     xcb_dri2_get_buffers_cookie_t xcb_ret;
    525     xcb_dri2_get_buffers_request_t xcb_out;
    526 
    527     xcb_out.drawable = drawable;
    528     xcb_out.count = count;
    529 
    530     xcb_parts[2].iov_base = (char *) &xcb_out;
    531     xcb_parts[2].iov_len = sizeof(xcb_out);
    532     xcb_parts[3].iov_base = 0;
    533     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    534     /* uint32_t attachments */
    535     xcb_parts[4].iov_base = (char *) attachments;
    536     xcb_parts[4].iov_len = attachments_len * sizeof(uint32_t);
    537     xcb_parts[5].iov_base = 0;
    538     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    539 
    540     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    541     return xcb_ret;
    542 }
    543 
    544 xcb_dri2_get_buffers_cookie_t
    545 xcb_dri2_get_buffers_unchecked (xcb_connection_t *c,
    546                                 xcb_drawable_t    drawable,
    547                                 uint32_t          count,
    548                                 uint32_t          attachments_len,
    549                                 const uint32_t   *attachments)
    550 {
    551     static const xcb_protocol_request_t xcb_req = {
    552         .count = 4,
    553         .ext = &xcb_dri2_id,
    554         .opcode = XCB_DRI2_GET_BUFFERS,
    555         .isvoid = 0
    556     };
    557 
    558     struct iovec xcb_parts[6];
    559     xcb_dri2_get_buffers_cookie_t xcb_ret;
    560     xcb_dri2_get_buffers_request_t xcb_out;
    561 
    562     xcb_out.drawable = drawable;
    563     xcb_out.count = count;
    564 
    565     xcb_parts[2].iov_base = (char *) &xcb_out;
    566     xcb_parts[2].iov_len = sizeof(xcb_out);
    567     xcb_parts[3].iov_base = 0;
    568     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    569     /* uint32_t attachments */
    570     xcb_parts[4].iov_base = (char *) attachments;
    571     xcb_parts[4].iov_len = attachments_len * sizeof(uint32_t);
    572     xcb_parts[5].iov_base = 0;
    573     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    574 
    575     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    576     return xcb_ret;
    577 }
    578 
    579 xcb_dri2_dri2_buffer_t *
    580 xcb_dri2_get_buffers_buffers (const xcb_dri2_get_buffers_reply_t *R)
    581 {
    582     return (xcb_dri2_dri2_buffer_t *) (R + 1);
    583 }
    584 
    585 int
    586 xcb_dri2_get_buffers_buffers_length (const xcb_dri2_get_buffers_reply_t *R)
    587 {
    588     return R->count;
    589 }
    590 
    591 xcb_dri2_dri2_buffer_iterator_t
    592 xcb_dri2_get_buffers_buffers_iterator (const xcb_dri2_get_buffers_reply_t *R)
    593 {
    594     xcb_dri2_dri2_buffer_iterator_t i;
    595     i.data = (xcb_dri2_dri2_buffer_t *) (R + 1);
    596     i.rem = R->count;
    597     i.index = (char *) i.data - (char *) R;
    598     return i;
    599 }
    600 
    601 xcb_dri2_get_buffers_reply_t *
    602 xcb_dri2_get_buffers_reply (xcb_connection_t               *c,
    603                             xcb_dri2_get_buffers_cookie_t   cookie  /**< */,
    604                             xcb_generic_error_t           **e)
    605 {
    606     return (xcb_dri2_get_buffers_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    607 }
    608 
    609 xcb_dri2_copy_region_cookie_t
    610 xcb_dri2_copy_region (xcb_connection_t *c,
    611                       xcb_drawable_t    drawable,
    612                       uint32_t          region,
    613                       uint32_t          dest,
    614                       uint32_t          src)
    615 {
    616     static const xcb_protocol_request_t xcb_req = {
    617         .count = 2,
    618         .ext = &xcb_dri2_id,
    619         .opcode = XCB_DRI2_COPY_REGION,
    620         .isvoid = 0
    621     };
    622 
    623     struct iovec xcb_parts[4];
    624     xcb_dri2_copy_region_cookie_t xcb_ret;
    625     xcb_dri2_copy_region_request_t xcb_out;
    626 
    627     xcb_out.drawable = drawable;
    628     xcb_out.region = region;
    629     xcb_out.dest = dest;
    630     xcb_out.src = src;
    631 
    632     xcb_parts[2].iov_base = (char *) &xcb_out;
    633     xcb_parts[2].iov_len = sizeof(xcb_out);
    634     xcb_parts[3].iov_base = 0;
    635     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    636 
    637     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    638     return xcb_ret;
    639 }
    640 
    641 xcb_dri2_copy_region_cookie_t
    642 xcb_dri2_copy_region_unchecked (xcb_connection_t *c,
    643                                 xcb_drawable_t    drawable,
    644                                 uint32_t          region,
    645                                 uint32_t          dest,
    646                                 uint32_t          src)
    647 {
    648     static const xcb_protocol_request_t xcb_req = {
    649         .count = 2,
    650         .ext = &xcb_dri2_id,
    651         .opcode = XCB_DRI2_COPY_REGION,
    652         .isvoid = 0
    653     };
    654 
    655     struct iovec xcb_parts[4];
    656     xcb_dri2_copy_region_cookie_t xcb_ret;
    657     xcb_dri2_copy_region_request_t xcb_out;
    658 
    659     xcb_out.drawable = drawable;
    660     xcb_out.region = region;
    661     xcb_out.dest = dest;
    662     xcb_out.src = src;
    663 
    664     xcb_parts[2].iov_base = (char *) &xcb_out;
    665     xcb_parts[2].iov_len = sizeof(xcb_out);
    666     xcb_parts[3].iov_base = 0;
    667     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    668 
    669     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    670     return xcb_ret;
    671 }
    672 
    673 xcb_dri2_copy_region_reply_t *
    674 xcb_dri2_copy_region_reply (xcb_connection_t               *c,
    675                             xcb_dri2_copy_region_cookie_t   cookie  /**< */,
    676                             xcb_generic_error_t           **e)
    677 {
    678     return (xcb_dri2_copy_region_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    679 }
    680 
    681 int
    682 xcb_dri2_get_buffers_with_format_sizeof (const void  *_buffer,
    683                                          uint32_t     attachments_len)
    684 {
    685     char *xcb_tmp = (char *)_buffer;
    686     unsigned int xcb_buffer_len = 0;
    687     unsigned int xcb_block_len = 0;
    688     unsigned int xcb_pad = 0;
    689     unsigned int xcb_align_to = 0;
    690 
    691 
    692     xcb_block_len += sizeof(xcb_dri2_get_buffers_with_format_request_t);
    693     xcb_tmp += xcb_block_len;
    694     xcb_buffer_len += xcb_block_len;
    695     xcb_block_len = 0;
    696     /* attachments */
    697     xcb_block_len += attachments_len * sizeof(xcb_dri2_attach_format_t);
    698     xcb_tmp += xcb_block_len;
    699     xcb_align_to = ALIGNOF(xcb_dri2_attach_format_t);
    700     /* insert padding */
    701     xcb_pad = -xcb_block_len & (xcb_align_to - 1);
    702     xcb_buffer_len += xcb_block_len + xcb_pad;
    703     if (0 != xcb_pad) {
    704         xcb_tmp += xcb_pad;
    705         xcb_pad = 0;
    706     }
    707     xcb_block_len = 0;
    708 
    709     return xcb_buffer_len;
    710 }
    711 
    712 xcb_dri2_get_buffers_with_format_cookie_t
    713 xcb_dri2_get_buffers_with_format (xcb_connection_t               *c,
    714                                   xcb_drawable_t                  drawable,
    715                                   uint32_t                        count,
    716                                   uint32_t                        attachments_len,
    717                                   const xcb_dri2_attach_format_t *attachments)
    718 {
    719     static const xcb_protocol_request_t xcb_req = {
    720         .count = 4,
    721         .ext = &xcb_dri2_id,
    722         .opcode = XCB_DRI2_GET_BUFFERS_WITH_FORMAT,
    723         .isvoid = 0
    724     };
    725 
    726     struct iovec xcb_parts[6];
    727     xcb_dri2_get_buffers_with_format_cookie_t xcb_ret;
    728     xcb_dri2_get_buffers_with_format_request_t xcb_out;
    729 
    730     xcb_out.drawable = drawable;
    731     xcb_out.count = count;
    732 
    733     xcb_parts[2].iov_base = (char *) &xcb_out;
    734     xcb_parts[2].iov_len = sizeof(xcb_out);
    735     xcb_parts[3].iov_base = 0;
    736     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    737     /* xcb_dri2_attach_format_t attachments */
    738     xcb_parts[4].iov_base = (char *) attachments;
    739     xcb_parts[4].iov_len = attachments_len * sizeof(xcb_dri2_attach_format_t);
    740     xcb_parts[5].iov_base = 0;
    741     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    742 
    743     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    744     return xcb_ret;
    745 }
    746 
    747 xcb_dri2_get_buffers_with_format_cookie_t
    748 xcb_dri2_get_buffers_with_format_unchecked (xcb_connection_t               *c,
    749                                             xcb_drawable_t                  drawable,
    750                                             uint32_t                        count,
    751                                             uint32_t                        attachments_len,
    752                                             const xcb_dri2_attach_format_t *attachments)
    753 {
    754     static const xcb_protocol_request_t xcb_req = {
    755         .count = 4,
    756         .ext = &xcb_dri2_id,
    757         .opcode = XCB_DRI2_GET_BUFFERS_WITH_FORMAT,
    758         .isvoid = 0
    759     };
    760 
    761     struct iovec xcb_parts[6];
    762     xcb_dri2_get_buffers_with_format_cookie_t xcb_ret;
    763     xcb_dri2_get_buffers_with_format_request_t xcb_out;
    764 
    765     xcb_out.drawable = drawable;
    766     xcb_out.count = count;
    767 
    768     xcb_parts[2].iov_base = (char *) &xcb_out;
    769     xcb_parts[2].iov_len = sizeof(xcb_out);
    770     xcb_parts[3].iov_base = 0;
    771     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    772     /* xcb_dri2_attach_format_t attachments */
    773     xcb_parts[4].iov_base = (char *) attachments;
    774     xcb_parts[4].iov_len = attachments_len * sizeof(xcb_dri2_attach_format_t);
    775     xcb_parts[5].iov_base = 0;
    776     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
    777 
    778     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    779     return xcb_ret;
    780 }
    781 
    782 xcb_dri2_dri2_buffer_t *
    783 xcb_dri2_get_buffers_with_format_buffers (const xcb_dri2_get_buffers_with_format_reply_t *R)
    784 {
    785     return (xcb_dri2_dri2_buffer_t *) (R + 1);
    786 }
    787 
    788 int
    789 xcb_dri2_get_buffers_with_format_buffers_length (const xcb_dri2_get_buffers_with_format_reply_t *R)
    790 {
    791     return R->count;
    792 }
    793 
    794 xcb_dri2_dri2_buffer_iterator_t
    795 xcb_dri2_get_buffers_with_format_buffers_iterator (const xcb_dri2_get_buffers_with_format_reply_t *R)
    796 {
    797     xcb_dri2_dri2_buffer_iterator_t i;
    798     i.data = (xcb_dri2_dri2_buffer_t *) (R + 1);
    799     i.rem = R->count;
    800     i.index = (char *) i.data - (char *) R;
    801     return i;
    802 }
    803 
    804 xcb_dri2_get_buffers_with_format_reply_t *
    805 xcb_dri2_get_buffers_with_format_reply (xcb_connection_t                           *c,
    806                                         xcb_dri2_get_buffers_with_format_cookie_t   cookie  /**< */,
    807                                         xcb_generic_error_t                       **e)
    808 {
    809     return (xcb_dri2_get_buffers_with_format_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    810 }
    811 
    812 xcb_dri2_swap_buffers_cookie_t
    813 xcb_dri2_swap_buffers (xcb_connection_t *c,
    814                        xcb_drawable_t    drawable,
    815                        uint32_t          target_msc_hi,
    816                        uint32_t          target_msc_lo,
    817                        uint32_t          divisor_hi,
    818                        uint32_t          divisor_lo,
    819                        uint32_t          remainder_hi,
    820                        uint32_t          remainder_lo)
    821 {
    822     static const xcb_protocol_request_t xcb_req = {
    823         .count = 2,
    824         .ext = &xcb_dri2_id,
    825         .opcode = XCB_DRI2_SWAP_BUFFERS,
    826         .isvoid = 0
    827     };
    828 
    829     struct iovec xcb_parts[4];
    830     xcb_dri2_swap_buffers_cookie_t xcb_ret;
    831     xcb_dri2_swap_buffers_request_t xcb_out;
    832 
    833     xcb_out.drawable = drawable;
    834     xcb_out.target_msc_hi = target_msc_hi;
    835     xcb_out.target_msc_lo = target_msc_lo;
    836     xcb_out.divisor_hi = divisor_hi;
    837     xcb_out.divisor_lo = divisor_lo;
    838     xcb_out.remainder_hi = remainder_hi;
    839     xcb_out.remainder_lo = remainder_lo;
    840 
    841     xcb_parts[2].iov_base = (char *) &xcb_out;
    842     xcb_parts[2].iov_len = sizeof(xcb_out);
    843     xcb_parts[3].iov_base = 0;
    844     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    845 
    846     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    847     return xcb_ret;
    848 }
    849 
    850 xcb_dri2_swap_buffers_cookie_t
    851 xcb_dri2_swap_buffers_unchecked (xcb_connection_t *c,
    852                                  xcb_drawable_t    drawable,
    853                                  uint32_t          target_msc_hi,
    854                                  uint32_t          target_msc_lo,
    855                                  uint32_t          divisor_hi,
    856                                  uint32_t          divisor_lo,
    857                                  uint32_t          remainder_hi,
    858                                  uint32_t          remainder_lo)
    859 {
    860     static const xcb_protocol_request_t xcb_req = {
    861         .count = 2,
    862         .ext = &xcb_dri2_id,
    863         .opcode = XCB_DRI2_SWAP_BUFFERS,
    864         .isvoid = 0
    865     };
    866 
    867     struct iovec xcb_parts[4];
    868     xcb_dri2_swap_buffers_cookie_t xcb_ret;
    869     xcb_dri2_swap_buffers_request_t xcb_out;
    870 
    871     xcb_out.drawable = drawable;
    872     xcb_out.target_msc_hi = target_msc_hi;
    873     xcb_out.target_msc_lo = target_msc_lo;
    874     xcb_out.divisor_hi = divisor_hi;
    875     xcb_out.divisor_lo = divisor_lo;
    876     xcb_out.remainder_hi = remainder_hi;
    877     xcb_out.remainder_lo = remainder_lo;
    878 
    879     xcb_parts[2].iov_base = (char *) &xcb_out;
    880     xcb_parts[2].iov_len = sizeof(xcb_out);
    881     xcb_parts[3].iov_base = 0;
    882     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    883 
    884     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    885     return xcb_ret;
    886 }
    887 
    888 xcb_dri2_swap_buffers_reply_t *
    889 xcb_dri2_swap_buffers_reply (xcb_connection_t                *c,
    890                              xcb_dri2_swap_buffers_cookie_t   cookie  /**< */,
    891                              xcb_generic_error_t            **e)
    892 {
    893     return (xcb_dri2_swap_buffers_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    894 }
    895 
    896 xcb_dri2_get_msc_cookie_t
    897 xcb_dri2_get_msc (xcb_connection_t *c,
    898                   xcb_drawable_t    drawable)
    899 {
    900     static const xcb_protocol_request_t xcb_req = {
    901         .count = 2,
    902         .ext = &xcb_dri2_id,
    903         .opcode = XCB_DRI2_GET_MSC,
    904         .isvoid = 0
    905     };
    906 
    907     struct iovec xcb_parts[4];
    908     xcb_dri2_get_msc_cookie_t xcb_ret;
    909     xcb_dri2_get_msc_request_t xcb_out;
    910 
    911     xcb_out.drawable = drawable;
    912 
    913     xcb_parts[2].iov_base = (char *) &xcb_out;
    914     xcb_parts[2].iov_len = sizeof(xcb_out);
    915     xcb_parts[3].iov_base = 0;
    916     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    917 
    918     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    919     return xcb_ret;
    920 }
    921 
    922 xcb_dri2_get_msc_cookie_t
    923 xcb_dri2_get_msc_unchecked (xcb_connection_t *c,
    924                             xcb_drawable_t    drawable)
    925 {
    926     static const xcb_protocol_request_t xcb_req = {
    927         .count = 2,
    928         .ext = &xcb_dri2_id,
    929         .opcode = XCB_DRI2_GET_MSC,
    930         .isvoid = 0
    931     };
    932 
    933     struct iovec xcb_parts[4];
    934     xcb_dri2_get_msc_cookie_t xcb_ret;
    935     xcb_dri2_get_msc_request_t xcb_out;
    936 
    937     xcb_out.drawable = drawable;
    938 
    939     xcb_parts[2].iov_base = (char *) &xcb_out;
    940     xcb_parts[2].iov_len = sizeof(xcb_out);
    941     xcb_parts[3].iov_base = 0;
    942     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    943 
    944     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
    945     return xcb_ret;
    946 }
    947 
    948 xcb_dri2_get_msc_reply_t *
    949 xcb_dri2_get_msc_reply (xcb_connection_t           *c,
    950                         xcb_dri2_get_msc_cookie_t   cookie  /**< */,
    951                         xcb_generic_error_t       **e)
    952 {
    953     return (xcb_dri2_get_msc_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
    954 }
    955 
    956 xcb_dri2_wait_msc_cookie_t
    957 xcb_dri2_wait_msc (xcb_connection_t *c,
    958                    xcb_drawable_t    drawable,
    959                    uint32_t          target_msc_hi,
    960                    uint32_t          target_msc_lo,
    961                    uint32_t          divisor_hi,
    962                    uint32_t          divisor_lo,
    963                    uint32_t          remainder_hi,
    964                    uint32_t          remainder_lo)
    965 {
    966     static const xcb_protocol_request_t xcb_req = {
    967         .count = 2,
    968         .ext = &xcb_dri2_id,
    969         .opcode = XCB_DRI2_WAIT_MSC,
    970         .isvoid = 0
    971     };
    972 
    973     struct iovec xcb_parts[4];
    974     xcb_dri2_wait_msc_cookie_t xcb_ret;
    975     xcb_dri2_wait_msc_request_t xcb_out;
    976 
    977     xcb_out.drawable = drawable;
    978     xcb_out.target_msc_hi = target_msc_hi;
    979     xcb_out.target_msc_lo = target_msc_lo;
    980     xcb_out.divisor_hi = divisor_hi;
    981     xcb_out.divisor_lo = divisor_lo;
    982     xcb_out.remainder_hi = remainder_hi;
    983     xcb_out.remainder_lo = remainder_lo;
    984 
    985     xcb_parts[2].iov_base = (char *) &xcb_out;
    986     xcb_parts[2].iov_len = sizeof(xcb_out);
    987     xcb_parts[3].iov_base = 0;
    988     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
    989 
    990     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
    991     return xcb_ret;
    992 }
    993 
    994 xcb_dri2_wait_msc_cookie_t
    995 xcb_dri2_wait_msc_unchecked (xcb_connection_t *c,
    996                              xcb_drawable_t    drawable,
    997                              uint32_t          target_msc_hi,
    998                              uint32_t          target_msc_lo,
    999                              uint32_t          divisor_hi,
   1000                              uint32_t          divisor_lo,
   1001                              uint32_t          remainder_hi,
   1002                              uint32_t          remainder_lo)
   1003 {
   1004     static const xcb_protocol_request_t xcb_req = {
   1005         .count = 2,
   1006         .ext = &xcb_dri2_id,
   1007         .opcode = XCB_DRI2_WAIT_MSC,
   1008         .isvoid = 0
   1009     };
   1010 
   1011     struct iovec xcb_parts[4];
   1012     xcb_dri2_wait_msc_cookie_t xcb_ret;
   1013     xcb_dri2_wait_msc_request_t xcb_out;
   1014 
   1015     xcb_out.drawable = drawable;
   1016     xcb_out.target_msc_hi = target_msc_hi;
   1017     xcb_out.target_msc_lo = target_msc_lo;
   1018     xcb_out.divisor_hi = divisor_hi;
   1019     xcb_out.divisor_lo = divisor_lo;
   1020     xcb_out.remainder_hi = remainder_hi;
   1021     xcb_out.remainder_lo = remainder_lo;
   1022 
   1023     xcb_parts[2].iov_base = (char *) &xcb_out;
   1024     xcb_parts[2].iov_len = sizeof(xcb_out);
   1025     xcb_parts[3].iov_base = 0;
   1026     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1027 
   1028     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1029     return xcb_ret;
   1030 }
   1031 
   1032 xcb_dri2_wait_msc_reply_t *
   1033 xcb_dri2_wait_msc_reply (xcb_connection_t            *c,
   1034                          xcb_dri2_wait_msc_cookie_t   cookie  /**< */,
   1035                          xcb_generic_error_t        **e)
   1036 {
   1037     return (xcb_dri2_wait_msc_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1038 }
   1039 
   1040 xcb_dri2_wait_sbc_cookie_t
   1041 xcb_dri2_wait_sbc (xcb_connection_t *c,
   1042                    xcb_drawable_t    drawable,
   1043                    uint32_t          target_sbc_hi,
   1044                    uint32_t          target_sbc_lo)
   1045 {
   1046     static const xcb_protocol_request_t xcb_req = {
   1047         .count = 2,
   1048         .ext = &xcb_dri2_id,
   1049         .opcode = XCB_DRI2_WAIT_SBC,
   1050         .isvoid = 0
   1051     };
   1052 
   1053     struct iovec xcb_parts[4];
   1054     xcb_dri2_wait_sbc_cookie_t xcb_ret;
   1055     xcb_dri2_wait_sbc_request_t xcb_out;
   1056 
   1057     xcb_out.drawable = drawable;
   1058     xcb_out.target_sbc_hi = target_sbc_hi;
   1059     xcb_out.target_sbc_lo = target_sbc_lo;
   1060 
   1061     xcb_parts[2].iov_base = (char *) &xcb_out;
   1062     xcb_parts[2].iov_len = sizeof(xcb_out);
   1063     xcb_parts[3].iov_base = 0;
   1064     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1065 
   1066     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1067     return xcb_ret;
   1068 }
   1069 
   1070 xcb_dri2_wait_sbc_cookie_t
   1071 xcb_dri2_wait_sbc_unchecked (xcb_connection_t *c,
   1072                              xcb_drawable_t    drawable,
   1073                              uint32_t          target_sbc_hi,
   1074                              uint32_t          target_sbc_lo)
   1075 {
   1076     static const xcb_protocol_request_t xcb_req = {
   1077         .count = 2,
   1078         .ext = &xcb_dri2_id,
   1079         .opcode = XCB_DRI2_WAIT_SBC,
   1080         .isvoid = 0
   1081     };
   1082 
   1083     struct iovec xcb_parts[4];
   1084     xcb_dri2_wait_sbc_cookie_t xcb_ret;
   1085     xcb_dri2_wait_sbc_request_t xcb_out;
   1086 
   1087     xcb_out.drawable = drawable;
   1088     xcb_out.target_sbc_hi = target_sbc_hi;
   1089     xcb_out.target_sbc_lo = target_sbc_lo;
   1090 
   1091     xcb_parts[2].iov_base = (char *) &xcb_out;
   1092     xcb_parts[2].iov_len = sizeof(xcb_out);
   1093     xcb_parts[3].iov_base = 0;
   1094     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1095 
   1096     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1097     return xcb_ret;
   1098 }
   1099 
   1100 xcb_dri2_wait_sbc_reply_t *
   1101 xcb_dri2_wait_sbc_reply (xcb_connection_t            *c,
   1102                          xcb_dri2_wait_sbc_cookie_t   cookie  /**< */,
   1103                          xcb_generic_error_t        **e)
   1104 {
   1105     return (xcb_dri2_wait_sbc_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1106 }
   1107 
   1108 xcb_void_cookie_t
   1109 xcb_dri2_swap_interval_checked (xcb_connection_t *c,
   1110                                 xcb_drawable_t    drawable,
   1111                                 uint32_t          interval)
   1112 {
   1113     static const xcb_protocol_request_t xcb_req = {
   1114         .count = 2,
   1115         .ext = &xcb_dri2_id,
   1116         .opcode = XCB_DRI2_SWAP_INTERVAL,
   1117         .isvoid = 1
   1118     };
   1119 
   1120     struct iovec xcb_parts[4];
   1121     xcb_void_cookie_t xcb_ret;
   1122     xcb_dri2_swap_interval_request_t xcb_out;
   1123 
   1124     xcb_out.drawable = drawable;
   1125     xcb_out.interval = interval;
   1126 
   1127     xcb_parts[2].iov_base = (char *) &xcb_out;
   1128     xcb_parts[2].iov_len = sizeof(xcb_out);
   1129     xcb_parts[3].iov_base = 0;
   1130     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1131 
   1132     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1133     return xcb_ret;
   1134 }
   1135 
   1136 xcb_void_cookie_t
   1137 xcb_dri2_swap_interval (xcb_connection_t *c,
   1138                         xcb_drawable_t    drawable,
   1139                         uint32_t          interval)
   1140 {
   1141     static const xcb_protocol_request_t xcb_req = {
   1142         .count = 2,
   1143         .ext = &xcb_dri2_id,
   1144         .opcode = XCB_DRI2_SWAP_INTERVAL,
   1145         .isvoid = 1
   1146     };
   1147 
   1148     struct iovec xcb_parts[4];
   1149     xcb_void_cookie_t xcb_ret;
   1150     xcb_dri2_swap_interval_request_t xcb_out;
   1151 
   1152     xcb_out.drawable = drawable;
   1153     xcb_out.interval = interval;
   1154 
   1155     xcb_parts[2].iov_base = (char *) &xcb_out;
   1156     xcb_parts[2].iov_len = sizeof(xcb_out);
   1157     xcb_parts[3].iov_base = 0;
   1158     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1159 
   1160     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1161     return xcb_ret;
   1162 }
   1163 
   1164 xcb_dri2_get_param_cookie_t
   1165 xcb_dri2_get_param (xcb_connection_t *c,
   1166                     xcb_drawable_t    drawable,
   1167                     uint32_t          param)
   1168 {
   1169     static const xcb_protocol_request_t xcb_req = {
   1170         .count = 2,
   1171         .ext = &xcb_dri2_id,
   1172         .opcode = XCB_DRI2_GET_PARAM,
   1173         .isvoid = 0
   1174     };
   1175 
   1176     struct iovec xcb_parts[4];
   1177     xcb_dri2_get_param_cookie_t xcb_ret;
   1178     xcb_dri2_get_param_request_t xcb_out;
   1179 
   1180     xcb_out.drawable = drawable;
   1181     xcb_out.param = param;
   1182 
   1183     xcb_parts[2].iov_base = (char *) &xcb_out;
   1184     xcb_parts[2].iov_len = sizeof(xcb_out);
   1185     xcb_parts[3].iov_base = 0;
   1186     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1187 
   1188     xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
   1189     return xcb_ret;
   1190 }
   1191 
   1192 xcb_dri2_get_param_cookie_t
   1193 xcb_dri2_get_param_unchecked (xcb_connection_t *c,
   1194                               xcb_drawable_t    drawable,
   1195                               uint32_t          param)
   1196 {
   1197     static const xcb_protocol_request_t xcb_req = {
   1198         .count = 2,
   1199         .ext = &xcb_dri2_id,
   1200         .opcode = XCB_DRI2_GET_PARAM,
   1201         .isvoid = 0
   1202     };
   1203 
   1204     struct iovec xcb_parts[4];
   1205     xcb_dri2_get_param_cookie_t xcb_ret;
   1206     xcb_dri2_get_param_request_t xcb_out;
   1207 
   1208     xcb_out.drawable = drawable;
   1209     xcb_out.param = param;
   1210 
   1211     xcb_parts[2].iov_base = (char *) &xcb_out;
   1212     xcb_parts[2].iov_len = sizeof(xcb_out);
   1213     xcb_parts[3].iov_base = 0;
   1214     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
   1215 
   1216     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
   1217     return xcb_ret;
   1218 }
   1219 
   1220 xcb_dri2_get_param_reply_t *
   1221 xcb_dri2_get_param_reply (xcb_connection_t             *c,
   1222                           xcb_dri2_get_param_cookie_t   cookie  /**< */,
   1223                           xcb_generic_error_t         **e)
   1224 {
   1225     return (xcb_dri2_get_param_reply_t *) xcb_wait_for_reply(c, cookie.sequence, e);
   1226 }
   1227 
   1228