[PATCH 07/18] xfree86: switch to byte counting functions
Peter Hutterer
peter.hutterer at who-t.net
Wed Jul 8 17:05:05 PDT 2009
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
hw/xfree86/common/xf86DGA.c | 2 +-
hw/xfree86/dixmods/extmod/xf86dga2.c | 8 +++---
hw/xfree86/dixmods/extmod/xf86vmode.c | 42 ++++++++++++++++----------------
hw/xfree86/dri/xf86dri.c | 14 +++++-----
hw/xfree86/modes/xf86Modes.c | 2 +-
hw/xfree86/os-support/linux/lnx_font.c | 2 +-
hw/xfree86/xaa/xaaFillRect.c | 2 +-
hw/xfree86/xaa/xaaImage.c | 6 ++--
hw/xfree86/xaa/xaaPCache.c | 2 +-
9 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index f83bcd5..6ea3012 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -1178,7 +1178,7 @@ DGAGetOldDGAMode(int index)
w = pScrn->currentMode->HDisplay;
h = pScrn->currentMode->VDisplay;
- p = ((pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)) + 3) & ~3L;
+ p = pad_to_dwords(pScrn->displayWidth * num_bytes_for_bits(pScrn->bitsPerPixel));
for(i = 0; i < pScreenPriv->numModes; i++) {
mode = &(pScreenPriv->modes[i]);
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 46aa8b8..2ba93fd 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -159,7 +159,7 @@ ProcXDGAOpenFramebuffer(ClientPtr client)
}
nameSize = deviceName ? (strlen(deviceName) + 1) : 0;
- rep.length = (nameSize + 3) >> 2;
+ rep.length = num_dwords_for_bytes(nameSize);
WriteToClient(client, sizeof(xXDGAOpenFramebufferReply), (char *)&rep);
if(rep.length)
@@ -225,10 +225,10 @@ ProcXDGAQueryModes(ClientPtr client)
size = num * sz_xXDGAModeInfo;
for(i = 0; i < num; i++)
- size += (strlen(mode[i].name) + 4) & ~3L; /* plus NULL */
+ size += pad_to_dwords(strlen(mode[i].name) + 1); /* plus NULL */
rep.number = num;
- rep.length = size >> 2;
+ rep.length = num_dwords_for_bytes(size);
WriteToClient(client, sz_xXDGAQueryModesReply, (char*)&rep);
@@ -389,7 +389,7 @@ ProcXDGASetMode(ClientPtr client)
info.reserved1 = mode.reserved1;
info.reserved2 = mode.reserved2;
- rep.length = (sz_xXDGAModeInfo + info.name_size) >> 2;
+ rep.length = num_dwords_for_bytes(sz_xXDGAModeInfo + info.name_size);
WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep);
WriteToClient(client, sz_xXDGAModeInfo, (char*)(&info));
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index bd6c594..27c39ed 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -414,11 +414,11 @@ ProcXF86VidModeGetModeLine(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq);
rep.type = X_Reply;
if (ver < 2) {
- rep.length = (SIZEOF(xXF86OldVidModeGetModeLineReply) -
- SIZEOF(xGenericReply)) >> 2;
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86OldVidModeGetModeLineReply) -
+ SIZEOF(xGenericReply));
} else {
- rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) -
- SIZEOF(xGenericReply)) >> 2;
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86VidModeGetModeLineReply) -
+ SIZEOF(xGenericReply));
}
rep.sequenceNumber = client->sequence;
@@ -670,10 +670,10 @@ ProcXF86VidModeAddModeLine(ClientPtr client)
if (ver < 2) {
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
- len = client->req_len - (sizeof(xXF86OldVidModeAddModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86OldVidModeAddModeLineReq));
} else {
REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86VidModeAddModeLineReq));
}
if (len != stuff->privsize)
return BadLength;
@@ -809,10 +809,10 @@ ProcXF86VidModeDeleteModeLine(ClientPtr client)
if (ver < 2) {
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
- len = client->req_len - (sizeof(xXF86OldVidModeDeleteModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86OldVidModeDeleteModeLineReq));
} else {
REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86VidModeDeleteModeLineReq));
}
if (len != stuff->privsize) {
if (xf86GetVerbosity() > DEFAULT_XF86VIDMODE_VERBOSITY) {
@@ -923,10 +923,10 @@ ProcXF86VidModeModModeLine(ClientPtr client)
if (ver < 2) {
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
- len = client->req_len - (sizeof(xXF86OldVidModeModModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86OldVidModeModModeLineReq));
} else {
REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86VidModeModModeLineReq));
}
if (len != stuff->privsize)
return BadLength;
@@ -1052,10 +1052,10 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
if (ver < 2) {
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
len = client->req_len -
- (sizeof(xXF86OldVidModeValidateModeLineReq) >> 2);
+ num_dwords_for_bytes(sizeof(xXF86OldVidModeValidateModeLineReq));
} else {
REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
- len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86VidModeValidateModeLineReq));
}
if (len != stuff->privsize)
return BadLength;
@@ -1107,8 +1107,8 @@ status_reply:
xfree(modetmp);
rep.type = X_Reply;
- rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply)
- - SIZEOF(xGenericReply)) >> 2;
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86VidModeValidateModeLineReply)
+ - SIZEOF(xGenericReply));
rep.sequenceNumber = client->sequence;
rep.status = status;
if (client->swapped) {
@@ -1185,10 +1185,10 @@ ProcXF86VidModeSwitchToMode(ClientPtr client)
if (ver < 2) {
REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
- len = client->req_len - (sizeof(xXF86OldVidModeSwitchToModeReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86OldVidModeSwitchToModeReq));
} else {
REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
- len = client->req_len - (sizeof(xXF86VidModeSwitchToModeReq) >> 2);
+ len = client->req_len - num_dwords_for_bytes(sizeof(xXF86VidModeSwitchToModeReq));
}
if (len != stuff->privsize)
return BadLength;
@@ -1289,10 +1289,10 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
VIDMODE_MON_MODEL, 0)).ptr);
else
rep.modelLength = 0;
- rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) +
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) +
(nHsync + nVrefresh) * sizeof(CARD32) +
- ((rep.vendorLength + 3) & ~3) +
- ((rep.modelLength + 3) & ~3)) >> 2;
+ pad_to_dwords(rep.vendorLength) +
+ pad_to_dwords(rep.modelLength));
rep.sequenceNumber = client->sequence;
rep.nhsync = nHsync;
rep.nvsync = nVrefresh;
@@ -1413,8 +1413,8 @@ ProcXF86VidModeGetDotClocks(ClientPtr client)
numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg);
rep.type = X_Reply;
- rep.length = (SIZEOF(xXF86VidModeGetDotClocksReply)
- - SIZEOF(xGenericReply) + numClocks) >> 2;
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86VidModeGetDotClocksReply)
+ - SIZEOF(xGenericReply) + numClocks);
rep.sequenceNumber = client->sequence;
rep.clocks = numClocks;
rep.maxclocks = MAXCLOCKS;
diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
index 902fe12..a1d4805 100644
--- a/hw/xfree86/dri/xf86dri.c
+++ b/hw/xfree86/dri/xf86dri.c
@@ -214,8 +214,8 @@ ProcXF86DRIOpenConnection(
rep.busIdStringLength = 0;
if (busIdString)
rep.busIdStringLength = strlen(busIdString);
- rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
- ((rep.busIdStringLength + 3) & ~3)) >> 2;
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
+ pad_to_dwords(rep.busIdStringLength));
rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
#if defined(LONG64) && !defined(__linux__)
@@ -300,9 +300,9 @@ ProcXF86DRIGetClientDriverName(
rep.clientDriverNameLength = 0;
if (clientDriverName)
rep.clientDriverNameLength = strlen(clientDriverName);
- rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) -
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86DRIGetClientDriverNameReply) -
SIZEOF(xGenericReply) +
- ((rep.clientDriverNameLength + 3) & ~3)) >> 2;
+ pad_to_dwords(rep.clientDriverNameLength));
WriteToClient(client,
sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
@@ -515,7 +515,7 @@ ProcXF86DRIGetDrawableInfo(
rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
}
- rep.length = ((rep.length + 3) & ~3) >> 2;
+ rep.length = num_dwords_for_bytes(rep.length);
WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
@@ -574,9 +574,9 @@ ProcXF86DRIGetDeviceInfo(
rep.length = 0;
if (rep.devPrivateSize) {
- rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) -
+ rep.length = num_dwords_for_bytes(SIZEOF(xXF86DRIGetDeviceInfoReply) -
SIZEOF(xGenericReply) +
- ((rep.devPrivateSize + 3) & ~3)) >> 2;
+ pad_to_dwords(rep.devPrivateSize));
}
WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 74d8648..2cec08a 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -123,7 +123,7 @@ unsigned int
xf86ModeBandwidth(DisplayModePtr mode, int depth)
{
float a_active, a_total, active_percent, pixels_per_second;
- int bytes_per_pixel = (depth + 7) / 8;
+ int bytes_per_pixel = num_bytes_for_bits(depth);
if (!mode->HTotal || !mode->VTotal || !mode->Clock)
return 0;
diff --git a/hw/xfree86/os-support/linux/lnx_font.c b/hw/xfree86/os-support/linux/lnx_font.c
index 5b2696a..e1ff259 100644
--- a/hw/xfree86/os-support/linux/lnx_font.c
+++ b/hw/xfree86/os-support/linux/lnx_font.c
@@ -168,7 +168,7 @@ lnx_savefont(void)
return FALSE;
}
- size = (width + 7)/8 * 32 * charcount;
+ size = num_bytes_for_bits(width) * 32 * charcount;
fontdata = (unsigned char *)xnfalloc(size);
if (!fontdata) {
xf86Msg(X_WARNING,
diff --git a/hw/xfree86/xaa/xaaFillRect.c b/hw/xfree86/xaa/xaaFillRect.c
index 7c319bb..686a9c6 100644
--- a/hw/xfree86/xaa/xaaFillRect.c
+++ b/hw/xfree86/xaa/xaaFillRect.c
@@ -812,7 +812,7 @@ WriteColumn(
src = pSrc + (yoff * srcwidth);
- dwords = ((w * Bpp) + 3) >> 2;
+ dwords = num_dwords_for_bytes(w * Bpp);
if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
((dwords * h) & 0x01)) {
diff --git a/hw/xfree86/xaa/xaaImage.c b/hw/xfree86/xaa/xaaImage.c
index 85461c8..ef22e17 100644
--- a/hw/xfree86/xaa/xaaImage.c
+++ b/hw/xfree86/xaa/xaaImage.c
@@ -92,7 +92,7 @@ XAAWritePixmap32To24(
int trans
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int count, dwords = ((w * 3) + 3) >> 2;
+ int count, dwords = num_dwords_for_bytes(w * 3);
CARD32 *src, *dst;
Bool PlusOne = FALSE;
@@ -227,7 +227,7 @@ XAAWritePixmap (
BAD_ALIGNMENT:
- dwords = ((w * Bpp) + 3) >> 2;
+ dwords = num_dwords_for_bytes(w * Bpp);
if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
((dwords * h) & 0x01)) {
@@ -351,7 +351,7 @@ XAAWritePixmapScanline (
BAD_ALIGNMENT:
- dwords = ((w * Bpp) + 3) >> 2;
+ dwords = num_dwords_for_bytes(w * Bpp);
(*infoRec->SetupForScanlineImageWrite)(
pScrn, rop, planemask, trans, bpp, depth);
diff --git a/hw/xfree86/xaa/xaaPCache.c b/hw/xfree86/xaa/xaaPCache.c
index dbbeac6..b782f26 100644
--- a/hw/xfree86/xaa/xaaPCache.c
+++ b/hw/xfree86/xaa/xaaPCache.c
@@ -1556,7 +1556,7 @@ XAACacheMonoStipple(ScrnInfoPtr pScrn, PixmapPtr pPix)
} else funcNo = 2;
pad = BitmapBytePad(pCache->w * bpp);
- dwords = pad >> 2;
+ dwords = num_dwords_for_bytes(pad);
dstPtr = data = (unsigned char*)xalloc(pad * pCache->h);
srcPtr = (unsigned char*)pPix->devPrivate.ptr;
--
1.6.3.rc1.2.g0164.dirty
More information about the xorg-devel
mailing list