mirror of
https://gitlab.freedesktop.org/xorg/lib/libx11.git
synced 2026-05-07 16:48:31 +02:00
Quit relying on XCBSendRequest to pad to 4-byte boundaries and do it ourselves.
This commit is contained in:
parent
fb590c15a7
commit
d3512ef3aa
1 changed files with 15 additions and 20 deletions
|
|
@ -155,8 +155,7 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
unsigned int sequence;
|
||||
int flags = XCB_REQUEST_RAW;
|
||||
int i;
|
||||
CARD32 len;
|
||||
size_t rem;
|
||||
size_t len;
|
||||
|
||||
/* skip empty iovecs. if no iovecs remain, we're done. */
|
||||
while(veclen > 0 && vec[0].iov_len == 0)
|
||||
|
|
@ -171,13 +170,14 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
if(len == 0)
|
||||
/* it's a bigrequest. dig out the *real* length field. */
|
||||
len = ((CARD32 *) vec[0].iov_base)[1];
|
||||
len <<= 2;
|
||||
|
||||
/* do we have enough data for a complete request? how many iovec
|
||||
* elements does it span? */
|
||||
for(i = 0; i < veclen; ++i)
|
||||
{
|
||||
CARD32 oldlen = len;
|
||||
len -= (vec[i].iov_len + 3) >> 2;
|
||||
size_t oldlen = len;
|
||||
len -= vec[i].iov_len;
|
||||
/* if len is now 0 or has wrapped, we have enough data. */
|
||||
if((len - 1) > oldlen)
|
||||
break;
|
||||
|
|
@ -188,16 +188,9 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
/* we have enough data to issue one complete request. the remaining
|
||||
* code can't fail. */
|
||||
|
||||
/* len says how far we overshot our data needs in 4-byte units.
|
||||
* (it's negative if we actually overshot, or 0 if we're right on.)
|
||||
* rem is overshoot in 1-byte units, so it needs to have trailing
|
||||
* padding subtracted off if we're not using that padding in this
|
||||
* request. */
|
||||
if(len)
|
||||
rem = (-len << 2) - (-vec[i].iov_len & 3);
|
||||
else
|
||||
rem = 0;
|
||||
vec[i].iov_len -= rem;
|
||||
/* len says how far we overshot our data needs. (it's "negative" if
|
||||
* we actually overshot, or 0 if we're right on.) */
|
||||
vec[i].iov_len += len;
|
||||
xcb_req.count = i + 1;
|
||||
xcb_req.opcode = ((CARD8 *) vec[0].iov_base)[0];
|
||||
|
||||
|
|
@ -211,7 +204,7 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
|
||||
/* update the iovecs to refer only to data not yet sent. */
|
||||
vec[i].iov_base = (char *) vec[i].iov_base + vec[i].iov_len;
|
||||
vec[i].iov_len = rem;
|
||||
vec[i].iov_len = -len;
|
||||
while(--i >= 0)
|
||||
vec[i].iov_len = 0;
|
||||
|
||||
|
|
@ -233,9 +226,11 @@ static inline int issue_complete_request(Display *dpy, int veclen, struct iovec
|
|||
|
||||
void _XPutXCBBuffer(Display *dpy)
|
||||
{
|
||||
static char const pad[3];
|
||||
const int padsize = -dpy->xcl->request_extra_size & 3;
|
||||
XCBConnection *c = dpy->xcl->connection;
|
||||
_XExtension *ext;
|
||||
struct iovec iov[2];
|
||||
struct iovec iov[5];
|
||||
|
||||
assert_sequence_less(dpy->last_request_read, dpy->request);
|
||||
assert_sequence_less(XCBGetRequestSent(c), dpy->request);
|
||||
|
|
@ -245,8 +240,6 @@ void _XPutXCBBuffer(Display *dpy)
|
|||
ext->before_flush(dpy, &ext->codes, dpy->buffer, dpy->bufptr - dpy->buffer);
|
||||
if(dpy->xcl->request_extra)
|
||||
{
|
||||
static char const pad[3];
|
||||
int padsize = -dpy->xcl->request_extra_size & 3;
|
||||
ext->before_flush(dpy, &ext->codes, dpy->xcl->request_extra, dpy->xcl->request_extra_size);
|
||||
if(padsize)
|
||||
ext->before_flush(dpy, &ext->codes, pad, padsize);
|
||||
|
|
@ -257,11 +250,13 @@ void _XPutXCBBuffer(Display *dpy)
|
|||
iov[0].iov_len = dpy->bufptr - dpy->buffer;
|
||||
iov[1].iov_base = (caddr_t) dpy->xcl->request_extra;
|
||||
iov[1].iov_len = dpy->xcl->request_extra_size;
|
||||
iov[2].iov_base = (caddr_t) pad;
|
||||
iov[2].iov_len = padsize;
|
||||
|
||||
while(issue_complete_request(dpy, 2, iov))
|
||||
while(issue_complete_request(dpy, 3, iov))
|
||||
/* empty */;
|
||||
|
||||
assert(iov[0].iov_len == 0 && iov[1].iov_len == 0);
|
||||
assert(iov[0].iov_len == 0 && iov[1].iov_len == 0 && iov[2].iov_len == 0);
|
||||
|
||||
dpy->xcl->request_extra = 0;
|
||||
dpy->xcl->request_extra_size = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue