diff --git a/Xext/shm.c b/Xext/shm.c index 7dcc772ed..564278fe7 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group. #include #include "dix/dix_priv.h" +#include "dix/request_priv.h" #include "dix/screen_hooks_priv.h" #include "os/auth.h" #include "os/busfault.h" @@ -251,6 +252,8 @@ ShmRegisterFbFuncs(ScreenPtr pScreen) static int ProcShmQueryVersion(ClientPtr client) { + REQUEST_HEAD_STRUCT(xShmQueryVersionReq); + xShmQueryVersionReply rep = { .type = X_Reply, .sharedPixmaps = sharedPixmaps, @@ -263,8 +266,6 @@ ProcShmQueryVersion(ClientPtr client) .pixmapFormat = sharedPixmaps ? ZPixmap : 0 }; - REQUEST_SIZE_MATCH(xShmQueryVersionReq); - if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -346,8 +347,9 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly) static int ProcShmAttach(ClientPtr client) { - REQUEST(xShmAttachReq); - REQUEST_SIZE_MATCH(xShmAttachReq); + REQUEST_HEAD_STRUCT(xShmAttachReq); + REQUEST_FIELD_CARD32(shmseg); + REQUEST_FIELD_CARD32(shmid); if (!client->local) return BadRequest; @@ -434,8 +436,8 @@ ShmDetachSegment(void *value, /* must conform to DeleteType */ static int ProcShmDetach(ClientPtr client) { - REQUEST(xShmDetachReq); - REQUEST_SIZE_MATCH(xShmDetachReq); + REQUEST_HEAD_STRUCT(xShmDetachReq); + REQUEST_FIELD_CARD32(shmseg); if (!client->local) return BadRequest; @@ -712,8 +714,19 @@ ShmGetImage(ClientPtr client, xShmGetImageReq *stuff) static int ProcShmPutImage(ClientPtr client) { - REQUEST(xShmPutImageReq); - REQUEST_SIZE_MATCH(xShmPutImageReq); + REQUEST_HEAD_STRUCT(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) return BadRequest; @@ -764,8 +777,15 @@ ProcShmPutImage(ClientPtr client) static int ProcShmGetImage(ClientPtr client) { - REQUEST(xShmGetImageReq); - REQUEST_SIZE_MATCH(xShmGetImageReq); + REQUEST_HEAD_STRUCT(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) return BadRequest; @@ -913,8 +933,13 @@ ProcShmGetImage(ClientPtr client) static int ProcShmCreatePixmap(ClientPtr client) { - REQUEST(xShmCreatePixmapReq); - REQUEST_SIZE_MATCH(xShmCreatePixmapReq); + REQUEST_HEAD_STRUCT(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) return BadRequest; @@ -1146,8 +1171,8 @@ ShmBusfaultNotify(void *context) static int ProcShmAttachFd(ClientPtr client) { - REQUEST(xShmAttachFdReq); - REQUEST_SIZE_MATCH(xShmAttachFdReq); + REQUEST_HEAD_STRUCT(xShmAttachFdReq); + REQUEST_FIELD_CARD32(shmseg); if (!client->local) return BadRequest; @@ -1266,8 +1291,9 @@ shm_tmpfile(void) static int ProcShmCreateSegment(ClientPtr client) { - REQUEST(xShmCreateSegmentReq); - REQUEST_SIZE_MATCH(xShmCreateSegmentReq); + REQUEST_HEAD_STRUCT(xShmCreateSegmentReq); + REQUEST_FIELD_CARD32(shmseg); + REQUEST_FIELD_CARD32(size); if (!client->local) return BadRequest; @@ -1381,128 +1407,6 @@ SShmCompletionEvent(xShmCompletionEvent * from, xShmCompletionEvent * to) 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) { ShmDetachSegment( @@ -1547,7 +1451,7 @@ ShmExtensionInit(void) ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg"); if (ShmSegType && (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, - ProcShmDispatch, SProcShmDispatch, + ProcShmDispatch, ProcShmDispatch, ShmResetProc, StandardMinorOpcode))) { ShmReqCode = (unsigned char) extEntry->base; ShmCompletionCode = extEntry->eventBase;