glx: Remove __glXReply

Static data bad, hulk smash.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Adam Jackson 2017-06-16 15:44:48 -04:00
parent d6db668116
commit c33541e59e
9 changed files with 69 additions and 74 deletions

View File

@ -53,11 +53,6 @@
RESTYPE __glXContextRes;
RESTYPE __glXDrawableRes;
/*
** Reply for most singles.
*/
xGLXSingleReply __glXReply;
static DevPrivateKeyRec glxClientPrivateKeyRec;
#define glxClientPrivateKey (&glxClientPrivateKeyRec)

View File

@ -64,6 +64,7 @@ DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte * pc,
GLenum pname;
GLint compsize = 0;
char *answer = NULL, answerBuffer[200];
xGLXSingleReply reply = { 0, };
if (do_swap) {
target = (GLenum) bswap_32(*(int *) (pc + 0));
@ -92,7 +93,7 @@ DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte * pc,
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetTexImageReply *) &__glXReply)->width = compsize;
((xGLXGetTexImageReply *) &reply)->width = compsize;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}

View File

@ -51,6 +51,7 @@ __glXDisp_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc)
const GLint level = *(GLint *) (pc + 4);
GLint compsize = 0;
char *answer = NULL, answerBuffer[200];
xGLXSingleReply reply = { 0, };
glGetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
&compsize);
@ -69,7 +70,7 @@ __glXDisp_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc)
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetTexImageReply *) &__glXReply)->width = compsize;
((xGLXGetTexImageReply *) &reply)->width = compsize;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -97,6 +98,7 @@ __glXDispSwap_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc)
const GLint level = (GLint) bswap_32(*(int *) (pc + 4));
GLint compsize = 0;
char *answer = NULL, answerBuffer[200];
xGLXSingleReply reply = { 0, };
glGetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
&compsize);
@ -115,7 +117,7 @@ __glXDispSwap_GetCompressedTexImage(struct __GLXclientStateRec *cl, GLbyte * pc)
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetTexImageReply *) &__glXReply)->width = compsize;
((xGLXGetTexImageReply *) &reply)->width = compsize;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}

View File

