glxcmdsswap.c 23.5 KB
Newer Older
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1
/*
Adam Jackson's avatar
Adam Jackson committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice including the dates of first publication and
 * either this permission notice or a reference to
 * http://oss.sgi.com/projects/FreeB/
 * shall be included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * Except as contained in this notice, the name of Silicon Graphics, Inc.
 * shall not be used in advertising or otherwise to promote the sale, use or
 * other dealings in this Software without prior written authorization from
 * Silicon Graphics, Inc.
 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
30

31 32 33 34
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif

35
#include <string.h>
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
36 37 38 39 40 41 42
#include "glxserver.h"
#include "glxutil.h"
#include <GL/glxtokens.h>
#include <unpack.h>
#include <pixmapstr.h>
#include <windowstr.h>
#include "glxext.h"
43
#include "indirect_dispatch.h"
44 45
#include "indirect_table.h"
#include "indirect_util.h"
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
46 47 48 49 50 51 52 53 54 55

/************************************************************************/

/*
** Byteswapping versions of GLX commands.  In most cases they just swap
** the incoming arguments and then call the unswapped routine.  For commands
** that have replies, a separate swapping routine for the reply is provided;
** it is called at the end of the unswapped routine.
*/

56 57
int
__glXDispSwap_CreateContext(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
58
{
59
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
60
    xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
61

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
62 63
    __GLX_DECLARE_SWAP_VARIABLES;

64 65
    REQUEST_SIZE_MATCH(xGLXCreateContextReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
66 67 68 69 70 71
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->context);
    __GLX_SWAP_INT(&req->visual);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->shareList);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
72
    return __glXDisp_CreateContext(cl, pc);
Eric Anholt's avatar
Eric Anholt committed
73 74
}

75 76
int
__glXDispSwap_CreateNewContext(__GLXclientState * cl, GLbyte * pc)
Eric Anholt's avatar
Eric Anholt committed
77
{
78
    ClientPtr client = cl->client;
Eric Anholt's avatar
Eric Anholt committed
79
    xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
80

Eric Anholt's avatar
Eric Anholt committed
81 82
    __GLX_DECLARE_SWAP_VARIABLES;

83 84
    REQUEST_SIZE_MATCH(xGLXCreateNewContextReq);

Eric Anholt's avatar
Eric Anholt committed
85 86 87 88 89 90 91
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->context);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->renderType);
    __GLX_SWAP_INT(&req->shareList);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
92
    return __glXDisp_CreateNewContext(cl, pc);
Eric Anholt's avatar
Eric Anholt committed
93 94
}

95 96
int
__glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState * cl, GLbyte * pc)
Eric Anholt's avatar
Eric Anholt committed
97
{
98
    ClientPtr client = cl->client;
Eric Anholt's avatar
Eric Anholt committed
99
    xGLXCreateContextWithConfigSGIXReq *req =
100
        (xGLXCreateContextWithConfigSGIXReq *) pc;
Eric Anholt's avatar
Eric Anholt committed
101 102
    __GLX_DECLARE_SWAP_VARIABLES;

103 104
    REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq);

Eric Anholt's avatar
Eric Anholt committed
105 106 107 108 109 110 111
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->context);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->renderType);
    __GLX_SWAP_INT(&req->shareList);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
112
    return __glXDisp_CreateContextWithConfigSGIX(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
113 114
}

