Attachment "gcc3.3-strict-aliasing.patch" to
ticket [918871ffff]
added by
rmax
2004-03-19 01:39:00.
--- generic/tclClock.c 30 Oct 2003 22:46:42 -0000 1.24
+++ generic/tclClock.c 18 Mar 2004 17:45:08 -0000
@@ -323,7 +323,7 @@
#endif
tclockVal = clockVal;
- timeDataPtr = TclpGetDate((TclpTime_t) &tclockVal, useGMT);
+ timeDataPtr = TclpGetDate(&tclockVal, useGMT);
/*
* Make a guess at the upper limit on the substituted string size
--- generic/tclDate.c 17 Mar 2004 18:14:13 -0000 1.23
+++ generic/tclDate.c 18 Mar 2004 17:45:09 -0000
@@ -566,7 +565,7 @@
/* Perform a preliminary DST compensation ?? */
if (DSTmode == DSTon
- || (DSTmode == DSTmaybe && TclpGetDate((TclpTime_t)&Julian, 0)->tm_isdst))
+ || (DSTmode == DSTmaybe && TclpGetDate(&Julian, 0)->tm_isdst))
Julian -= 60 * 60;
*TimePtr = Julian;
return 0;
@@ -580,8 +579,8 @@
{
time_t StartDay;
time_t FutureDay;
- StartDay = (TclpGetDate((TclpTime_t)&Start, 0)->tm_hour + 1) % 24;
- FutureDay = (TclpGetDate((TclpTime_t)&Future, 0)->tm_hour + 1) % 24;
+ StartDay = (TclpGetDate(&Start, 0)->tm_hour + 1) % 24;
+ FutureDay = (TclpGetDate(&Future, 0)->tm_hour + 1) % 24;
return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
}
@@ -596,7 +595,7 @@
time_t now;
now = Start;
- tm = TclpGetDate((TclpTime_t)&now, 0);
+ tm = TclpGetDate(&now, 0);
now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
return DSTcorrect(Start, now);
@@ -613,7 +612,7 @@
int result;
now = Start;
- tm = TclpGetDate((TclpTime_t)&now, 0);
+ tm = TclpGetDate(&now, 0);
/* To compute the next n'th month, we use this alg:
* add n to year value
* if currentMonth < requestedMonth decrement year value by 1 (so that
@@ -648,7 +647,7 @@
*TimePtr = 0;
return 0;
}
- tm = TclpGetDate((TclpTime_t)&Start, 0);
+ tm = TclpGetDate(&Start, 0);
Month = 12 * (tm->tm_year + TM_YEAR_BASE) + tm->tm_mon + RelMonth;
Year = Month / 12;
Month = Month % 12 + 1;
@@ -921,7 +920,7 @@
TclDateInput = p;
/* now has to be cast to a time_t for 64bit compliance */
Start = now;
- tm = TclpGetDate((TclpTime_t) &Start, (zone == -50000));
+ tm = TclpGetDate(&Start, (zone == -50000));
thisyear = tm->tm_year + TM_YEAR_BASE;
TclDateYear = thisyear;
TclDateMonth = tm->tm_mon + 1;
--- generic/tclGetDate.y 17 Mar 2004 18:14:13 -0000 1.21
+++ generic/tclGetDate.y 18 Mar 2004 17:45:09 -0000
@@ -785,7 +785,7 @@
/* Perform a preliminary DST compensation ?? */
if (DSTmode == DSTon
- || (DSTmode == DSTmaybe && TclpGetDate((TclpTime_t)&Julian, 0)->tm_isdst))
+ || (DSTmode == DSTmaybe && TclpGetDate(Julian, 0)->tm_isdst))
Julian -= 60 * 60;
*TimePtr = Julian;
return 0;
@@ -799,8 +799,8 @@
{
time_t StartDay;
time_t FutureDay;
- StartDay = (TclpGetDate((TclpTime_t)&Start, 0)->tm_hour + 1) % 24;
- FutureDay = (TclpGetDate((TclpTime_t)&Future, 0)->tm_hour + 1) % 24;
+ StartDay = (TclpGetDate(Start, 0)->tm_hour + 1) % 24;
+ FutureDay = (TclpGetDate(Future, 0)->tm_hour + 1) % 24;
return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
}
@@ -815,7 +815,7 @@
time_t now;
now = Start;
- tm = TclpGetDate((TclpTime_t)&now, 0);
+ tm = TclpGetDate(now, 0);
now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7);
now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1);
return DSTcorrect(Start, now);
@@ -832,7 +832,7 @@
int result;
now = Start;
- tm = TclpGetDate((TclpTime_t)&now, 0);
+ tm = TclpGetDate(now, 0);
/* To compute the next n'th month, we use this alg:
* add n to year value
* if currentMonth < requestedMonth decrement year value by 1 (so that
@@ -867,7 +867,7 @@
*TimePtr = 0;
return 0;
}
- tm = TclpGetDate((TclpTime_t)&Start, 0);
+ tm = TclpGetDate(Start, 0);
Month = 12 * (tm->tm_year + TM_YEAR_BASE) + tm->tm_mon + RelMonth;
Year = Month / 12;
Month = Month % 12 + 1;
@@ -1140,7 +1140,7 @@
yyInput = p;
/* now has to be cast to a time_t for 64bit compliance */
Start = now;
- tm = TclpGetDate((TclpTime_t) &Start, (zone == -50000));
+ tm = TclpGetDate(Start, (zone == -50000));
thisyear = tm->tm_year + TM_YEAR_BASE;
yyYear = thisyear;
yyMonth = tm->tm_mon + 1;
--- generic/tclInt.decls 17 Mar 2004 18:14:13 -0000 1.69
+++ generic/tclInt.decls 18 Mar 2004 17:45:09 -0000
@@ -522,7 +522,7 @@
int TclpHasSockets(Tcl_Interp *interp)
}
declare 133 generic {
- struct tm *TclpGetDate(TclpTime_t time, int useGMT)
+ struct tm *TclpGetDate(time_t *time, int useGMT)
}
declare 134 generic {
size_t TclpStrftime(char *s, size_t maxsize, CONST char *format,
--- generic/tclInt.h 17 Mar 2004 18:14:13 -0000 1.147
+++ generic/tclInt.h 18 Mar 2004 17:45:09 -0000
@@ -1525,12 +1525,6 @@
typedef struct TclFile_ *TclFile;
/*
- * Opaque names for platform specific types.
- */
-
-typedef struct TclpTime_t_ *TclpTime_t;
-
-/*
* The "globParameters" argument of the function TclGlob is an
* or'ed combination of the following values:
*/
--- generic/tclIntDecls.h 17 Mar 2004 18:14:13 -0000 1.57
+++ generic/tclIntDecls.h 18 Mar 2004 17:45:09 -0000
@@ -691,7 +691,7 @@
#ifndef TclpGetDate_TCL_DECLARED
#define TclpGetDate_TCL_DECLARED
/* 133 */
-EXTERN struct tm * TclpGetDate _ANSI_ARGS_((TclpTime_t time, int useGMT));
+EXTERN struct tm * TclpGetDate _ANSI_ARGS_((CONST time_t *time, int useGMT));
#endif
#ifndef TclpStrftime_TCL_DECLARED
#define TclpStrftime_TCL_DECLARED
@@ -1104,7 +1104,7 @@
int (*tcl_RemoveInterpResolvers) _ANSI_ARGS_((Tcl_Interp * interp, CONST char * name)); /* 130 */
void (*tcl_SetNamespaceResolvers) _ANSI_ARGS_((Tcl_Namespace * namespacePtr, Tcl_ResolveCmdProc * cmdProc, Tcl_ResolveVarProc * varProc, Tcl_ResolveCompiledVarProc * compiledVarProc)); /* 131 */
int (*tclpHasSockets) _ANSI_ARGS_((Tcl_Interp * interp)); /* 132 */
- struct tm * (*tclpGetDate) _ANSI_ARGS_((TclpTime_t time, int useGMT)); /* 133 */
+ struct tm * (*tclpGetDate) _ANSI_ARGS_((CONST time_t *time, int useGMT)); /* 133 */
size_t (*tclpStrftime) _ANSI_ARGS_((char * s, size_t maxsize, CONST char * format, CONST struct tm * t, int useGMT)); /* 134 */
void *reserved135;
void *reserved136;
--- generic/tclNamesp.c 24 Dec 2003 04:18:20 -0000 1.35
+++ generic/tclNamesp.c 18 Mar 2004 17:45:09 -0000
@@ -3093,6 +3093,7 @@
{
Tcl_Namespace *namespacePtr;
CallFrame frame;
+ CallFrame *framep;
Tcl_Obj *objPtr;
char *name;
int length, result;
@@ -3130,7 +3131,9 @@
* the command(s).
*/
- result = Tcl_PushCallFrame(interp, (Tcl_CallFrame *) &frame,
+ /* This is needed to satisfy GCC 3.3's strict aliasing rules */
+ framep = &frame;
+ result = Tcl_PushCallFrame(interp, (Tcl_CallFrame *) framep,
namespacePtr, /*isProcCallFrame*/ 0);
if (result != TCL_OK) {
return TCL_ERROR;
--- generic/tclStubLib.c 4 Dec 2002 07:07:59 -0000 1.6
+++ generic/tclStubLib.c 18 Mar 2004 17:45:10 -0000
@@ -88,6 +88,7 @@
{
CONST char *actualVersion = NULL;
TclStubs *tmp;
+ TclStubs **tmpp;
/*
* We can't optimize this check by caching tclStubsPtr because
@@ -100,8 +101,10 @@
return NULL;
}
+ /* This is needed to satisfy GCC 3.3's strict aliasing rules */
+ tmpp = &tmp;
actualVersion = Tcl_PkgRequireEx(interp, "Tcl", version, exact,
- (ClientData *) &tmp);
+ (ClientData *) tmpp);
if (actualVersion == NULL) {
tclStubsPtr = NULL;
return NULL;
--- unix/tclUnixChan.c 25 Feb 2004 14:50:41 -0000 1.46
+++ unix/tclUnixChan.c 18 Mar 2004 17:45:10 -0000
@@ -3165,6 +3165,7 @@
struct timeval blockTime, *timeoutPtr;
int index, bit, numFound, result = 0;
fd_mask readyMasks[3*MASK_SIZE];
+ fd_mask *maskp[3];
/* This array reflects the readable/writable
* conditions that were found to exist by the
* last call to select. */
@@ -3239,9 +3240,13 @@
* Wait for the event or a timeout.
*/
- numFound = select(fd+1, (SELECT_MASK *) &readyMasks[0],
- (SELECT_MASK *) &readyMasks[MASK_SIZE],
- (SELECT_MASK *) &readyMasks[2*MASK_SIZE], timeoutPtr);
+ /* This is needed to satisfy GCC 3.3's strict aliasing rules */
+ maskp[0] = &readyMasks[0];
+ maskp[1] = &readyMasks[MASK_SIZE];
+ maskp[2] = &readyMasks[2*MASK_SIZE];
+ numFound = select(fd+1, (SELECT_MASK *) maskp[0],
+ (SELECT_MASK *) maskp[1],
+ (SELECT_MASK *) maskp[2], timeoutPtr);
if (numFound == 1) {
if (readyMasks[index] & bit) {
result |= TCL_READABLE;
--- unix/tclUnixTime.c 19 May 2003 17:25:37 -0000 1.18
+++ unix/tclUnixTime.c 18 Mar 2004 17:45:10 -0000
@@ -287,15 +287,13 @@
struct tm *
TclpGetDate(time, useGMT)
- TclpTime_t time;
+ CONST time_t *time;
int useGMT;
{
- CONST time_t *tp = (CONST time_t *)time;
-
if (useGMT) {
- return ThreadSafeGMTime(tp);
+ return ThreadSafeGMTime(time);
} else {
- return ThreadSafeLocalTime(tp);
+ return ThreadSafeLocalTime(time);
}
}
--- win/tclWinTime.c 16 Dec 2003 02:55:38 -0000 1.21
+++ win/tclWinTime.c 18 Mar 2004 17:45:10 -0000
@@ -545,10 +545,9 @@
struct tm *
TclpGetDate(t, useGMT)
- TclpTime_t t;
+ CONST time_t t;
int useGMT;
{
- const time_t *tp = (const time_t *) t;
struct tm *tmPtr;
time_t time;
@@ -571,14 +570,14 @@
H. Giese, June 2003
*/
#ifdef __BORLANDC__
- if (*tp >= SECSPERDAY) {
+ if (t >= SECSPERDAY) {
#else
- if (*tp >= 0) {
+ if (t >= 0) {
#endif
return localtime(tp);
}
- time = *tp - timezone;
+ time = t - timezone;
/*
* If we aren't near to overflowing the long, just add the bias and
@@ -586,11 +585,11 @@
* the result at the end.
*/
- if (*tp < (LONG_MAX - 2 * SECSPERDAY)
- && *tp > (LONG_MIN + 2 * SECSPERDAY)) {
+ if (t < (LONG_MAX - 2 * SECSPERDAY)
+ && t > (LONG_MIN + 2 * SECSPERDAY)) {
tmPtr = ComputeGMT(&time);
} else {
- tmPtr = ComputeGMT(tp);
+ tmPtr = ComputeGMT(&t);
tzset();
@@ -626,7 +625,7 @@
tmPtr->tm_wday = (tmPtr->tm_wday + time) % 7;
}
} else {
- tmPtr = ComputeGMT(tp);
+ tmPtr = ComputeGMT(&t);
}
return tmPtr;
}