summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-10-17 09:45:15 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-11-08 07:24:07 +1000
commit4a060f993bf676cf21ad9784e010f54134da7b40 (patch)
treebd829e85fd7174236818d76bc8c1280937836cb5 /include
parentd8956520deb79c1cbb5e974c175bf8493859b22b (diff)
Add _XGetRequest as substitute for GetReq/GetReqExtra
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jamey Sharp <jamey@minilop.net>
Diffstat (limited to 'include')
-rw-r--r--include/X11/Xlibint.h49
1 files changed, 16 insertions, 33 deletions
diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
index 2ce356d1..43d1f2a9 100644
--- a/include/X11/Xlibint.h
+++ b/include/X11/Xlibint.h
@@ -420,6 +420,18 @@ extern LockInfoPtr _Xglobal_lock;
#define WORD64ALIGN
#endif /* WORD64 */
+/**
+ * Return a len-sized request buffer for the request type. This function may
+ * flush the output queue.
+ *
+ * @param dpy The display connection
+ * @param type The request type
+ * @param len Length of the request in bytes
+ *
+ * @returns A pointer to the request buffer with a few default values
+ * initialized.
+ */
+extern void *_XGetRequest(Display *dpy, CARD8 type, size_t len);
/*
* GetReq - Get the next available X request packet in the buffer and
@@ -432,25 +444,10 @@ extern LockInfoPtr _Xglobal_lock;
#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetReq(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = (SIZEOF(x##name##Req))>>2;\
- dpy->bufptr += SIZEOF(x##name##Req);\
- dpy->request++
-
+ req = (x##name##Req *) _XGetRequest(dpy, X_##name, SIZEOF(x##name##Req))
#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
#define GetReq(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = (SIZEOF(x/**/name/**/Req))>>2;\
- dpy->bufptr += SIZEOF(x/**/name/**/Req);\
- dpy->request++
+ req = (x/**/name/**/Req *) _XGetRequest(dpy, X_/**/name, SIZEOF(x/**/name/**/Req))
#endif
/* GetReqExtra is the same as GetReq, but allocates "n" additional
@@ -458,24 +455,10 @@ extern LockInfoPtr _Xglobal_lock;
#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetReqExtra(name, n, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = (SIZEOF(x##name##Req) + n)>>2;\
- dpy->bufptr += SIZEOF(x##name##Req) + n;\
- dpy->request++
+ req = (x##name##Req *) _XGetRequest(dpy, X_##name, SIZEOF(x##name##Req) + n)
#else
#define GetReqExtra(name, n, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
- dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
- dpy->request++
+ req = (x/**/name/**/Req *) _XGetRequest(dpy, X_/**/name, SIZEOF(x/**/name/**/Req) + n)
#endif