@ -45,8 +45,6 @@
#define __GLX_PAD(a) (((a)+3)&~3)
extern xGLXSingleReply __glXReply;
GLint
__glGetBooleanv_variable_size(GLenum e)
{
@ -117,6 +115,7 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
size_t element_size, GLboolean always_array, CARD32 retval)
{
size_t reply_ints = 0;
xGLXSingleReply reply = { 0, };
if (__glXErrorOccured()) {
elements = 0;
@ -125,11 +124,11 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
reply_ints = bytes_to_int32(elements * element_size);
}
__glXReply.length = reply_ints;
__glXReply.type = X_Reply;
__glXReply.sequenceNumber = client->sequence;
__glXReply.size = elements;
__glXReply.retval = retval;
reply.length = reply_ints;
reply.type = X_Reply;
reply.sequenceNumber = client->sequence;
reply.size = elements;
reply.retval = retval;
/* It is faster on almost always every architecture to just copy the 8
* bytes, even when not necessary, than check to see of the value of
@ -137,8 +136,8 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
* harm.
*/
(void) memcpy(&__glXReply.pad3, data, 8);
WriteToClient(client, sz_xGLXSingleReply, &__glXReply);
(void) memcpy(&reply.pad3, data, 8);
WriteToClient(client, sz_xGLXSingleReply, &reply);
if (reply_ints != 0) {
WriteToClient(client, reply_ints * 4, data);
@ -163,6 +162,7 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
size_t element_size, GLboolean always_array, CARD32 retval)
{
size_t reply_ints = 0;
xGLXSingleReply reply = { 0, };
if (__glXErrorOccured()) {
elements = 0;
@ -171,11 +171,11 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
reply_ints = bytes_to_int32(elements * element_size);
}
__glXReply.length = bswap_32(reply_ints);
__glXReply.type = X_Reply;
__glXReply.sequenceNumber = bswap_16(client->sequence);
__glXReply.size = bswap_32(elements);
__glXReply.retval = bswap_32(retval);
reply.length = bswap_32(reply_ints);
reply.type = X_Reply;
reply.sequenceNumber = bswap_16(client->sequence);
reply.size = bswap_32(elements);
reply.retval = bswap_32(retval);
/* It is faster on almost always every architecture to just copy the 8
* bytes, even when not necessary, than check to see of the value of
@ -183,8 +183,8 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
* harm.
*/
(void) memcpy(&__glXReply.pad3, data, 8);
WriteToClient(client, sz_xGLXSingleReply, &__glXReply);
(void) memcpy(&reply.pad3, data, 8);
WriteToClient(client, sz_xGLXSingleReply, &reply);
if (reply_ints != 0) {
WriteToClient(client, reply_ints * 4, data);

View File

@ -232,6 +232,7 @@ __glXDisp_Finish(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
__GLXcontext *cx;
int error;
xGLXSingleReply reply = { 0, };
REQUEST_SIZE_MATCH(xGLXSingleReq);
@ -328,6 +329,7 @@ DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap)
__GLXcontext *cx;
GLenum name;
const char *string;
xGLXSingleReply reply = { 0, };
__GLX_DECLARE_SWAP_VARIABLES;
int error;

View File

@ -252,6 +252,7 @@ __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
__GLXcontext *cx;
int error;
xGLXSingleReply reply = { 0, };
__GLX_DECLARE_SWAP_VARIABLES;

View File

@ -50,6 +50,7 @@ __glXDisp_ReadPixels(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
int error;
char *answer, answerBuffer[200];
xGLXSingleReply reply = { 0, };
REQUEST_FIXED_SIZE(xGLXSingleReq, 28);
@ -100,6 +101,7 @@ __glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0, depth = 1;
xGLXSingleReply reply = { 0, };
REQUEST_FIXED_SIZE(xGLXSingleReq, 20);
@ -141,9 +143,9 @@ __glXDisp_GetTexImage(__GLXclientState * cl, GLbyte * pc)
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetTexImageReply *) &__glXReply)->width = width;
((xGLXGetTexImageReply *) &__glXReply)->height = height;
((xGLXGetTexImageReply *) &__glXReply)->depth = depth;
((xGLXGetTexImageReply *) &reply)->width = width;
((xGLXGetTexImageReply *) &reply)->height = height;
((xGLXGetTexImageReply *) &reply)->depth = depth;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -159,6 +161,7 @@ __glXDisp_GetPolygonStipple(__GLXclientState * cl, GLbyte * pc)
int error;
GLubyte answerBuffer[200];
char *answer;
xGLXSingleReply reply = { 0, };
REQUEST_FIXED_SIZE(xGLXSingleReq, 4);
@ -199,6 +202,7 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -239,8 +243,8 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
}
else {
__GLX_BEGIN_REPLY(compsize + compsize2);
((xGLXGetSeparableFilterReply *) &__glXReply)->width = width;
((xGLXGetSeparableFilterReply *) &__glXReply)->height = height;
((xGLXGetSeparableFilterReply *) &reply)->width = width;
((xGLXGetSeparableFilterReply *) &reply)->height = height;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize + compsize2);
}
@ -277,6 +281,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -315,8 +320,8 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetConvolutionFilterReply *) &__glXReply)->width = width;
((xGLXGetConvolutionFilterReply *) &__glXReply)->height = height;
((xGLXGetConvolutionFilterReply *) &reply)->width = width;
((xGLXGetConvolutionFilterReply *) &reply)->height = height;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -353,6 +358,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -385,7 +391,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetHistogramReply *) &__glXReply)->width = width;
((xGLXGetHistogramReply *) &reply)->width = width;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -421,6 +427,7 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
ClientPtr client = cl->client;
int error;
char *answer, answerBuffer[200];
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -484,6 +491,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
int error;
char *answer, answerBuffer[200];
GLint width = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -516,7 +524,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
}
else {
__GLX_BEGIN_REPLY(compsize);
((xGLXGetColorTableReply *) &__glXReply)->width = width;
((xGLXGetColorTableReply *) &reply)->width = width;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}