115 116
int
__glXDispSwap_DestroyContext(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
117
{
118
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
119
    xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
120

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
121 122
    __GLX_DECLARE_SWAP_VARIABLES;

123 124
    REQUEST_SIZE_MATCH(xGLXDestroyContextReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
125 126 127
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->context);

128
    return __glXDisp_DestroyContext(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
129 130
}

131 132
int
__glXDispSwap_MakeCurrent(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
133
{
134
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
135
    xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
136

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
137 138
    __GLX_DECLARE_SWAP_VARIABLES;

139 140
    REQUEST_SIZE_MATCH(xGLXMakeCurrentReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
141 142 143 144 145
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->drawable);
    __GLX_SWAP_INT(&req->context);
    __GLX_SWAP_INT(&req->oldContextTag);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
146
    return __glXDisp_MakeCurrent(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
147 148
}

149 150
int
__glXDispSwap_MakeContextCurrent(__GLXclientState * cl, GLbyte * pc)
151
{
152
    ClientPtr client = cl->client;
153
    xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
154

155 156
    __GLX_DECLARE_SWAP_VARIABLES;

157 158
    REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq);

159 160 161 162 163 164
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->drawable);
    __GLX_SWAP_INT(&req->readdrawable);
    __GLX_SWAP_INT(&req->context);
    __GLX_SWAP_INT(&req->oldContextTag);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
165
    return __glXDisp_MakeContextCurrent(cl, pc);
166 167
}

168 169
int
__glXDispSwap_MakeCurrentReadSGI(__GLXclientState * cl, GLbyte * pc)
170
{
171
    ClientPtr client = cl->client;
172
    xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
173

174 175
    __GLX_DECLARE_SWAP_VARIABLES;

176 177
    REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq);

178 179 180 181 182 183
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->drawable);
    __GLX_SWAP_INT(&req->readable);
    __GLX_SWAP_INT(&req->context);
    __GLX_SWAP_INT(&req->oldContextTag);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
184
    return __glXDisp_MakeCurrentReadSGI(cl, pc);
185 186
}

