Xext: shm: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
a7f9bcaf39
commit
bac5e1fa2d
182
Xext/shm.c
182
Xext/shm.c
|
@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group.
|
||||||
#include <X11/Xfuncproto.h>
|
#include <X11/Xfuncproto.h>
|
||||||
|
|
||||||
#include "dix/dix_priv.h"
|
#include "dix/dix_priv.h"
|
||||||
|
#include "dix/request_priv.h"
|
||||||
#include "dix/screen_hooks_priv.h"
|
#include "dix/screen_hooks_priv.h"
|
||||||
#include "os/auth.h"
|
#include "os/auth.h"
|
||||||
#include "os/busfault.h"
|
#include "os/busfault.h"
|
||||||
|
@ -251,6 +252,8 @@ ShmRegisterFbFuncs(ScreenPtr pScreen)
|
||||||
static int
|
static int
|
||||||
ProcShmQueryVersion(ClientPtr client)
|
ProcShmQueryVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST_HEAD_STRUCT(xShmQueryVersionReq);
|
||||||
|
|
||||||
xShmQueryVersionReply rep = {
|
xShmQueryVersionReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sharedPixmaps = sharedPixmaps,
|
.sharedPixmaps = sharedPixmaps,
|
||||||
|
@ -263,8 +266,6 @@ ProcShmQueryVersion(ClientPtr client)
|
||||||
.pixmapFormat = sharedPixmaps ? ZPixmap : 0
|
.pixmapFormat = sharedPixmaps ? ZPixmap : 0
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xShmQueryVersionReq);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
|
@ -346,8 +347,9 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
|
||||||
static int
|
static int
|
||||||
ProcShmAttach(ClientPtr client)
|
ProcShmAttach(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmAttachReq);
|
REQUEST_HEAD_STRUCT(xShmAttachReq);
|
||||||
REQUEST_SIZE_MATCH(xShmAttachReq);
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
REQUEST_FIELD_CARD32(shmid);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -434,8 +436,8 @@ ShmDetachSegment(void *value, /* must conform to DeleteType */
|
||||||
static int
|
static int
|
||||||
ProcShmDetach(ClientPtr client)
|
ProcShmDetach(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmDetachReq);
|
REQUEST_HEAD_STRUCT(xShmDetachReq);
|
||||||
REQUEST_SIZE_MATCH(xShmDetachReq);
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -712,8 +714,19 @@ ShmGetImage(ClientPtr client, xShmGetImageReq *stuff)
|
||||||
static int
|
static int
|
||||||
ProcShmPutImage(ClientPtr client)
|
ProcShmPutImage(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmPutImageReq);
|
REQUEST_HEAD_STRUCT(xShmPutImageReq);
|
||||||
REQUEST_SIZE_MATCH(xShmPutImageReq);
|
REQUEST_FIELD_CARD32(drawable);
|
||||||
|
REQUEST_FIELD_CARD32(gc);
|
||||||
|
REQUEST_FIELD_CARD16(totalWidth);
|
||||||
|
REQUEST_FIELD_CARD16(totalHeight);
|
||||||
|
REQUEST_FIELD_CARD16(srcX);
|
||||||
|
REQUEST_FIELD_CARD16(srcY);
|
||||||
|
REQUEST_FIELD_CARD16(srcWidth);
|
||||||
|
REQUEST_FIELD_CARD16(srcHeight);
|
||||||
|
REQUEST_FIELD_CARD16(dstX);
|
||||||
|
REQUEST_FIELD_CARD16(dstY);
|
||||||
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
REQUEST_FIELD_CARD32(offset);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -764,8 +777,15 @@ ProcShmPutImage(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcShmGetImage(ClientPtr client)
|
ProcShmGetImage(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmGetImageReq);
|
REQUEST_HEAD_STRUCT(xShmGetImageReq);
|
||||||
REQUEST_SIZE_MATCH(xShmGetImageReq);
|
REQUEST_FIELD_CARD32(drawable);
|
||||||
|
REQUEST_FIELD_CARD16(x);
|
||||||
|
REQUEST_FIELD_CARD16(y);
|
||||||
|
REQUEST_FIELD_CARD16(width);
|
||||||
|
REQUEST_FIELD_CARD16(height);
|
||||||
|
REQUEST_FIELD_CARD32(planeMask);
|
||||||
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
REQUEST_FIELD_CARD32(offset);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -913,8 +933,13 @@ ProcShmGetImage(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcShmCreatePixmap(ClientPtr client)
|
ProcShmCreatePixmap(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmCreatePixmapReq);
|
REQUEST_HEAD_STRUCT(xShmCreatePixmapReq);
|
||||||
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
|
REQUEST_FIELD_CARD32(pid);
|
||||||
|
REQUEST_FIELD_CARD32(drawable);
|
||||||
|
REQUEST_FIELD_CARD16(width);
|
||||||
|
REQUEST_FIELD_CARD16(height);
|
||||||
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
REQUEST_FIELD_CARD32(offset);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -1146,8 +1171,8 @@ ShmBusfaultNotify(void *context)
|
||||||
static int
|
static int
|
||||||
ProcShmAttachFd(ClientPtr client)
|
ProcShmAttachFd(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmAttachFdReq);
|
REQUEST_HEAD_STRUCT(xShmAttachFdReq);
|
||||||
REQUEST_SIZE_MATCH(xShmAttachFdReq);
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -1266,8 +1291,9 @@ shm_tmpfile(void)
|
||||||
static int
|
static int
|
||||||
ProcShmCreateSegment(ClientPtr client)
|
ProcShmCreateSegment(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xShmCreateSegmentReq);
|
REQUEST_HEAD_STRUCT(xShmCreateSegmentReq);
|
||||||
REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
|
REQUEST_FIELD_CARD32(shmseg);
|
||||||
|
REQUEST_FIELD_CARD32(size);
|
||||||
|
|
||||||
if (!client->local)
|
if (!client->local)
|
||||||
return BadRequest;
|
return BadRequest;
|
||||||
|
@ -1381,128 +1407,6 @@ SShmCompletionEvent(xShmCompletionEvent * from, xShmCompletionEvent * to)
|
||||||
cpswapl(from->offset, to->offset);
|
cpswapl(from->offset, to->offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmAttach(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmAttachReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmAttachReq);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
swapl(&stuff->shmid);
|
|
||||||
return ProcShmAttach(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmDetach(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmDetachReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmDetachReq);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
return ProcShmDetach(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmPutImage(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmPutImageReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmPutImageReq);
|
|
||||||
swapl(&stuff->drawable);
|
|
||||||
swapl(&stuff->gc);
|
|
||||||
swaps(&stuff->totalWidth);
|
|
||||||
swaps(&stuff->totalHeight);
|
|
||||||
swaps(&stuff->srcX);
|
|
||||||
swaps(&stuff->srcY);
|
|
||||||
swaps(&stuff->srcWidth);
|
|
||||||
swaps(&stuff->srcHeight);
|
|
||||||
swaps(&stuff->dstX);
|
|
||||||
swaps(&stuff->dstY);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
swapl(&stuff->offset);
|
|
||||||
return ProcShmPutImage(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmGetImage(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmGetImageReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmGetImageReq);
|
|
||||||
swapl(&stuff->drawable);
|
|
||||||
swaps(&stuff->x);
|
|
||||||
swaps(&stuff->y);
|
|
||||||
swaps(&stuff->width);
|
|
||||||
swaps(&stuff->height);
|
|
||||||
swapl(&stuff->planeMask);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
swapl(&stuff->offset);
|
|
||||||
return ProcShmGetImage(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmCreatePixmap(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmCreatePixmapReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmCreatePixmapReq);
|
|
||||||
swapl(&stuff->pid);
|
|
||||||
swapl(&stuff->drawable);
|
|
||||||
swaps(&stuff->width);
|
|
||||||
swaps(&stuff->height);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
swapl(&stuff->offset);
|
|
||||||
return ProcShmCreatePixmap(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SHM_FD_PASSING
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmAttachFd(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmAttachFdReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmAttachFdReq);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
return ProcShmAttachFd(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmCreateSegment(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xShmCreateSegmentReq);
|
|
||||||
REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
|
|
||||||
swapl(&stuff->shmseg);
|
|
||||||
swapl(&stuff->size);
|
|
||||||
return ProcShmCreateSegment(client);
|
|
||||||
}
|
|
||||||
#endif /* SHM_FD_PASSING */
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcShmDispatch(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xReq);
|
|
||||||
|
|
||||||
if (!client->local)
|
|
||||||
return BadRequest;
|
|
||||||
|
|
||||||
switch (stuff->data) {
|
|
||||||
case X_ShmQueryVersion:
|
|
||||||
return ProcShmQueryVersion(client);
|
|
||||||
case X_ShmAttach:
|
|
||||||
return SProcShmAttach(client);
|
|
||||||
case X_ShmDetach:
|
|
||||||
return SProcShmDetach(client);
|
|
||||||
case X_ShmPutImage:
|
|
||||||
return SProcShmPutImage(client);
|
|
||||||
case X_ShmGetImage:
|
|
||||||
return SProcShmGetImage(client);
|
|
||||||
case X_ShmCreatePixmap:
|
|
||||||
return SProcShmCreatePixmap(client);
|
|
||||||
#ifdef SHM_FD_PASSING
|
|
||||||
case X_ShmAttachFd:
|
|
||||||
return SProcShmAttachFd(client);
|
|
||||||
case X_ShmCreateSegment:
|
|
||||||
return SProcShmCreateSegment(client);
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return BadRequest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ShmPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
|
static void ShmPixmapDestroy(CallbackListPtr *pcbl, ScreenPtr pScreen, PixmapPtr pPixmap)
|
||||||
{
|
{
|
||||||
ShmDetachSegment(
|
ShmDetachSegment(
|
||||||
|
@ -1547,7 +1451,7 @@ ShmExtensionInit(void)
|
||||||
ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
|
ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
|
||||||
if (ShmSegType &&
|
if (ShmSegType &&
|
||||||
(extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
|
(extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
|
||||||
ProcShmDispatch, SProcShmDispatch,
|
ProcShmDispatch, ProcShmDispatch,
|
||||||
ShmResetProc, StandardMinorOpcode))) {
|
ShmResetProc, StandardMinorOpcode))) {
|
||||||
ShmReqCode = (unsigned char) extEntry->base;
|
ShmReqCode = (unsigned char) extEntry->base;
|
||||||
ShmCompletionCode = extEntry->eventBase;
|
ShmCompletionCode = extEntry->eventBase;
|
||||||
|
|
Loading…
Reference in New Issue