[Xcb] [PATCH] XCB-XML: Proposal for alignment padding
Evgeny M. Zubok
evgeny.zubok at tochka.ru
Wed Nov 10 13:46:15 PST 2010
Below an example of request with a group of not aligned
lists. randrproto.txt describes an encoding of RRSetCrtcGamme as:
RRSetCrtcGamma
1 CARD8 major opcode
1 24 RandR opcode
2 3+(6n+2)/4 length
4 CRTC crtc
2 n size
2 unused
2n LISTofCARD16 red
2n LISTofCARD16 green
2n LISTofCARD16 blue
p unused, p=pad(6n)
The specification states that there is no alignments between
lists. However, c_client.py generates the implementation of
xcb_randr_set_crtc_gamma(_checked) with alignments. Is there a bug here?
The following is the exerpt from randr.c:
xcb_parts[2].iov_base = (char *) &xcb_out;
xcb_parts[2].iov_len = sizeof(xcb_out);
xcb_parts[3].iov_base = 0;
xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
xcb_parts[4].iov_base = (char *) red;
xcb_parts[4].iov_len = size * sizeof(uint16_t);
xcb_parts[5].iov_base = 0;
xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
xcb_parts[6].iov_base = (char *) green;
xcb_parts[6].iov_len = size * sizeof(uint16_t);
xcb_parts[7].iov_base = 0;
xcb_parts[7].iov_len = -xcb_parts[6].iov_len & 3;
xcb_parts[8].iov_base = (char *) blue;
xcb_parts[8].iov_len = size * sizeof(uint16_t);
xcb_parts[9].iov_base = 0;
xcb_parts[9].iov_len = -xcb_parts[8].iov_len & 3;
xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
return xcb_ret;
My patch has XML description without padding between lists and with
pad (with an optional expression) at the bottom of structure:
<request name="SetCrtcGamma" opcode="24">
<field type="CRTC" name="crtc" />
<field type="CARD16" name="size" />
<pad bytes="2"/>
<list type="CARD16" name="red">
<fieldref>size</fieldref>
</list>
<list type="CARD16" name="green">
<fieldref>size</fieldref>
</list>
<list type="CARD16" name="blue">
<fieldref>size</fieldref>
</list>
<pad align="4">
<op op="*">
<fieldref>size</fieldref>
<value>6</value>
</op>
</pad>
</request>
The improved code generator actually should generate
xcb_parts[2].iov_base = (char *) &xcb_out;
xcb_parts[2].iov_len = sizeof(xcb_out);
xcb_parts[3].iov_base = (char *) red;
xcb_parts[3].iov_len = size * sizeof(uint16_t);
xcb_parts[4].iov_base = (char *) green;
xcb_parts[4].iov_len = size * sizeof(uint16_t);
xcb_parts[5].iov_base = (char *) blue;
xcb_parts[5].iov_len = size * sizeof(uint16_t);
xcb_parts[6].iov_base = 0;
xcb_parts[6].iov_len = -(size * 6) & 3;
xcb_ret.sequence = xcb_send_request(c, XCB_REQUEST_CHECKED, xcb_parts + 2, &xcb_req);
return xcb_ret;
More information about the Xcb
mailing list