[PATCH xserver 2/3] glx: Inline some reply swapping code

Adam Jackson ajax at redhat.com
Wed Aug 16 18:49:17 UTC 2017


Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 glx/glxcmds.c     |  68 ++++++++++++++++++++++++++---------
 glx/glxcmdsswap.c | 103 ------------------------------------------------------
 glx/glxserver.h   |  22 ------------
 3 files changed, 52 insertions(+), 141 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 9ad90eec2..6a763970d 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -685,11 +685,12 @@ DoMakeCurrent(__GLXclientState * cl,
     }
 
     if (client->swapped) {
-        __glXSwapMakeCurrentReply(client, &reply);
-    }
-    else {
-        WriteToClient(client, sz_xGLXMakeCurrentReply, &reply);
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
+        __GLX_SWAP_INT(&reply.contextTag);
     }
+    WriteToClient(client, sz_xGLXMakeCurrentReply, &reply);
     return Success;
 }
 
@@ -751,11 +752,11 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc)
     };
 
     if (client->swapped) {
-        __glXSwapIsDirectReply(client, &reply);
-    }
-    else {
-        WriteToClient(client, sz_xGLXIsDirectReply, &reply);
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
     }
+    WriteToClient(client, sz_xGLXIsDirectReply, &reply);
 
     return Success;
 }
@@ -789,11 +790,14 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
     };
 
     if (client->swapped) {
-        __glXSwapQueryVersionReply(client, &reply);
-    }
-    else {
-        WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
+        __GLX_SWAP_INT(&reply.majorVersion);
+        __GLX_SWAP_INT(&reply.minorVersion);
     }
+
+    WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
     return Success;
 }
 
@@ -1738,7 +1742,16 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
     sendBuf[5] = (int) (ctx->pGlxScreen->pScreen->myNum);
 
     if (client->swapped) {
-        __glXSwapQueryContextInfoEXTReply(client, &reply, sendBuf);
+        int length = reply.length;
+
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
+        __GLX_SWAP_INT(&reply.n);
+        WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply);
+        __GLX_SWAP_INT_ARRAY((int *) sendBuf, length);
+        WriteToClient(client, length << 2, sendBuf);
     }
     else {
         WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply);
@@ -1968,7 +1981,16 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
     };
 
     if (client->swapped) {
-        __glXSwapGetDrawableAttributesReply(client, &reply, attributes);
+        int length = reply.length;
+
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
+        __GLX_SWAP_INT(&reply.numAttribs);
+        WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply);
+        __GLX_SWAP_INT_ARRAY((int *) attributes, length);
+        WriteToClient(client, length << 2, attributes);
     }
     else {
         WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply);
@@ -2415,7 +2437,14 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
     memcpy(buf, pGlxScreen->GLXextensions, n);
 
     if (client->swapped) {
-        glxSwapQueryExtensionsStringReply(client, &reply, buf);
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
+        __GLX_SWAP_INT(&reply.n);
+        WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply);
+        __GLX_SWAP_INT_ARRAY((int *) buf, length);
+        WriteToClient(client, length << 2, buf);
     }
     else {
         WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply);