187 188
int
__glXDispSwap_IsDirect(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
189
{
190
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
191
    xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
192

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
193 194
    __GLX_DECLARE_SWAP_VARIABLES;

195 196
    REQUEST_SIZE_MATCH(xGLXIsDirectReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
197 198 199
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->context);

200
    return __glXDisp_IsDirect(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
201 202
}

203 204
int
__glXDispSwap_QueryVersion(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
205
{
206
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
207
    xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
208

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
209 210
    __GLX_DECLARE_SWAP_VARIABLES;

211 212
    REQUEST_SIZE_MATCH(xGLXQueryVersionReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
213 214 215 216
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->majorVersion);
    __GLX_SWAP_INT(&req->minorVersion);

217
    return __glXDisp_QueryVersion(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
218 219
}

220 221
int
__glXDispSwap_WaitGL(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
222
{
223
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
224
    xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
225

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
226 227
    __GLX_DECLARE_SWAP_VARIABLES;

228 229
    REQUEST_SIZE_MATCH(xGLXWaitGLReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
230 231 232
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->contextTag);

233
    return __glXDisp_WaitGL(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
234 235
}

236 237
int
__glXDispSwap_WaitX(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
238
{
239
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
240
    xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
241

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
242 243
    __GLX_DECLARE_SWAP_VARIABLES;

244 245
    REQUEST_SIZE_MATCH(xGLXWaitXReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
246 247 248
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->contextTag);

249
    return __glXDisp_WaitX(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
250 251
}

252 253
int
__glXDispSwap_CopyContext(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
254
{
255
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
256
    xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
257

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
258 259
    __GLX_DECLARE_SWAP_VARIABLES;

260 261
    REQUEST_SIZE_MATCH(xGLXCopyContextReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
262 263 264 265 266
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->source);
    __GLX_SWAP_INT(&req->dest);
    __GLX_SWAP_INT(&req->mask);

267
    return __glXDisp_CopyContext(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
268 269
}

270 271
int
__glXDispSwap_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
272
{
273
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
274
    xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
275

Egbert Eich's avatar
Egbert Eich committed
276
    __GLX_DECLARE_SWAP_VARIABLES;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
277

278 279
    REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
280
    __GLX_SWAP_INT(&req->screen);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
281
    return __glXDisp_GetVisualConfigs(cl, pc);
Eric Anholt's avatar
Eric Anholt committed
282 283
}

284 285
int
__glXDispSwap_GetFBConfigs(__GLXclientState * cl, GLbyte * pc)
Eric Anholt's avatar
Eric Anholt committed
286
{
287
    ClientPtr client = cl->client;
Eric Anholt's avatar
Eric Anholt committed
288
    xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
289

Eric Anholt's avatar
Eric Anholt committed
290 291
    __GLX_DECLARE_SWAP_VARIABLES;

292 293
    REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq);

Eric Anholt's avatar
Eric Anholt committed
294
    __GLX_SWAP_INT(&req->screen);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
295
    return __glXDisp_GetFBConfigs(cl, pc);
Eric Anholt's avatar
Eric Anholt committed
296 297
}

298 299
int
__glXDispSwap_GetFBConfigsSGIX(__GLXclientState * cl, GLbyte * pc)
Eric Anholt's avatar
Eric Anholt committed
300
{
301
    ClientPtr client = cl->client;
Eric Anholt's avatar
Eric Anholt committed
302
    xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
303

Eric Anholt's avatar
Eric Anholt committed
304 305
    __GLX_DECLARE_SWAP_VARIABLES;

306
    REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq);
307

Eric Anholt's avatar
Eric Anholt committed
308
    __GLX_SWAP_INT(&req->screen);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
309
    return __glXDisp_GetFBConfigsSGIX(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
310 311
}

312 313
int
__glXDispSwap_CreateGLXPixmap(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
314
{
315
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
316
    xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
317

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
318 319
    __GLX_DECLARE_SWAP_VARIABLES;

320 321
    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
322 323 324 325 326 327
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->visual);
    __GLX_SWAP_INT(&req->pixmap);
    __GLX_SWAP_INT(&req->glxpixmap);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
328
    return __glXDisp_CreateGLXPixmap(cl, pc);
Eric Anholt's avatar
Eric Anholt committed
329 330
}

331 332
int
__glXDispSwap_CreatePixmap(__GLXclientState * cl, GLbyte * pc)
Eric Anholt's avatar
Eric Anholt committed
333
{
334
    ClientPtr client = cl->client;
Eric Anholt's avatar
Eric Anholt committed
335
    xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
336
    CARD32 *attribs;
337

Eric Anholt's avatar
Eric Anholt committed
338
    __GLX_DECLARE_SWAP_VARIABLES;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
339
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
Eric Anholt's avatar
Eric Anholt committed
340

341 342
    REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq);

Eric Anholt's avatar
Eric Anholt committed
343 344 345 346 347
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->pixmap);
    __GLX_SWAP_INT(&req->glxpixmap);
348
    __GLX_SWAP_INT(&req->numAttribs);
349

350
    if (req->numAttribs > (UINT32_MAX >> 3)) {
351 352
        client->errorValue = req->numAttribs;
        return BadValue;
353
    }
354
    REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3);
355
    attribs = (CARD32 *) (req + 1);
356
    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
Eric Anholt's avatar
Eric Anholt committed
357

Kristian Høgsberg's avatar
Kristian Høgsberg committed
358
    return __glXDisp_CreatePixmap(cl, pc);
Eric Anholt's avatar
Eric Anholt committed
359 360
}

361 362
int
__glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState * cl, GLbyte * pc)
Eric Anholt's avatar
Eric Anholt committed
363
{
364
    ClientPtr client = cl->client;
365 366
    xGLXCreateGLXPixmapWithConfigSGIXReq *req =
        (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
Eric Anholt's avatar
Eric Anholt committed
367 368
    __GLX_DECLARE_SWAP_VARIABLES;

369 370
    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq);

Eric Anholt's avatar
Eric Anholt committed
371 372 373 374 375 376
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->pixmap);
    __GLX_SWAP_INT(&req->glxpixmap);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
377
    return __glXDisp_CreateGLXPixmapWithConfigSGIX(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
378 379
}

380 381
int
__glXDispSwap_DestroyGLXPixmap(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
382
{
383
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
384
    xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
385

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
386 387
    __GLX_DECLARE_SWAP_VARIABLES;

388 389
    REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
390 391 392
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->glxpixmap);

393
    return __glXDisp_DestroyGLXPixmap(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
394 395
}

396 397
int
__glXDispSwap_DestroyPixmap(__GLXclientState * cl, GLbyte * pc)
398
{
399
    ClientPtr client = cl->client;
400
    xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
401

402 403
    __GLX_DECLARE_SWAP_VARIABLES;

404
    REQUEST_AT_LEAST_SIZE(xGLXDestroyGLXPixmapReq);
405

406 407 408
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->glxpixmap);

409
    return __glXDisp_DestroyGLXPixmap(cl, pc);
410 411
}

412 413
int
__glXDispSwap_QueryContext(__GLXclientState * cl, GLbyte * pc)
414
{
415
    ClientPtr client = cl->client;
416 417
    xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
418
    __GLX_DECLARE_SWAP_VARIABLES;
419

420 421
    REQUEST_SIZE_MATCH(xGLXQueryContextReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
422
    __GLX_SWAP_INT(&req->context);
423

Kristian Høgsberg's avatar
Kristian Høgsberg committed
424
    return __glXDisp_QueryContext(cl, pc);
425 426
}

427 428
int
__glXDispSwap_CreatePbuffer(__GLXclientState * cl, GLbyte * pc)
429
{
430
    ClientPtr client = cl->client;
431 432
    xGLXCreatePbufferReq *req = (xGLXCreatePbufferReq *) pc;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
433 434 435
    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
    CARD32 *attribs;
436

437 438
    REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
439 440 441 442
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->pbuffer);
    __GLX_SWAP_INT(&req->numAttribs);
443

444
    if (req->numAttribs > (UINT32_MAX >> 3)) {
445 446
        client->errorValue = req->numAttribs;
        return BadValue;
447
    }
448
    REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3);
449
    attribs = (CARD32 *) (req + 1);
450
    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
451

Kristian Høgsberg's avatar
Kristian Høgsberg committed
452
    return __glXDisp_CreatePbuffer(cl, pc);
453 454
}

455 456
int
__glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState * cl, GLbyte * pc)
457
{
458
    ClientPtr client = cl->client;
459 460
    xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
461
    __GLX_DECLARE_SWAP_VARIABLES;
462

463
    REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq);
464

Kristian Høgsberg's avatar
Kristian Høgsberg committed
465 466 467 468 469
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->pbuffer);
    __GLX_SWAP_INT(&req->width);
    __GLX_SWAP_INT(&req->height);
470

Kristian Høgsberg's avatar
Kristian Høgsberg committed
471
    return __glXDisp_CreateGLXPbufferSGIX(cl, pc);
472 473
}

474 475
int
__glXDispSwap_DestroyPbuffer(__GLXclientState * cl, GLbyte * pc)
476
{
477
    ClientPtr client = cl->client;
478
    xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
479

Kristian Høgsberg's avatar
Kristian Høgsberg committed
480
    __GLX_DECLARE_SWAP_VARIABLES;
481

482 483
    REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
484 485 486
    __GLX_SWAP_INT(&req->pbuffer);

    return __glXDisp_DestroyPbuffer(cl, pc);
487 488
}

489 490
int
__glXDispSwap_DestroyGLXPbufferSGIX(__GLXclientState * cl, GLbyte * pc)
491
{
492
    ClientPtr client = cl->client;
493
    xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc;
494

Kristian Høgsberg's avatar
Kristian Høgsberg committed
495
    __GLX_DECLARE_SWAP_VARIABLES;
496

497 498
    REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
499 500 501
    __GLX_SWAP_INT(&req->pbuffer);

    return __glXDisp_DestroyGLXPbufferSGIX(cl, pc);
502 503
}

504 505
int
__glXDispSwap_ChangeDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
506
{
507
    ClientPtr client = cl->client;
508
    xGLXChangeDrawableAttributesReq *req =
509
        (xGLXChangeDrawableAttributesReq *) pc;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
510 511 512 513
    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
    CARD32 *attribs;

514 515
    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
516 517
    __GLX_SWAP_INT(&req->drawable);
    __GLX_SWAP_INT(&req->numAttribs);
518

519
    if (req->numAttribs > (UINT32_MAX >> 3)) {
520 521
        client->errorValue = req->numAttribs;
        return BadValue;
522
    }
523 524 525
    if (((sizeof(xGLXChangeDrawableAttributesReq) +
          (req->numAttribs << 3)) >> 2) < client->req_len)
        return BadLength;
526

527
    attribs = (CARD32 *) (req + 1);
528
    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
529

Kristian Høgsberg's avatar
Kristian Høgsberg committed
530
    return __glXDisp_ChangeDrawableAttributes(cl, pc);
531 532
}

533 534
int
__glXDispSwap_ChangeDrawableAttributesSGIX(__GLXclientState * cl, GLbyte * pc)
535
{
536
    ClientPtr client = cl->client;
537
    xGLXChangeDrawableAttributesSGIXReq *req =
538
        (xGLXChangeDrawableAttributesSGIXReq *) pc;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
539 540 541
    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
    CARD32 *attribs;
542

543 544
    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
545 546
    __GLX_SWAP_INT(&req->drawable);
    __GLX_SWAP_INT(&req->numAttribs);
547

548
    if (req->numAttribs > (UINT32_MAX >> 3)) {
549 550
        client->errorValue = req->numAttribs;
        return BadValue;
551
    }
552 553 554
    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq,
                       req->numAttribs << 3);
    attribs = (CARD32 *) (req + 1);
555
    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
556 557

    return __glXDisp_ChangeDrawableAttributesSGIX(cl, pc);
558 559
}