View File

@ -52,6 +52,7 @@ __glXDispSwap_ReadPixels(__GLXclientState * cl, GLbyte * pc)
ClientPtr client = cl->client;
int error;
char *answer, answerBuffer[200];
xGLXSingleReply reply = { 0, };
REQUEST_FIXED_SIZE(xGLXSingleReq, 28);
@ -114,6 +115,7 @@ __glXDispSwap_GetTexImage(__GLXclientState * cl, GLbyte * pc)
int error;
char *answer, answerBuffer[200];
GLint width = 0, height = 0, depth = 1;
xGLXSingleReply reply = { 0, };
REQUEST_FIXED_SIZE(xGLXSingleReq, 20);
@ -166,9 +168,9 @@ __glXDispSwap_GetTexImage(__GLXclientState * cl, GLbyte * pc)
__GLX_SWAP_INT(&width);
__GLX_SWAP_INT(&height);
__GLX_SWAP_INT(&depth);
((xGLXGetTexImageReply *) &__glXReply)->width = width;
((xGLXGetTexImageReply *) &__glXReply)->height = height;
((xGLXGetTexImageReply *) &__glXReply)->depth = depth;
((xGLXGetTexImageReply *) &reply)->width = width;
((xGLXGetTexImageReply *) &reply)->height = height;
((xGLXGetTexImageReply *) &reply)->depth = depth;
__GLX_SEND_HEADER();
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -184,6 +186,7 @@ __glXDispSwap_GetPolygonStipple(__GLXclientState * cl, GLbyte * pc)
int error;
GLubyte answerBuffer[200];
char *answer;
xGLXSingleReply reply = { 0, };
__GLX_DECLARE_SWAP_VARIABLES;
@ -229,6 +232,7 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_DECLARE_SWAP_VARIABLES;
char *answer, answerBuffer[200];
GLint width = 0, height = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -276,8 +280,8 @@ GetSeparableFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_SWAP_REPLY_HEADER();
__GLX_SWAP_INT(&width);
__GLX_SWAP_INT(&height);
((xGLXGetSeparableFilterReply *) &__glXReply)->width = width;
((xGLXGetSeparableFilterReply *) &__glXReply)->height = height;
((xGLXGetSeparableFilterReply *) &reply)->width = width;
((xGLXGetSeparableFilterReply *) &reply)->height = height;
__GLX_SEND_VOID_ARRAY(compsize + compsize2);
}
@ -317,6 +321,7 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_DECLARE_SWAP_VARIABLES;
char *answer, answerBuffer[200];
GLint width = 0, height = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -362,8 +367,8 @@ GetConvolutionFilter(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_SWAP_REPLY_HEADER();
__GLX_SWAP_INT(&width);
__GLX_SWAP_INT(&height);
((xGLXGetConvolutionFilterReply *) &__glXReply)->width = width;
((xGLXGetConvolutionFilterReply *) &__glXReply)->height = height;
((xGLXGetConvolutionFilterReply *) &reply)->width = width;
((xGLXGetConvolutionFilterReply *) &reply)->height = height;
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -403,6 +408,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_DECLARE_SWAP_VARIABLES;
char *answer, answerBuffer[200];
GLint width = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -441,7 +447,7 @@ GetHistogram(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_BEGIN_REPLY(compsize);
__GLX_SWAP_REPLY_HEADER();
__GLX_SWAP_INT(&width);
((xGLXGetHistogramReply *) &__glXReply)->width = width;
((xGLXGetHistogramReply *) &reply)->width = width;
__GLX_SEND_VOID_ARRAY(compsize);
}
@ -480,6 +486,7 @@ GetMinmax(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_DECLARE_SWAP_VARIABLES;
char *answer, answerBuffer[200];
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -551,6 +558,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_DECLARE_SWAP_VARIABLES;
char *answer, answerBuffer[200];
GLint width = 0;
xGLXSingleReply reply = { 0, };
cx = __glXForceCurrent(cl, tag, &error);
if (!cx) {
@ -589,7 +597,7 @@ GetColorTable(__GLXclientState * cl, GLbyte * pc, GLXContextTag tag)
__GLX_BEGIN_REPLY(compsize);
__GLX_SWAP_REPLY_HEADER();
__GLX_SWAP_INT(&width);
((xGLXGetColorTableReply *) &__glXReply)->width = width;
((xGLXGetColorTableReply *) &reply)->width = width;
__GLX_SEND_VOID_ARRAY(compsize);
}

View File

@ -53,26 +53,19 @@
#define __GLX_GET_DOUBLE(dst,src) (dst) = *((GLdouble*)(src))
#endif
extern void __glXMemInit(void);
extern xGLXSingleReply __glXReply;
#define __GLX_BEGIN_REPLY(size) \
__glXReply.length = __GLX_PAD(size) >> 2; \
__glXReply.type = X_Reply; \
__glXReply.sequenceNumber = client->sequence;
reply.length = __GLX_PAD(size) >> 2; \
reply.type = X_Reply; \
reply.sequenceNumber = client->sequence;
#define __GLX_SEND_HEADER() \
WriteToClient (client, sz_xGLXSingleReply, &__glXReply);
WriteToClient (client, sz_xGLXSingleReply, &reply);
#define __GLX_PUT_RETVAL(a) \
__glXReply.retval = (a);
reply.retval = (a);
#define __GLX_PUT_SIZE(a) \
__glXReply.size = (a);
#define __GLX_PUT_RENDERMODE(m) \
__glXReply.pad3 = (m)
reply.size = (a);
/*
** Get a buffer to hold returned data, with the given alignment. If we have
@ -101,21 +94,6 @@ extern xGLXSingleReply __glXReply;
res = (char *)answerBuffer; \
}
#define __GLX_PUT_BYTE() \
*(GLbyte *)&__glXReply.pad3 = *(GLbyte *)answer
#define __GLX_PUT_SHORT() \
*(GLshort *)&__glXReply.pad3 = *(GLshort *)answer
#define __GLX_PUT_INT() \
*(GLint *)&__glXReply.pad3 = *(GLint *)answer
#define __GLX_PUT_FLOAT() \
*(GLfloat *)&__glXReply.pad3 = *(GLfloat *)answer
#define __GLX_PUT_DOUBLE() \
*(GLdouble *)&__glXReply.pad3 = *(GLdouble *)answer
#define __GLX_SEND_BYTE_ARRAY(len) \
WriteToClient(client, __GLX_PAD((len)*__GLX_SIZE_INT8), answer)
@ -216,13 +194,13 @@ extern xGLXSingleReply __glXReply;
}
#define __GLX_SWAP_REPLY_HEADER() \
__GLX_SWAP_SHORT(&__glXReply.sequenceNumber); \
__GLX_SWAP_INT(&__glXReply.length);
__GLX_SWAP_SHORT(&reply.sequenceNumber); \
__GLX_SWAP_INT(&reply.length);
#define __GLX_SWAP_REPLY_RETVAL() \
__GLX_SWAP_INT(&__glXReply.retval)
__GLX_SWAP_INT(&reply.retval)
#define __GLX_SWAP_REPLY_SIZE() \
__GLX_SWAP_INT(&__glXReply.size)
__GLX_SWAP_INT(&reply.size)
#endif /* !__GLX_unpack_h__ */