aboutsummaryrefslogtreecommitdiff
path: root/X11/Xlibint.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-12-23 15:22:40 +0100
committermarha <marha@users.sourceforge.net>2011-12-23 15:22:40 +0100
commitd1d04c7bd3f1465b7bb6690022d086c6bb005b70 (patch)
tree058884f2af1a2994f07d887c88bfdea63cc47703 /X11/Xlibint.h
parent52b728b4b397d26f8841848ee921950e083991d0 (diff)
downloadvcxsrv-d1d04c7bd3f1465b7bb6690022d086c6bb005b70.tar.gz
vcxsrv-d1d04c7bd3f1465b7bb6690022d086c6bb005b70.tar.bz2
vcxsrv-d1d04c7bd3f1465b7bb6690022d086c6bb005b70.zip
Synchronised files
Diffstat (limited to 'X11/Xlibint.h')
-rw-r--r--X11/Xlibint.h101
1 files changed, 34 insertions, 67 deletions
diff --git a/X11/Xlibint.h b/X11/Xlibint.h
index a55938b5b..9cc1f0d1b 100644
--- a/X11/Xlibint.h
+++ b/X11/Xlibint.h
@@ -420,6 +420,30 @@ 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);
+
+/* GetReqSized is the same as GetReq but allows the caller to specify the
+ * size in bytes. 'sz' must be a multiple of 4! */
+
+#if !defined(UNIXCPP) || defined(ANSICPP)
+#define GetReqSized(name, sz, req) \
+ req = (x##name##Req *) _XGetRequest(dpy, X_##name, sz)
+#else
+#define GetReqSized(name, sz, req) \
+ req = (x/**/name/**/Req *) _XGetRequest(dpy, X_/**/name, sz)
+#endif
+
/*
* GetReq - Get the next available X request packet in the buffer and
@@ -432,25 +456,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++
-
+ GetReqSized(name, SIZEOF(x##name##Req), 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++
+ GetReqSized(name, SIZEOF(x/**/name/**/Req), req)
#endif
/* GetReqExtra is the same as GetReq, but allocates "n" additional
@@ -458,24 +467,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++
+ GetReqSized(name, SIZEOF(x##name##Req) + n, req)
#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++
+ GetReqSized(name, SIZEOF(x/**/name/**/Req) + n, req)
#endif
@@ -487,26 +482,12 @@ extern LockInfoPtr _Xglobal_lock;
#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetResReq(name, rid, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = 2;\
- req->id = (rid);\
- dpy->bufptr += SIZEOF(xResourceReq);\
- dpy->request++
+ req = (xResourceReq *) _XGetRequest(dpy, X_##name, SIZEOF(xResourceReq)); \
+ req->id = (rid)
#else
#define GetResReq(name, rid, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = 2;\
- req->id = (rid);\
- dpy->bufptr += SIZEOF(xResourceReq);\
- dpy->request++
+ req = (xResourceReq *) _XGetRequest(dpy, X_/**/name, SIZEOF(xResourceReq)); \
+ req->id = (rid)
#endif
/*
@@ -515,24 +496,10 @@ extern LockInfoPtr _Xglobal_lock;
*/
#if !defined(UNIXCPP) || defined(ANSICPP)
#define GetEmptyReq(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_##name;\
- req->length = 1;\
- dpy->bufptr += SIZEOF(xReq);\
- dpy->request++
+ req = (xReq *) _XGetRequest(dpy, X_##name, SIZEOF(xReq))
#else
#define GetEmptyReq(name, req) \
- WORD64ALIGN\
- if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
- _XFlush(dpy);\
- req = (xReq *) (dpy->last_req = dpy->bufptr);\
- req->reqType = X_/**/name;\
- req->length = 1;\
- dpy->bufptr += SIZEOF(xReq);\
- dpy->request++
+ req = (xReq *) _XGetRequest(dpy, X_/**/name, SIZEOF(xReq))
#endif
#ifdef WORD64