[PATCH libX11] include: Add GetReqSized() for request buffers of specific size

Jamey Sharp jamey at minilop.net
Fri Oct 14 09:42:02 PDT 2011


The GetReq family of macros is so evil. I'm not going to go so far as
to NAK this patch or anything, but please consider whether you can
implement this as a proper function or something. Perhaps:

void *XGetReq(CARD8 reqType, size_t sz);

(I think the other macros could be re-implemented on top of that
function, so long as the function continues to behave in a manner
compatible with code compiled using the current macros.)

Also, do you care about big-requests here? I can't remember how Xlib
handles that extension.

Jamey

On 10/14/11, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> Some XI2 requests change in size over different versions and libXi would
> need to hack around GetReq and GetReqExtra. Add a new GetReqSized so the
> library can explicitly specify the size of the request in 4-byte units.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
> Instead of hacking around in libXi with GetReq, let's just add a new macro.
>
>  include/X11/Xlibint.h |   25 +++++++++++++++++++++++++
>  1 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
> index 2ce356d..083498f 100644
> --- a/include/X11/Xlibint.h
> +++ b/include/X11/Xlibint.h
> @@ -478,6 +478,31 @@ extern LockInfoPtr _Xglobal_lock;
>  	dpy->request++
>  #endif
>
> +/* GetReqSized is the same as GetReq but allows the caller to specify the
> + * size in 4-byte units */
> +#if !defined(UNIXCPP) || defined(ANSICPP)
> +#define GetReqSized(name, sz, req) \
> +        WORD64ALIGN\
> +	if ((dpy->bufptr + sz * 4) > dpy->bufmax)\
> +		_XFlush(dpy);\
> +	req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
> +	req->reqType = X_##name;\
> +	req->length = sz; \
> +	dpy->bufptr += sz * 4;\
> +	dpy->request++
> +#else
> +#define GetReqSized(name, sz, req) \
> +        WORD64ALIGN\
> +	if ((dpy->bufptr + sz * 4) > dpy->bufmax)\
> +		_XFlush(dpy);\
> +	req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
> +	req->reqType = X_/**/name;\
> +	req->length = sz; \
> +	dpy->bufptr += sz * 4; \
> +	dpy->request++
> +#endif
> +
> +
>
>  /*
>   * GetResReq is for those requests that have a resource ID
> --
> 1.7.6.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>


More information about the xorg-devel mailing list