560 561
int
__glXDispSwap_CreateWindow(__GLXclientState * cl, GLbyte * pc)
562
{
563
    ClientPtr client = cl->client;
564
    xGLXCreateWindowReq *req = (xGLXCreateWindowReq *) pc;
565

Kristian Høgsberg's avatar
Kristian Høgsberg committed
566 567 568
    __GLX_DECLARE_SWAP_VARIABLES;
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
    CARD32 *attribs;
569

570 571
    REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
572 573 574 575 576
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->fbconfig);
    __GLX_SWAP_INT(&req->window);
    __GLX_SWAP_INT(&req->glxwindow);
    __GLX_SWAP_INT(&req->numAttribs);
577

578
    if (req->numAttribs > (UINT32_MAX >> 3)) {
579 580
        client->errorValue = req->numAttribs;
        return BadValue;
581
    }
582
    REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3);
583
    attribs = (CARD32 *) (req + 1);
584
    __GLX_SWAP_INT_ARRAY(attribs, req->numAttribs << 1);
585

Kristian Høgsberg's avatar
Kristian Høgsberg committed
586
    return __glXDisp_CreateWindow(cl, pc);
587 588
}

589 590
int
__glXDispSwap_DestroyWindow(__GLXclientState * cl, GLbyte * pc)
591
{
592
    ClientPtr client = cl->client;
593
    xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
594

Kristian Høgsberg's avatar
Kristian Høgsberg committed
595
    __GLX_DECLARE_SWAP_VARIABLES;
596

597
    REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq);