@@ -2483,7 +2512,14 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
     memcpy(buf, ptr, n);
 
     if (client->swapped) {
-        glxSwapQueryServerStringReply(client, &reply, buf);
+        __GLX_DECLARE_SWAP_VARIABLES;
+        __GLX_SWAP_SHORT(&reply.sequenceNumber);
+        __GLX_SWAP_INT(&reply.length);
+        __GLX_SWAP_INT(&reply.n);
+        WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
+        /** no swap is needed for an array of chars **/
+        /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
+        WriteToClient(client, length << 2, buf);
     }
     else {
         WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c
index 9ec1222f8..44a09e61c 100644
--- a/glx/glxcmdsswap.c
+++ b/glx/glxcmdsswap.c
@@ -826,109 +826,6 @@ __glXDispSwap_GetDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
 /************************************************************************/
 
 /*
-** Swap replies.
-*/
-
-void
-__glXSwapMakeCurrentReply(ClientPtr client, xGLXMakeCurrentReply * reply)
-{
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    __GLX_SWAP_INT(&reply->contextTag);
-    WriteToClient(client, sz_xGLXMakeCurrentReply, reply);
-}
-
-void
-__glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply * reply)
-{
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    WriteToClient(client, sz_xGLXIsDirectReply, reply);
-}
-
-void
-__glXSwapQueryVersionReply(ClientPtr client, xGLXQueryVersionReply * reply)
-{
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    __GLX_SWAP_INT(&reply->majorVersion);
-    __GLX_SWAP_INT(&reply->minorVersion);
-    WriteToClient(client, sz_xGLXQueryVersionReply, reply);
-}
-
-void
-glxSwapQueryExtensionsStringReply(ClientPtr client,
-                                  xGLXQueryExtensionsStringReply * reply,
-                                  char *buf)
-{
-    int length = reply->length;
-
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    __GLX_SWAP_INT(&reply->n);
-    WriteToClient(client, sz_xGLXQueryExtensionsStringReply, reply);
-    __GLX_SWAP_INT_ARRAY((int *) buf, length);
-    WriteToClient(client, length << 2, buf);
-}
-
-void
-glxSwapQueryServerStringReply(ClientPtr client,
-                              xGLXQueryServerStringReply * reply, char *buf)
-{
-    int length = reply->length;
-
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    __GLX_SWAP_INT(&reply->n);
-    WriteToClient(client, sz_xGLXQueryServerStringReply, reply);
-    /** no swap is needed for an array of chars **/
-    /* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
-    WriteToClient(client, length << 2, buf);
-}
-
-void
-__glXSwapQueryContextInfoEXTReply(ClientPtr client,
-                                  xGLXQueryContextInfoEXTReply * reply,
-                                  int *buf)
-{
-    int length = reply->length;
-
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    __GLX_SWAP_INT(&reply->n);
-    WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, reply);
-    __GLX_SWAP_INT_ARRAY((int *) buf, length);
-    WriteToClient(client, length << 2, buf);
-}
-
-void
-__glXSwapGetDrawableAttributesReply(ClientPtr client,
-                                    xGLXGetDrawableAttributesReply * reply,
-                                    CARD32 *buf)
-{
-    int length = reply->length;
-
-    __GLX_DECLARE_SWAP_VARIABLES;
-    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
-    __GLX_SWAP_SHORT(&reply->sequenceNumber);
-    __GLX_SWAP_INT(&reply->length);
-    __GLX_SWAP_INT(&reply->numAttribs);
-    WriteToClient(client, sz_xGLXGetDrawableAttributesReply, reply);
-    __GLX_SWAP_INT_ARRAY((int *) buf, length);
-    WriteToClient(client, length << 2, buf);
-}
-
-/************************************************************************/
-
-/*
 ** Render and Renderlarge are not in the GLX API.  They are used by the GLX
 ** client library to send batches of GL rendering commands.
 */
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 547826bd9..a54ce4b92 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -189,28 +189,6 @@ extern RESTYPE __glXDrawableRes;
 extern char *__glXcombine_strings(const char *, const char *);
 
 /*
-** Routines for sending swapped replies.
-*/
-
-extern void __glXSwapMakeCurrentReply(ClientPtr client,
-                                      xGLXMakeCurrentReply * reply);
-extern void __glXSwapIsDirectReply(ClientPtr client, xGLXIsDirectReply * reply);
-extern void __glXSwapQueryVersionReply(ClientPtr client,
-                                       xGLXQueryVersionReply * reply);
-extern void __glXSwapQueryContextInfoEXTReply(ClientPtr client,
-                                              xGLXQueryContextInfoEXTReply *
-                                              reply, int *buf);
-extern void __glXSwapGetDrawableAttributesReply(ClientPtr client,
-                                                xGLXGetDrawableAttributesReply *
-                                                reply, CARD32 *buf);
-extern void glxSwapQueryExtensionsStringReply(ClientPtr client,
-                                              xGLXQueryExtensionsStringReply *
-                                              reply, char *buf);
-extern void glxSwapQueryServerStringReply(ClientPtr client,
-                                          xGLXQueryServerStringReply * reply,
-                                          char *buf);
-
-/*
  * Routines for computing the size of variably-sized rendering commands.
  */
 
-- 
2.13.4



More information about the xorg-devel mailing list