From 2696a81e647c227ce916f8a6ad6b889bf137ffa0 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 22 Dec 2006 19:06:12 +0000 Subject: Fix [Bug 1522467] using fix similar to that used in Tcl recently. --- ChangeLog | 4 ++++ unix/tkUnixEvent.c | 53 +++++++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08e0b67..44aa5fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-12-22 Donal K. Fellows + * unix/tkUnixEvent.c (TkUnixDoOneXEvent): Made correct on AMD64 and + other similar 64-bit systems where fd_mask is not 'unsigned int' in + effect. [Bug 1522467] + * library/msgs/es_ES.msg (removed): * library/msgs/es.msg: Fixed translation fault that was present in all Spanish-speaking locales. [Bug 1111213] diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index d15d175..758f00e 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixEvent.c,v 1.11.2.6 2006/01/20 18:42:04 jenglish Exp $ + * RCS: @(#) $Id: tkUnixEvent.c,v 1.11.2.7 2006/12/22 19:06:12 dkf Exp $ */ #include "tkInt.h" @@ -466,13 +466,12 @@ DisplayFileProc(clientData, flags) * * TkUnixDoOneXEvent -- * - * This routine waits for an X event to be processed or for - * a timeout to occur. The timeout is specified as an absolute - * time. This routine is called when Tk needs to wait for a - * particular X event without letting arbitrary events be - * processed. The caller will typically call Tk_RestrictEvents - * to set up an event filter before calling this routine. This - * routine will service at most one event per invocation. + * This routine waits for an X event to be processed or for a timeout to + * occur. The timeout is specified as an absolute time. This routine is + * called when Tk needs to wait for a particular X event without letting + * arbitrary events be processed. The caller will typically call + * Tk_RestrictEvents to set up an event filter before calling this + * routine. This routine will service at most one event per invocation. * * Results: * Returns 0 if the timeout has expired, otherwise returns 1. @@ -485,14 +484,15 @@ DisplayFileProc(clientData, flags) int TkUnixDoOneXEvent(timePtr) - Tcl_Time *timePtr; /* Specifies the absolute time when the - * call should time out. */ + Tcl_Time *timePtr; /* Specifies the absolute time when the call + * should time out. */ { TkDisplay *dispPtr; static fd_mask readMask[MASK_SIZE]; struct timeval blockTime, *timeoutPtr; Tcl_Time now; - int fd, index, bit, numFound, numFdBits = 0; + int fd, index, numFound, numFdBits = 0; + fd_mask bit; /* * Look for queued events first. @@ -503,9 +503,9 @@ TkUnixDoOneXEvent(timePtr) } /* - * Compute the next block time and check to see if we have timed out. - * Note that HP-UX defines tv_sec to be unsigned so we have to be - * careful in our arithmetic. + * Compute the next block time and check to see if we have timed out. Note + * that HP-UX defines tv_sec to be unsigned so we have to be careful in + * our arithmetic. */ if (timePtr) { @@ -528,21 +528,26 @@ TkUnixDoOneXEvent(timePtr) } /* - * Set up the select mask for all of the displays. If a display has - * data pending, then we want to poll instead of blocking. + * Set up the select mask for all of the displays. If a display has data + * pending, then we want to poll instead of blocking. */ memset((VOID *) readMask, 0, MASK_SIZE*sizeof(fd_mask)); for (dispPtr = TkGetDisplayList(); dispPtr != NULL; - dispPtr = dispPtr->nextPtr) { + dispPtr = dispPtr->nextPtr) { XFlush(dispPtr->display); if (QLength(dispPtr->display) > 0) { blockTime.tv_sec = 0; blockTime.tv_usec = 0; } fd = ConnectionNumber(dispPtr->display); + + /* + * Assume there are always at least 'fd' bits in the 'readMask' array. + */ + index = fd/(NBBY*sizeof(fd_mask)); - bit = 1 << (fd%(NBBY*sizeof(fd_mask))); + bit = ((fd_mask)1) << (fd%(NBBY*sizeof(fd_mask))); readMask[index] |= bit; if (numFdBits <= fd) { numFdBits = fd+1; @@ -553,8 +558,8 @@ TkUnixDoOneXEvent(timePtr) timeoutPtr); if (numFound <= 0) { /* - * Some systems don't clear the masks after an error, so - * we have to do it here. + * Some systems don't clear the masks after an error, so we have to do + * it here. */ memset((VOID *) readMask, 0, MASK_SIZE*sizeof(fd_mask)); @@ -565,10 +570,10 @@ TkUnixDoOneXEvent(timePtr) */ for (dispPtr = TkGetDisplayList(); dispPtr != NULL; - dispPtr = dispPtr->nextPtr) { + dispPtr = dispPtr->nextPtr) { fd = ConnectionNumber(dispPtr->display); index = fd/(NBBY*sizeof(fd_mask)); - bit = 1 << (fd%(NBBY*sizeof(fd_mask))); + bit = ((fd_mask)1) << (fd%(NBBY*sizeof(fd_mask))); if ((readMask[index] & bit) || (QLength(dispPtr->display) > 0)) { DisplayFileProc((ClientData)dispPtr, TCL_READABLE); } @@ -590,8 +595,8 @@ TkUnixDoOneXEvent(timePtr) } /* - * We had an event but we did not generate a Tcl event from it. Behave - * as though we dealt with it. (JYL&SS) + * We had an event but we did not generate a Tcl event from it. Behave as + * though we dealt with it. (JYL&SS) */ return 1; -- cgit v0.12