598

Kristian Høgsberg's avatar
Kristian Høgsberg committed
599
    __GLX_SWAP_INT(&req->glxwindow);
600

Kristian Høgsberg's avatar
Kristian Høgsberg committed
601
    return __glXDisp_DestroyWindow(cl, pc);
602 603
}

604 605
int
__glXDispSwap_SwapBuffers(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
606
{
607
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
608
    xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
609

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
610 611
    __GLX_DECLARE_SWAP_VARIABLES;

612 613
    REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
614 615 616 617
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->contextTag);
    __GLX_SWAP_INT(&req->drawable);

618
    return __glXDisp_SwapBuffers(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
619 620
}

621 622
int
__glXDispSwap_UseXFont(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
623
{
624
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
625
    xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
626

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
627 628
    __GLX_DECLARE_SWAP_VARIABLES;

629 630
    REQUEST_SIZE_MATCH(xGLXUseXFontReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
631 632 633 634 635 636 637
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->contextTag);
    __GLX_SWAP_INT(&req->font);
    __GLX_SWAP_INT(&req->first);
    __GLX_SWAP_INT(&req->count);
    __GLX_SWAP_INT(&req->listBase);

638
    return __glXDisp_UseXFont(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
639 640
}

641 642
int
__glXDispSwap_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
643
{
644
    ClientPtr client = cl->client;
645 646
    xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
647 648
    __GLX_DECLARE_SWAP_VARIABLES;

649 650
    REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
651 652 653
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->screen);

654
    return __glXDisp_QueryExtensionsString(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
655 656
}

657 658
int
__glXDispSwap_QueryServerString(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
659
{
660
    ClientPtr client = cl->client;
661 662
    xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
663 664
    __GLX_DECLARE_SWAP_VARIABLES;

665 666
    REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
667 668 669 670
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->screen);
    __GLX_SWAP_INT(&req->name);

671
    return __glXDisp_QueryServerString(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
672 673
}

674 675
int
__glXDispSwap_ClientInfo(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
676
{
677
    ClientPtr client = cl->client;
678 679
    xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
680 681
    __GLX_DECLARE_SWAP_VARIABLES;

682 683
    REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
684 685 686 687 688
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->major);
    __GLX_SWAP_INT(&req->minor);
    __GLX_SWAP_INT(&req->numbytes);

689
    return __glXDisp_ClientInfo(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
690 691
}

692 693
int
__glXDispSwap_QueryContextInfoEXT(__GLXclientState * cl, GLbyte * pc)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
694
{
695
    ClientPtr client = cl->client;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
696
    xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
697

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
698 699
    __GLX_DECLARE_SWAP_VARIABLES;

700 701
    REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq);

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
702 703 704
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->context);

705
    return __glXDisp_QueryContextInfoEXT(cl, pc);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
706 707
}

708 709
int
__glXDispSwap_BindTexImageEXT(__GLXclientState * cl, GLbyte * pc)
710
{
711
    ClientPtr client = cl->client;
712
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
713 714 715 716
    GLXDrawable *drawId;
    int *buffer;
    CARD32 *num_attribs;

717 718
    __GLX_DECLARE_SWAP_VARIABLES;

719
    if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len)
720
        return BadLength;
721

722 723 724
    pc += __GLX_VENDPRIV_HDR_SIZE;

    drawId = ((GLXDrawable *) (pc));
725
    buffer = ((int *) (pc + 4));
726
    num_attribs = ((CARD32 *) (pc + 8));
727

728 729 730 731
    __GLX_SWAP_SHORT(&req->length);
    __GLX_SWAP_INT(&req->contextTag);
    __GLX_SWAP_INT(drawId);
    __GLX_SWAP_INT(buffer);
732
    __GLX_SWAP_INT(num_attribs);
733

734
    return __glXDisp_BindTexImageEXT(cl, (GLbyte *) pc);
735 736
}

737 738
int
__glXDispSwap_ReleaseTexImageEXT(__GLXclientState * cl, GLbyte * pc)
739
{
740
    ClientPtr client = cl->client;
741
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
742 743 744
    GLXDrawable *drawId;
    int *buffer;

745 746
    __GLX_DECLARE_SWAP_VARIABLES;

747 748
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8);

749 750 751
    pc += __GLX_VENDPRIV_HDR_SIZE;

    drawId = ((GLXDrawable *) (pc));
752 753
    buffer = ((int *) (pc + 4));