From 0f834b91a4768673833ab4917e87d86c237bb1a6 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 23 Mar 2012 10:05:55 +0100 Subject: libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update 23 Mar 2012 --- xorg-server/Xext/xf86bigfont.c | 739 +++++++++++++++++++++-------------------- 1 file changed, 371 insertions(+), 368 deletions(-) (limited to 'xorg-server/Xext/xf86bigfont.c') diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c index 4b63a13a1..9de785678 100644 --- a/xorg-server/Xext/xf86bigfont.c +++ b/xorg-server/Xext/xf86bigfont.c @@ -50,7 +50,7 @@ #ifdef SVR4 #include #endif -#if defined(__CYGWIN__) +#if defined(__CYGWIN__) #include #include #endif @@ -76,11 +76,9 @@ #include #include "xf86bigfontsrv.h" -static void XF86BigfontResetProc( - ExtensionEntry * /* extEntry */ +static void XF86BigfontResetProc(ExtensionEntry * /* extEntry */ ); - #ifdef HAS_SHM /* A random signature, transmitted to the clients so they can verify that the @@ -100,8 +98,7 @@ static Bool badSysCall = FALSE; #include static void -SigSysHandler( - int signo) +SigSysHandler(int signo) { badSysCall = TRUE; } @@ -109,7 +106,7 @@ SigSysHandler( static Bool CheckForShmSyscall(void) { - void (*oldHandler)(int); + void (*oldHandler) (int); int shmid = -1; /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ @@ -117,13 +114,11 @@ CheckForShmSyscall(void) badSysCall = FALSE; shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); - if (shmid != -1) - { + if (shmid != -1) { /* Successful allocation - clean up */ - shmctl(shmid, IPC_RMID, NULL); + shmctl(shmid, IPC_RMID, NULL); } - else - { + else { /* Allocation failed */ badSysCall = TRUE; } @@ -158,8 +153,7 @@ typedef struct _ShmDesc { static ShmDescPtr ShmList = (ShmDescPtr) NULL; static ShmDescPtr -shmalloc( - unsigned int size) +shmalloc(unsigned int size) { ShmDescPtr pDesc; int shmid; @@ -167,7 +161,7 @@ shmalloc( #ifdef MUST_CHECK_FOR_SHM_SYSCALL if (pagesize == 0) - return (ShmDescPtr) NULL; + return (ShmDescPtr) NULL; #endif /* On some older Linux systems, the number of shared memory segments @@ -177,27 +171,27 @@ shmalloc( the glyph metrics on the other hand. If the glyph metrics size is small, we prefer the traditional way. */ if (size < 3500) - return (ShmDescPtr) NULL; + return (ShmDescPtr) NULL; pDesc = malloc(sizeof(ShmDescRec)); if (!pDesc) - return (ShmDescPtr) NULL; + return (ShmDescPtr) NULL; - size = (size + pagesize-1) & -pagesize; + size = (size + pagesize - 1) & -pagesize; shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); if (shmid == -1) { - ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, %s\n", - size, strerror(errno)); - free(pDesc); - return (ShmDescPtr) NULL; + ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, %s\n", + size, strerror(errno)); + free(pDesc); + return (ShmDescPtr) NULL; } - if ((addr = shmat(shmid, 0, 0)) == (char *)-1) { - ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, %s\n", - size, strerror(errno)); - shmctl(shmid, IPC_RMID, (void *) 0); - free(pDesc); - return (ShmDescPtr) NULL; + if ((addr = shmat(shmid, 0, 0)) == (char *) -1) { + ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, %s\n", + size, strerror(errno)); + shmctl(shmid, IPC_RMID, (void *) 0); + free(pDesc); + return (ShmDescPtr) NULL; } #ifdef EARLY_REMOVE @@ -206,7 +200,8 @@ shmalloc( pDesc->shmid = shmid; pDesc->attach_addr = addr; - if (ShmList) ShmList->prev = &pDesc->next; + if (ShmList) + ShmList->prev = &pDesc->next; pDesc->next = ShmList; pDesc->prev = &ShmList; ShmList = pDesc; @@ -215,15 +210,15 @@ shmalloc( } static void -shmdealloc( - ShmDescPtr pDesc) +shmdealloc(ShmDescPtr pDesc) { #ifndef EARLY_REMOVE shmctl(pDesc->shmid, IPC_RMID, (void *) 0); #endif shmdt(pDesc->attach_addr); - if (pDesc->next) pDesc->next->prev = pDesc->prev; + if (pDesc->next) + pDesc->next->prev = pDesc->prev; *pDesc->prev = pDesc->next; free(pDesc); } @@ -232,8 +227,7 @@ shmdealloc( /* Called when a font is closed. */ void -XF86BigfontFreeFontShm( - FontPtr pFont) +XF86BigfontFreeFontShm(FontPtr pFont) { #ifdef HAS_SHM ShmDescPtr pDesc; @@ -242,11 +236,11 @@ XF86BigfontFreeFontShm( * called shmdealloc() for all segments, we don't need to do it here. */ if (!ShmList) - return; + return; pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex); if (pDesc) - shmdealloc(pDesc); + shmdealloc(pDesc); #endif } @@ -256,14 +250,13 @@ XF86BigfontCleanup(void) { #ifdef HAS_SHM while (ShmList) - shmdealloc(ShmList); + shmdealloc(ShmList); #endif } /* Called when a server generation dies. */ static void -XF86BigfontResetProc( - ExtensionEntry* extEntry) +XF86BigfontResetProc(ExtensionEntry * extEntry) { /* This function is normally called from CloseDownExtensions(), called * from main(). It will be followed by a call to FreeAllResources(), @@ -276,12 +269,10 @@ XF86BigfontResetProc( XF86BigfontCleanup(); } - /* ========== Handling of extension specific requests ========== */ static int -ProcXF86BigfontQueryVersion( - ClientPtr client) +ProcXF86BigfontQueryVersion(ClientPtr client) { xXF86BigfontQueryVersionReply reply; @@ -296,33 +287,33 @@ ProcXF86BigfontQueryVersion( #ifdef HAS_SHM reply.signature = signature; #else - reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */ + reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */ #endif reply.capabilities = #ifdef HAS_SHM - (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0) + (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0) #else - 0 + 0 #endif - ; /* may add more bits here in future versions */ + ; /* may add more bits here in future versions */ if (client->swapped) { - char tmp; - swaps(&reply.sequenceNumber); - swapl(&reply.length); - swaps(&reply.majorVersion); - swaps(&reply.minorVersion); - swapl(&reply.uid); - swapl(&reply.gid); - swapl(&reply.signature); + char tmp; + + swaps(&reply.sequenceNumber); + swapl(&reply.length); + swaps(&reply.majorVersion); + swaps(&reply.minorVersion); + swapl(&reply.uid); + swapl(&reply.gid); + swapl(&reply.signature); } WriteToClient(client, - sizeof(xXF86BigfontQueryVersionReply), (char *)&reply); + sizeof(xXF86BigfontQueryVersionReply), (char *) &reply); return Success; } static void -swapCharInfo( - xCharInfo *pCI) +swapCharInfo(xCharInfo * pCI) { char tmp; @@ -342,52 +333,55 @@ swapCharInfo( (p->ascent << 11) + (p->descent << 6)) ^ p->attributes) static int -ProcXF86BigfontQueryFont( - ClientPtr client) +ProcXF86BigfontQueryFont(ClientPtr client) { FontPtr pFont; + REQUEST(xXF86BigfontQueryFontReq); CARD32 stuff_flags; - xCharInfo* pmax; - xCharInfo* pmin; + xCharInfo *pmax; + xCharInfo *pmin; int nCharInfos; int shmid; + #ifdef HAS_SHM ShmDescPtr pDesc = NULL; #else #define pDesc 0 #endif - xCharInfo* pCI; - CARD16* pIndex2UniqIndex; - CARD16* pUniqIndex2Index; + xCharInfo *pCI; + CARD16 *pIndex2UniqIndex; + CARD16 *pUniqIndex2Index; CARD32 nUniqCharInfos; #if 0 REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq); #else switch (client->req_len) { - case 2: /* client with version 1.0 libX11 */ - stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0); - break; - case 3: /* client with version 1.1 libX11 */ - stuff_flags = stuff->flags; - break; - default: - return BadLength; + case 2: /* client with version 1.0 libX11 */ + stuff_flags = (LocalClient(client) && + !client->swapped ? XF86Bigfont_FLAGS_Shm : 0); + break; + case 3: /* client with version 1.1 libX11 */ + stuff_flags = stuff->flags; + break; + default: + return BadLength; } #endif - if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success) - return BadFont; /* procotol spec says only error is BadFont */ + if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != + Success) + return BadFont; /* procotol spec says only error is BadFont */ pmax = FONTINKMAX(pFont); pmin = FONTINKMIN(pFont); nCharInfos = - (pmax->rightSideBearing == pmin->rightSideBearing - && pmax->leftSideBearing == pmin->leftSideBearing - && pmax->descent == pmin->descent - && pmax->ascent == pmin->ascent - && pmax->characterWidth == pmin->characterWidth) - ? 0 : N2dChars(pFont); + (pmax->rightSideBearing == pmin->rightSideBearing + && pmax->leftSideBearing == pmin->leftSideBearing + && pmax->descent == pmin->descent + && pmax->ascent == pmin->ascent + && pmax->characterWidth == pmin->characterWidth) + ? 0 : N2dChars(pFont); shmid = -1; pCI = NULL; pIndex2UniqIndex = NULL; @@ -396,278 +390,289 @@ ProcXF86BigfontQueryFont( if (nCharInfos > 0) { #ifdef HAS_SHM - if (!badSysCall) - pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex); - if (pDesc) { - pCI = (xCharInfo *) pDesc->attach_addr; - if (stuff_flags & XF86Bigfont_FLAGS_Shm) - shmid = pDesc->shmid; - } else { - if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall) - pDesc = shmalloc(nCharInfos * sizeof(xCharInfo) - + sizeof(CARD32)); - if (pDesc) { - pCI = (xCharInfo *) pDesc->attach_addr; - shmid = pDesc->shmid; - } else { + if (!badSysCall) + pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex); + if (pDesc) { + pCI = (xCharInfo *) pDesc->attach_addr; + if (stuff_flags & XF86Bigfont_FLAGS_Shm) + shmid = pDesc->shmid; + } + else { + if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall) + pDesc = shmalloc(nCharInfos * sizeof(xCharInfo) + + sizeof(CARD32)); + if (pDesc) { + pCI = (xCharInfo *) pDesc->attach_addr; + shmid = pDesc->shmid; + } + else { #endif - pCI = malloc(nCharInfos * sizeof(xCharInfo)); - if (!pCI) - return BadAlloc; + pCI = malloc(nCharInfos * sizeof(xCharInfo)); + if (!pCI) + return BadAlloc; #ifdef HAS_SHM - } + } #endif - /* Fill nCharInfos starting at pCI. */ - { - xCharInfo* prCI = pCI; - int ninfos = 0; - int ncols = pFont->info.lastCol - pFont->info.firstCol + 1; - int row; - for (row = pFont->info.firstRow; - row <= pFont->info.lastRow && ninfos < nCharInfos; - row++) { - unsigned char chars[512]; - xCharInfo* tmpCharInfos[256]; - unsigned long count; - int col; - unsigned long i; - i = 0; - for (col = pFont->info.firstCol; - col <= pFont->info.lastCol; - col++) { - chars[i++] = row; - chars[i++] = col; - } - (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit, - &count, tmpCharInfos); - for (i = 0; i < count && ninfos < nCharInfos; i++) { - *prCI++ = *tmpCharInfos[i]; - ninfos++; - } - } - } + /* Fill nCharInfos starting at pCI. */ + { + xCharInfo *prCI = pCI; + int ninfos = 0; + int ncols = pFont->info.lastCol - pFont->info.firstCol + 1; + int row; + + for (row = pFont->info.firstRow; + row <= pFont->info.lastRow && ninfos < nCharInfos; row++) { + unsigned char chars[512]; + xCharInfo *tmpCharInfos[256]; + unsigned long count; + int col; + unsigned long i; + + i = 0; + for (col = pFont->info.firstCol; + col <= pFont->info.lastCol; col++) { + chars[i++] = row; + chars[i++] = col; + } + (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit, + &count, tmpCharInfos); + for (i = 0; i < count && ninfos < nCharInfos; i++) { + *prCI++ = *tmpCharInfos[i]; + ninfos++; + } + } + } #ifdef HAS_SHM - if (pDesc && !badSysCall) { - *(CARD32 *)(pCI + nCharInfos) = signature; - if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) { - shmdealloc(pDesc); - return BadAlloc; - } - } - } + if (pDesc && !badSysCall) { + *(CARD32 *) (pCI + nCharInfos) = signature; + if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) { + shmdealloc(pDesc); + return BadAlloc; + } + } + } #endif - if (shmid == -1) { - /* Cannot use shared memory, so remove-duplicates the xCharInfos - using a temporary hash table. */ - /* Note that CARD16 is suitable as index type, because - nCharInfos <= 0x10000. */ - CARD32 hashModulus; - CARD16* pHash2UniqIndex; - CARD16* pUniqIndex2NextUniqIndex; - CARD32 NextIndex; - CARD32 NextUniqIndex; - CARD16* tmp; - CARD32 i, j; - - hashModulus = 67; - if (hashModulus > nCharInfos+1) - hashModulus = nCharInfos+1; - - tmp = malloc((4*nCharInfos+1) * sizeof(CARD16)); - if (!tmp) { - if (!pDesc) free(pCI); - return BadAlloc; - } - pIndex2UniqIndex = tmp; - /* nCharInfos elements */ - pUniqIndex2Index = tmp + nCharInfos; - /* max. nCharInfos elements */ - pUniqIndex2NextUniqIndex = tmp + 2*nCharInfos; - /* max. nCharInfos elements */ - pHash2UniqIndex = tmp + 3*nCharInfos; - /* hashModulus (<= nCharInfos+1) elements */ - - /* Note that we can use 0xffff as end-of-list indicator, because - even if nCharInfos = 0x10000, 0xffff can not occur as valid - entry before the last element has been inserted. And once the - last element has been inserted, we don't need the hash table - any more. */ - for (j = 0; j < hashModulus; j++) - pHash2UniqIndex[j] = (CARD16)(-1); - - NextUniqIndex = 0; - for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) { - xCharInfo* p = &pCI[NextIndex]; - CARD32 hashCode = hashCI(p) % hashModulus; - for (i = pHash2UniqIndex[hashCode]; - i != (CARD16)(-1); - i = pUniqIndex2NextUniqIndex[i]) { - j = pUniqIndex2Index[i]; - if (pCI[j].leftSideBearing == p->leftSideBearing - && pCI[j].rightSideBearing == p->rightSideBearing - && pCI[j].characterWidth == p->characterWidth - && pCI[j].ascent == p->ascent - && pCI[j].descent == p->descent - && pCI[j].attributes == p->attributes) - break; - } - if (i != (CARD16)(-1)) { - /* Found *p at Index j, UniqIndex i */ - pIndex2UniqIndex[NextIndex] = i; - } else { - /* Allocate a new entry in the Uniq table */ - if (hashModulus <= 2*NextUniqIndex - && hashModulus < nCharInfos+1) { - /* Time to increate hash table size */ - hashModulus = 2*hashModulus+1; - if (hashModulus > nCharInfos+1) - hashModulus = nCharInfos+1; - for (j = 0; j < hashModulus; j++) - pHash2UniqIndex[j] = (CARD16)(-1); - for (i = 0; i < NextUniqIndex; i++) - pUniqIndex2NextUniqIndex[i] = (CARD16)(-1); - for (i = 0; i < NextUniqIndex; i++) { - j = pUniqIndex2Index[i]; - p = &pCI[j]; - hashCode = hashCI(p) % hashModulus; - pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode]; - pHash2UniqIndex[hashCode] = i; - } - p = &pCI[NextIndex]; - hashCode = hashCI(p) % hashModulus; - } - i = NextUniqIndex++; - pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode]; - pHash2UniqIndex[hashCode] = i; - pUniqIndex2Index[i] = NextIndex; - pIndex2UniqIndex[NextIndex] = i; - } - } - nUniqCharInfos = NextUniqIndex; - /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */ - } + if (shmid == -1) { + /* Cannot use shared memory, so remove-duplicates the xCharInfos + using a temporary hash table. */ + /* Note that CARD16 is suitable as index type, because + nCharInfos <= 0x10000. */ + CARD32 hashModulus; + CARD16 *pHash2UniqIndex; + CARD16 *pUniqIndex2NextUniqIndex; + CARD32 NextIndex; + CARD32 NextUniqIndex; + CARD16 *tmp; + CARD32 i, j; + + hashModulus = 67; + if (hashModulus > nCharInfos + 1) + hashModulus = nCharInfos + 1; + + tmp = malloc((4 * nCharInfos + 1) * sizeof(CARD16)); + if (!tmp) { + if (!pDesc) + free(pCI); + return BadAlloc; + } + pIndex2UniqIndex = tmp; + /* nCharInfos elements */ + pUniqIndex2Index = tmp + nCharInfos; + /* max. nCharInfos elements */ + pUniqIndex2NextUniqIndex = tmp + 2 * nCharInfos; + /* max. nCharInfos elements */ + pHash2UniqIndex = tmp + 3 * nCharInfos; + /* hashModulus (<= nCharInfos+1) elements */ + + /* Note that we can use 0xffff as end-of-list indicator, because + even if nCharInfos = 0x10000, 0xffff can not occur as valid + entry before the last element has been inserted. And once the + last element has been inserted, we don't need the hash table + any more. */ + for (j = 0; j < hashModulus; j++) + pHash2UniqIndex[j] = (CARD16) (-1); + + NextUniqIndex = 0; + for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) { + xCharInfo *p = &pCI[NextIndex]; + CARD32 hashCode = hashCI(p) % hashModulus; + + for (i = pHash2UniqIndex[hashCode]; + i != (CARD16) (-1); i = pUniqIndex2NextUniqIndex[i]) { + j = pUniqIndex2Index[i]; + if (pCI[j].leftSideBearing == p->leftSideBearing + && pCI[j].rightSideBearing == p->rightSideBearing + && pCI[j].characterWidth == p->characterWidth + && pCI[j].ascent == p->ascent + && pCI[j].descent == p->descent + && pCI[j].attributes == p->attributes) + break; + } + if (i != (CARD16) (-1)) { + /* Found *p at Index j, UniqIndex i */ + pIndex2UniqIndex[NextIndex] = i; + } + else { + /* Allocate a new entry in the Uniq table */ + if (hashModulus <= 2 * NextUniqIndex + && hashModulus < nCharInfos + 1) { + /* Time to increate hash table size */ + hashModulus = 2 * hashModulus + 1; + if (hashModulus > nCharInfos + 1) + hashModulus = nCharInfos + 1; + for (j = 0; j < hashModulus; j++) + pHash2UniqIndex[j] = (CARD16) (-1); + for (i = 0; i < NextUniqIndex; i++) + pUniqIndex2NextUniqIndex[i] = (CARD16) (-1); + for (i = 0; i < NextUniqIndex; i++) { + j = pUniqIndex2Index[i]; + p = &pCI[j]; + hashCode = hashCI(p) % hashModulus; + pUniqIndex2NextUniqIndex[i] = + pHash2UniqIndex[hashCode]; + pHash2UniqIndex[hashCode] = i; + } + p = &pCI[NextIndex]; + hashCode = hashCI(p) % hashModulus; + } + i = NextUniqIndex++; + pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode]; + pHash2UniqIndex[hashCode] = i; + pUniqIndex2Index[i] = NextIndex; + pIndex2UniqIndex[NextIndex] = i; + } + } + nUniqCharInfos = NextUniqIndex; + /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */ + } } { - int nfontprops = pFont->info.nprops; - int rlength = - sizeof(xXF86BigfontQueryFontReply) - + nfontprops * sizeof(xFontProp) - + (nCharInfos > 0 && shmid == -1 - ? nUniqCharInfos * sizeof(xCharInfo) - + (nCharInfos+1)/2 * 2 * sizeof(CARD16) - : 0); - xXF86BigfontQueryFontReply* reply = malloc(rlength); - char* p; - if (!reply) { - if (nCharInfos > 0) { - if (shmid == -1) free(pIndex2UniqIndex); - if (!pDesc) free(pCI); - } - return BadAlloc; - } - reply->type = X_Reply; - reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); - reply->sequenceNumber = client->sequence; - reply->minBounds = pFont->info.ink_minbounds; - reply->maxBounds = pFont->info.ink_maxbounds; - reply->minCharOrByte2 = pFont->info.firstCol; - reply->maxCharOrByte2 = pFont->info.lastCol; - reply->defaultChar = pFont->info.defaultCh; - reply->nFontProps = pFont->info.nprops; - reply->drawDirection = pFont->info.drawDirection; - reply->minByte1 = pFont->info.firstRow; - reply->maxByte1 = pFont->info.lastRow; - reply->allCharsExist = pFont->info.allExist; - reply->fontAscent = pFont->info.fontAscent; - reply->fontDescent = pFont->info.fontDescent; - reply->nCharInfos = nCharInfos; + int nfontprops = pFont->info.nprops; + int rlength = sizeof(xXF86BigfontQueryFontReply) + + nfontprops * sizeof(xFontProp) + + (nCharInfos > 0 && shmid == -1 + ? nUniqCharInfos * sizeof(xCharInfo) + + (nCharInfos + 1) / 2 * 2 * sizeof(CARD16) + : 0); + xXF86BigfontQueryFontReply *reply = malloc(rlength); + char *p; + + if (!reply) { + if (nCharInfos > 0) { + if (shmid == -1) + free(pIndex2UniqIndex); + if (!pDesc) + free(pCI); + } + return BadAlloc; + } + reply->type = X_Reply; + reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); + reply->sequenceNumber = client->sequence; + reply->minBounds = pFont->info.ink_minbounds; + reply->maxBounds = pFont->info.ink_maxbounds; + reply->minCharOrByte2 = pFont->info.firstCol; + reply->maxCharOrByte2 = pFont->info.lastCol; + reply->defaultChar = pFont->info.defaultCh; + reply->nFontProps = pFont->info.nprops; + reply->drawDirection = pFont->info.drawDirection; + reply->minByte1 = pFont->info.firstRow; + reply->maxByte1 = pFont->info.lastRow; + reply->allCharsExist = pFont->info.allExist; + reply->fontAscent = pFont->info.fontAscent; + reply->fontDescent = pFont->info.fontDescent; + reply->nCharInfos = nCharInfos; reply->nUniqCharInfos = nUniqCharInfos; - reply->shmid = shmid; - reply->shmsegoffset = 0; - if (client->swapped) { - char tmp; - swaps(&reply->sequenceNumber); - swapl(&reply->length); - swapCharInfo(&reply->minBounds); - swapCharInfo(&reply->maxBounds); - swaps(&reply->minCharOrByte2); - swaps(&reply->maxCharOrByte2); - swaps(&reply->defaultChar); - swaps(&reply->nFontProps); - swaps(&reply->fontAscent); - swaps(&reply->fontDescent); - swapl(&reply->nCharInfos); - swapl(&reply->nUniqCharInfos); - swapl(&reply->shmid); - swapl(&reply->shmsegoffset); - } - p = (char*) &reply[1]; - { - FontPropPtr pFP; - xFontProp* prFP; - int i; - for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p; - i < nfontprops; - i++, pFP++, prFP++) { - prFP->name = pFP->name; - prFP->value = pFP->value; - if (client->swapped) { - char tmp; - swapl(&prFP->name); - swapl(&prFP->value); - } - } - p = (char*) prFP; - } - if (nCharInfos > 0 && shmid == -1) { - xCharInfo* pci; - CARD16* ps; - int i, j; - pci = (xCharInfo*) p; - for (i = 0; i < nUniqCharInfos; i++, pci++) { - *pci = pCI[pUniqIndex2Index[i]]; - if (client->swapped) - swapCharInfo(pci); - } - ps = (CARD16*) pci; - for (j = 0; j < nCharInfos; j++, ps++) { - *ps = pIndex2UniqIndex[j]; - if (client->swapped) { - char tmp; - swaps(ps); - } - } - } - WriteToClient(client, rlength, (char *)reply); - free(reply); - if (nCharInfos > 0) { - if (shmid == -1) free(pIndex2UniqIndex); - if (!pDesc) free(pCI); - } - return Success; + reply->shmid = shmid; + reply->shmsegoffset = 0; + if (client->swapped) { + char tmp; + + swaps(&reply->sequenceNumber); + swapl(&reply->length); + swapCharInfo(&reply->minBounds); + swapCharInfo(&reply->maxBounds); + swaps(&reply->minCharOrByte2); + swaps(&reply->maxCharOrByte2); + swaps(&reply->defaultChar); + swaps(&reply->nFontProps); + swaps(&reply->fontAscent); + swaps(&reply->fontDescent); + swapl(&reply->nCharInfos); + swapl(&reply->nUniqCharInfos); + swapl(&reply->shmid); + swapl(&reply->shmsegoffset); + } + p = (char *) &reply[1]; + { + FontPropPtr pFP; + xFontProp *prFP; + int i; + + for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p; + i < nfontprops; i++, pFP++, prFP++) { + prFP->name = pFP->name; + prFP->value = pFP->value; + if (client->swapped) { + char tmp; + + swapl(&prFP->name); + swapl(&prFP->value); + } + } + p = (char *) prFP; + } + if (nCharInfos > 0 && shmid == -1) { + xCharInfo *pci; + CARD16 *ps; + int i, j; + + pci = (xCharInfo *) p; + for (i = 0; i < nUniqCharInfos; i++, pci++) { + *pci = pCI[pUniqIndex2Index[i]]; + if (client->swapped) + swapCharInfo(pci); + } + ps = (CARD16 *) pci; + for (j = 0; j < nCharInfos; j++, ps++) { + *ps = pIndex2UniqIndex[j]; + if (client->swapped) { + char tmp; + + swaps(ps); + } + } + } + WriteToClient(client, rlength, (char *) reply); + free(reply); + if (nCharInfos > 0) { + if (shmid == -1) + free(pIndex2UniqIndex); + if (!pDesc) + free(pCI); + } + return Success; } } static int -ProcXF86BigfontDispatch( - ClientPtr client) +ProcXF86BigfontDispatch(ClientPtr client) { REQUEST(xReq); switch (stuff->data) { - case X_XF86BigfontQueryVersion: - return ProcXF86BigfontQueryVersion(client); - case X_XF86BigfontQueryFont: - return ProcXF86BigfontQueryFont(client); - default: - return BadRequest; + case X_XF86BigfontQueryVersion: + return ProcXF86BigfontQueryVersion(client); + case X_XF86BigfontQueryFont: + return ProcXF86BigfontQueryFont(client); + default: + return BadRequest; } } static int -SProcXF86BigfontQueryVersion( - ClientPtr client) +SProcXF86BigfontQueryVersion(ClientPtr client) { REQUEST(xXF86BigfontQueryVersionReq); char tmp; @@ -677,8 +682,7 @@ SProcXF86BigfontQueryVersion( } static int -SProcXF86BigfontQueryFont( - ClientPtr client) +SProcXF86BigfontQueryFont(ClientPtr client) { REQUEST(xXF86BigfontQueryFontReq); char tmp; @@ -690,18 +694,17 @@ SProcXF86BigfontQueryFont( } static int -SProcXF86BigfontDispatch( - ClientPtr client) +SProcXF86BigfontDispatch(ClientPtr client) { REQUEST(xReq); switch (stuff->data) { - case X_XF86BigfontQueryVersion: - return SProcXF86BigfontQueryVersion(client); - case X_XF86BigfontQueryFont: - return SProcXF86BigfontQueryFont(client); - default: - return BadRequest; + case X_XF86BigfontQueryVersion: + return SProcXF86BigfontQueryVersion(client); + case X_XF86BigfontQueryFont: + return SProcXF86BigfontQueryFont(client); + default: + return BadRequest; } } @@ -709,41 +712,41 @@ void XFree86BigfontExtensionInit(void) { if (AddExtension(XF86BIGFONTNAME, - XF86BigfontNumberEvents, - XF86BigfontNumberErrors, - ProcXF86BigfontDispatch, - SProcXF86BigfontDispatch, - XF86BigfontResetProc, - StandardMinorOpcode)) { + XF86BigfontNumberEvents, + XF86BigfontNumberErrors, + ProcXF86BigfontDispatch, + SProcXF86BigfontDispatch, + XF86BigfontResetProc, StandardMinorOpcode)) { #ifdef HAS_SHM #ifdef MUST_CHECK_FOR_SHM_SYSCALL - /* - * Note: Local-clients will not be optimized without shared memory - * support. Remote-client optimization does not depend on shared - * memory support. Thus, the extension is still registered even - * when shared memory support is not functional. - */ - if (!CheckForShmSyscall()) { - ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n"); - return; - } + /* + * Note: Local-clients will not be optimized without shared memory + * support. Remote-client optimization does not depend on shared + * memory support. Thus, the extension is still registered even + * when shared memory support is not functional. + */ + if (!CheckForShmSyscall()) { + ErrorF(XF86BIGFONTNAME + " extension local-client optimization disabled due to lack of shared memory support in the kernel\n"); + return; + } #endif - srand((unsigned int) time(NULL)); - signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16) - + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand()); - /* fprintf(stderr, "signature = 0x%08X\n", signature); */ + srand((unsigned int) time(NULL)); + signature = ((unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()) << 16) + + (unsigned int) (65536.0 / (RAND_MAX + 1.0) * rand()); + /* fprintf(stderr, "signature = 0x%08X\n", signature); */ - FontShmdescIndex = AllocateFontPrivateIndex(); + FontShmdescIndex = AllocateFontPrivateIndex(); #if !defined(CSRG_BASED) && !defined(__CYGWIN__) - pagesize = SHMLBA; + pagesize = SHMLBA; #else -# ifdef _SC_PAGESIZE - pagesize = sysconf(_SC_PAGESIZE); -# else - pagesize = getpagesize(); -# endif +#ifdef _SC_PAGESIZE + pagesize = sysconf(_SC_PAGESIZE); +#else + pagesize = getpagesize(); +#endif #endif #endif } -- cgit v1.2.3