From 509281cd2ab88a10a9e781f373d5e59f29f3bc79 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Wed, 14 Jun 2006 15:21:12 +0000 Subject: Enable building Tcl with Microsoft's latest compiler offering (VS2005). We have to handle a number of oddities as they have deprecated most of the standard C library and now generate manifest files to be linked into the binaries. SF bug #1424909 --- ChangeLog | 11 +++++ generic/regerror.c | 10 ++--- generic/tcl.h | 6 ++- generic/tclDate.c | 6 +-- tests/env.test | 8 ++-- win/makefile.vc | 32 +++++++------- win/nmakehlp.c | 54 ++++++++++++++++++++---- win/rules.vc | 120 ++++++++++++++++++++++++++++++++++++++++++++--------- win/tclWinTime.c | 18 ++++---- 9 files changed, 201 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index 957ccd0..0f64b36 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-06-14 Pat Thoyts + + * generic/regerror.c: Enable building Tcl with Microsoft's + * generic/tcl.h: latest compiler offering (VS2005). + * generic/tclDate.c: We have to handle a number of oddities + * tests/env.test: as they have deprecated most of the + * win/makefile.vc: standard C library and now generate + * win/nmakehlp.c: manifest files to be linked into the + * win/rules.vc: binaries. SF bug #1424909 + * win/tclWinTime.c: + 2006-06-13 Donal K. Fellows * unix/tclLoadDl.c (TclpDlopen): Workaround for a compiler bug in Sun diff --git a/generic/regerror.c b/generic/regerror.c index aca13aa..182830d 100644 --- a/generic/regerror.c +++ b/generic/regerror.c @@ -50,8 +50,8 @@ static struct rerr { */ /* ARGSUSED */ size_t /* actual space needed (including NUL) */ -regerror(errcode, preg, errbuf, errbuf_size) -int errcode; /* error code, or REG_ATOI or REG_ITOA */ +regerror(code, preg, errbuf, errbuf_size) +int code; /* error code, or REG_ATOI or REG_ITOA */ CONST regex_t *preg; /* associated regex_t (unused at present) */ char *errbuf; /* result buffer (unless errbuf_size==0) */ size_t errbuf_size; /* available space in errbuf, can be 0 */ @@ -62,7 +62,7 @@ size_t errbuf_size; /* available space in errbuf, can be 0 */ size_t len; int icode; - switch (errcode) { + switch (code) { case REG_ATOI: /* convert name to number */ for (r = rerrs; r->code >= 0; r++) if (strcmp(r->name, errbuf) == 0) @@ -84,12 +84,12 @@ size_t errbuf_size; /* available space in errbuf, can be 0 */ break; default: /* a real, normal error code */ for (r = rerrs; r->code >= 0; r++) - if (r->code == errcode) + if (r->code == code) break; if (r->code >= 0) msg = r->explain; else { /* unknown; say so */ - sprintf(convbuf, unk, errcode); + sprintf(convbuf, unk, code); msg = convbuf; } break; diff --git a/generic/tcl.h b/generic/tcl.h index 5d7f192..f960ea0 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.153.2.24 2006/05/30 00:29:38 hobbs Exp $ + * RCS: @(#) $Id: tcl.h,v 1.153.2.25 2006/06/14 15:21:14 patthoyts Exp $ */ #ifndef _TCL @@ -385,7 +385,11 @@ typedef struct stati64 Tcl_StatBuf; # define TCL_LL_MODIFIER "L" # define TCL_LL_MODIFIER_SIZE 1 # else /* __BORLANDC__ */ +# if _MSC_VER < 1400 typedef struct _stati64 Tcl_StatBuf; +# else +typedef struct _stat64 Tcl_StatBuf; +# endif /* _MSC_VER < 1400 */ # define TCL_LL_MODIFIER "I64" # define TCL_LL_MODIFIER_SIZE 3 # endif /* __BORLANDC__ */ diff --git a/generic/tclDate.c b/generic/tclDate.c index e6a8a90..be6ec42 100644 --- a/generic/tclDate.c +++ b/generic/tclDate.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDate.c,v 1.20.4.2 2005/11/04 20:15:09 kennykb Exp $ + * RCS: @(#) $Id: tclDate.c,v 1.20.4.3 2006/06/14 15:21:14 patthoyts Exp $ */ #include "tclInt.h" @@ -478,7 +478,7 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode, TimePtr) for (i = EPOCH; i < Year; i++) Julian += 365 + IsLeapYear(i); } else { - for (i = Year; i < EPOCH; i++) + for (i = (int)Year; i < EPOCH; i++) Julian -= 365 + IsLeapYear(i); } Julian *= SECSPERDAY; @@ -547,7 +547,7 @@ NamedMonth(Start, MonthOrdinal, MonthNumber) * doing next february from january gives us february of the current year) * set day to 1, time to 0 */ - tm->tm_year += MonthOrdinal; + tm->tm_year += (int)MonthOrdinal; if (tm->tm_mon < MonthNumber - 1) { tm->tm_year--; } diff --git a/tests/env.test b/tests/env.test index 7bfeb3c..7653b05 100644 --- a/tests/env.test +++ b/tests/env.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: env.test,v 1.17.2.3 2005/10/05 08:03:18 hobbs Exp $ +# RCS: @(#) $Id: env.test,v 1.17.2.4 2006/06/14 15:21:14 patthoyts Exp $ package require tcltest 2 namespace import -force ::tcltest::* @@ -75,7 +75,7 @@ set printenvScript [makeFile { lrem names ComSpec lrem names "" } - foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH __CF_USER_TEXT_ENCODING } { + foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH __CF_USER_TEXT_ENCODING SYSTEMDRIVE SYSTEMROOT} { lrem names $name } foreach p $names { @@ -98,14 +98,14 @@ proc getenv {} { # Save the current environment variables at the start of the test. foreach name [array names env] { - set env2($name) $env($name) + set env2([string toupper $name]) $env($name) unset env($name) } # Added the following lines so that child tcltest can actually find its # library if the initial tcltest is run from a non-standard place. # ('saved' env vars) -foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH} { +foreach name {TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH SYSTEMDRIVE SYSTEMROOT} { if {[info exists env2($name)]} { set env($name) $env2($name); } diff --git a/win/makefile.vc b/win/makefile.vc index 7b8fe5f..417b13f 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -12,12 +12,13 @@ # Copyright (c) 2001-2002 David Gravereaux. # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: makefile.vc,v 1.100.2.7 2005/11/30 00:15:39 hobbs Exp $ +# RCS: @(#) $Id: makefile.vc,v 1.100.2.8 2006/06/14 15:21:14 patthoyts Exp $ #------------------------------------------------------------------------------ # Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR) -# or with the MS Platform SDK (MSSDK) -!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) +# or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define +# VCINSTALLDIR instead. +!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(MSSDK) && !defined(VCINSTALLDIR) MSG = ^ You need to run vcvars32.bat from Developer Studio or setenv.bat from the^ Platform SDK first to setup the environment. Jump to this line to read^ @@ -322,27 +323,20 @@ WINDIR = $(ROOT)\win !if !$(DEBUG) !if $(OPTIMIZING) ### This cranks the optimization level to maximize speed -cdebug = -O2 -Op -Gs +cdebug = -O2 $(OPTIMIZATIONS) !else cdebug = !endif !else if "$(MACHINE)" == "IA64" ### Warnings are too many, can't support warnings into errors. -cdebug = -Z7 -Od +cdebug = -Z7 -Od $(DEBUGFLAGS) !else -cdebug = -Z7 -WX -Od +cdebug = -Z7 -WX $(DEBUGFLAGS) !endif ### Declarations common to all compiler options -cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\ - -!if $(PENT_0F_ERRATA) -cflags = $(cflags) -QI0f -!endif - -!if $(ITAN_B_ERRATA) -cflags = $(cflags) -QIA64_Bx -!endif +cwarn = -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE +cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ !if $(MSVCRT) !if "$(DBGX)" == "" @@ -458,6 +452,7 @@ $** $(baselibs) @<< $** << + $(_VC_MANIFEST_EMBED_DLL) -@del $*.exp !endif @@ -466,13 +461,16 @@ $(TCLSTUBLIB): $(TCLSTUBOBJS) $(TCLSH): $(TCLSHOBJS) $(TCLIMPLIB) $(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $** + $(_VC_MANIFEST_EMBED_EXE) $(TCLTEST): $(TCLTESTOBJS) $(TCLIMPLIB) $(link32) $(conlflags) -stack:2300000 -out:$@ $(baselibs) $** + $(_VC_MANIFEST_EMBED_EXE) $(TCLPIPEDLL): $(WINDIR)\stub16.c $(cc32) $(CON_CFLAGS) -Fo$(TMP_DIR)\ $(WINDIR)\stub16.c $(link32) $(conlflags) -out:$@ $(TMP_DIR)\stub16.obj $(baselibs) + $(_VC_MANIFEST_EMBED_DLL) !if $(STATIC_BUILD) $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj @@ -481,6 +479,7 @@ $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLDDELIB): $(TMP_DIR)\tclWinDde.obj $(TCLSTUBLIB) $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tcldde -out:$@ \ $** $(baselibs) + $(_VC_MANIFEST_EMBED_DLL) -@del $*.exp -@del $*.lib !endif @@ -492,6 +491,7 @@ $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLREGLIB): $(TMP_DIR)\tclWinReg.obj $(TCLSTUBLIB) $(link32) $(dlllflags) -base:@$(WINDIR)\coffbase.txt,tclreg -out:$@ \ $** $(baselibs) + $(_VC_MANIFEST_EMBED_DLL) -@del $*.exp -@del $*.lib !endif @@ -500,7 +500,7 @@ $(CAT32): $(WINDIR)\cat.c $(cc32) $(CON_CFLAGS) -Fo$(TMP_DIR)\ $? $(link32) $(conlflags) -out:$@ -stack:16384 $(TMP_DIR)\cat.obj \ $(baselibs) - + $(_VC_MANIFEST_EMBED_EXE) #--------------------------------------------------------------------- # Regenerate the stubs files. [Development use only] diff --git a/win/nmakehlp.c b/win/nmakehlp.c index 4906303..48b82c4 100644 --- a/win/nmakehlp.c +++ b/win/nmakehlp.c @@ -9,9 +9,11 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * ---------------------------------------------------------------------------- - * RCS: @(#) $Id: nmakehlp.c,v 1.1 2002/03/27 21:15:43 davygrvy Exp $ + * RCS: @(#) $Id: nmakehlp.c,v 1.1.4.1 2006/06/14 15:21:15 patthoyts Exp $ * ---------------------------------------------------------------------------- */ + +#define _CRT_SECURE_NO_DEPRECATE #include #pragma comment (lib, "user32.lib") #pragma comment (lib, "kernel32.lib") @@ -41,6 +43,19 @@ main (int argc, char *argv[]) DWORD dwWritten; int chars; + /* + * Make sure children (cl.exe and link.exe) are kept quiet. + */ + + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); + + /* + * Make sure the compiler and linker aren't affected by the outside world. + */ + + SetEnvironmentVariable("CL", ""); + SetEnvironmentVariable("LINK", ""); + if (argc > 1 && *argv[1] == '-') { switch (*(argv[1]+1)) { case 'c': @@ -90,11 +105,11 @@ CheckForCompilerFeature (const char *option) STARTUPINFO si; PROCESS_INFORMATION pi; SECURITY_ATTRIBUTES sa; - DWORD threadID; + DWORD threadID, n; char msg[300]; BOOL ok; HANDLE hProcess, h, pipeThreads[2]; - char cmdline[100]; + char cmdline[256]; hProcess = GetCurrentProcess(); @@ -122,11 +137,16 @@ CheckForCompilerFeature (const char *option) 0, TRUE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE); /* base command line */ - strcpy(cmdline, "cl.exe -nologo -c -TC -Fdtemp "); + n = GetEnvironmentVariable("CC", cmdline, 255); + cmdline[n] = 0; + if (n == 0) + strcpy(cmdline, "cl.exe"); + strncat(cmdline, " -nologo -c -TC -Zs -X ", 255); + /* append our option for testing */ strcat(cmdline, option); /* filename to compile, which exists, but is nothing and empty. */ - strcat(cmdline, " nul"); + strcat(cmdline, " .\\nul"); ok = CreateProcess( NULL, /* Module name. */ @@ -175,8 +195,28 @@ CheckForCompilerFeature (const char *option) CloseHandle(pipeThreads[0]); CloseHandle(pipeThreads[1]); - /* look for the commandline warning code in both streams. */ - return !(strstr(Out.buffer, "D4002") != NULL || strstr(Err.buffer, "D4002") != NULL); +#ifdef _DEBUG + { + DWORD err = 0; + strcat(cmdline, "\n"); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), cmdline, + strlen(cmdline), &err, NULL); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), Out.buffer, + strlen(Out.buffer), &err,NULL); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), Err.buffer, + strlen(Err.buffer), &err,NULL); + } +#endif + + /* + * Look for the commandline warning code in both streams. + * - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002. + */ + + return !(strstr(Out.buffer, "D4002") != NULL + || strstr(Err.buffer, "D4002") != NULL + || strstr(Out.buffer, "D9002") != NULL + || strstr(Err.buffer, "D9002") != NULL); } int diff --git a/win/rules.vc b/win/rules.vc index 3cc84b0..05a3062 100644 --- a/win/rules.vc +++ b/win/rules.vc @@ -8,9 +8,10 @@ # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # Copyright (c) 2001-2002 David Gravereaux. +# Copyright (c) 2003 Patrick Thoyts # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: rules.vc,v 1.11 2003/03/01 01:22:46 hobbs Exp $ +# RCS: @(#) $Id: rules.vc,v 1.11.2.1 2006/06/14 15:21:15 patthoyts Exp $ #------------------------------------------------------------------------------ !ifndef _RULES_VC @@ -25,7 +26,7 @@ rc32 = $(RC) # built-in default. ### Assume the normal default. _INSTALLDIR = C:\Program Files\Tcl !else -### Fix the path seperators. +### Fix the path separators. _INSTALLDIR = $(INSTALLDIR:/=\) !endif @@ -61,7 +62,7 @@ RMDIR = deltree /Y #---------------------------------------------------------- !if !exist(nmakehlp.exe) -!if [$(cc32) -nologo -ML nmakehlp.c -link -subsystem:console > nul] +!if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul] !endif !endif @@ -70,7 +71,7 @@ RMDIR = deltree /Y #---------------------------------------------------------- ### test for optimizations -!if [nmakehlp -c -Otip] +!if [nmakehlp -c -Ot] !message *** Compiler has 'Optimizations' OPTIMIZING = 1 !else @@ -78,15 +79,67 @@ OPTIMIZING = 1 OPTIMIZING = 0 !endif +OPTIMIZATIONS = + +!if [nmakehlp -c -Ot] +OPTIMIZATIONS = $(OPTIMIZATIONS) -Ot +!endif + +!if [nmakehlp -c -Oi] +OPTIMIZATIONS = $(OPTIMIZATIONS) -Oi +!endif + +!if [nmakehlp -c -Op] +OPTIMIZATIONS = $(OPTIMIZATIONS) -Op +!endif + +!if [nmakehlp -c -fp:strict] +OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict +!endif + +!if [nmakehlp -c -Gs] +OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs +!endif + +!if [nmakehlp -c -GS] +OPTIMIZATIONS = $(OPTIMIZATIONS) -GS +!endif + +DEBUGFLAGS = + +!if [nmakehlp -c -RTC1] +DEBUGFLAGS = $(DEBUGFLAGS) -RTC1 +!elseif [nmakehlp -c -GZ] +DEBUGFLAGS = $(DEBUGFLAGS) -GZ +!endif + +COMPILERFLAGS =-W3 + +!if [nmakehlp -c -YX] +OPTIMIZATIONS = $(OPTIMIZATIONS) -YX +!endif + !if "$(MACHINE)" == "IX86" ### test for pentium errata !if [nmakehlp -c -QI0f] !message *** Compiler has 'Pentium 0x0f fix' -PENT_0F_ERRATA = 1 +COMPILERFLAGS = $(COMPILERFLAGSS) -QI0f !else !message *** Compiler doesn't have 'Pentium 0x0f fix' -PENT_0F_ERRATA = 0 !endif +!endif + +!if "$(MACHINE)" == "IA64" +### test for Itanium errata +!if [nmakehlp -c -QIA64_Bx] +!message *** Compiler has 'B-stepping errata workarounds' +COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx +!else +!message *** Compiler does not have 'B-stepping errata workarounds' +!endif +!endif + +!if "$(MACHINE)" == "IX86" ### test for -align:4096, when align:512 will do. !if [nmakehlp -l -opt:nowin98] !message *** Linker has 'Win98 alignment problem' @@ -96,21 +149,26 @@ ALIGN98_HACK = 1 ALIGN98_HACK = 0 !endif !else -PENT_0F_ERRATA = 0 ALIGN98_HACK = 0 !endif -!if "$(MACHINE)" == "IA64" -### test for Itanium errata -!if [nmakehlp -c -QIA64_Bx] -!message *** Compiler has 'B-stepping errata workarounds' -ITAN_B_ERRATA = 1 -!else -!message *** Compiler doesn't have 'B-stepping errata workarounds' -ITAN_B_ERRATA = 0 -!endif +#---------------------------------------------------------- +# MSVC8 (ships with Visual Studio 2005) generates a manifest +# file that we should link into the binaries. This is how. +#---------------------------------------------------------- + +_VC_MANIFEST_EMBED_EXE= +_VC_MANIFEST_EMBED_DLL= +!if ![cl /Zs /Tc NUL 2>&1 | find "Version 12" > NUL] +VCVER=6 +!elseif ![cl /Zs /Tc NUL 2>&1 | find "Version 13" > NUL] +VCVER=7 +!elseif ![cl /Zs /Tc NUL 2>&1 | find "Version 14" > NUL] +VCVER=8 +_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 +_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 !else -ITAN_B_ERRATA = 0 +VCVER=0 !endif #---------------------------------------------------------- @@ -126,6 +184,7 @@ MSVCRT = 0 LOIMPACT = 0 TCL_USE_STATIC_PACKAGES = 0 USE_THREAD_ALLOC = 0 +UNCHECKED = 0 !else !if [nmakehlp -f $(OPTS) "static"] !message *** Doing static @@ -175,6 +234,12 @@ USE_THREAD_ALLOC = 1 !else USE_THREAD_ALLOC = 0 !endif +!if [nmakehlp -f $(OPTS) "unchecked"] +!message *** Doing unchecked +UNCHECKED = 1 +!else +UNCHECKED = 0 +!endif !endif @@ -203,6 +268,10 @@ DBGX = SUFX = $(SUFX:g=) !endif +!if $(VCVER) > 6 +BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER) +!endif + TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX !if !$(STATIC_BUILD) @@ -283,6 +352,18 @@ OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1 OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD !endif +!if $(DEBUG) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DEBUG +!elseif $(OPTIMIZING) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED +!endif +!if $(PROFILE) +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED +!endif +!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" +OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT +!endif + #---------------------------------------------------------- # Get common info used when building extensions. @@ -296,7 +377,7 @@ TCLINSTALL = 1 _TCLDIR = $(_INSTALLDIR) !else MSG=^ -Don't know where tcl.h is. Set the TCLDIR macro. +Failed to find tcl.h. Set the TCLDIR macro. !error $(MSG) !endif !else @@ -307,7 +388,7 @@ TCLINSTALL = 1 TCLINSTALL = 0 !else MSG =^ -Don't know where tcl.h is. The TCLDIR macro doesn't appear correct. +Failed to find tcl.h. The TCLDIR macro does not appear correct. !error $(MSG) !endif !endif @@ -356,5 +437,6 @@ TCLTOOLSDIR = $(_TCLDIR)\tools !message *** Output directory will be '$(OUT_DIR)' !message *** Suffix for binaries will be '$(SUFX)' !message *** Optional defines are '$(OPTDEFINES)' +!message *** Compiler version $(VCVER) options are '$(OPTIMIZATIONS) $(DEBUGFLAGS)' !endif diff --git a/win/tclWinTime.c b/win/tclWinTime.c index dbb6dbc..842d114 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.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: tclWinTime.c,v 1.14.2.8 2005/03/30 05:31:13 hobbs Exp $ + * RCS: @(#) $Id: tclWinTime.c,v 1.14.2.9 2006/06/14 15:21:15 patthoyts Exp $ */ #include "tclWinInt.h" @@ -422,7 +422,7 @@ Tcl_GetTime(timePtr) timeInfo.fileTimeLastCall.QuadPart = curFileTime; timeInfo.perfCounterLastCall.QuadPart = curCounter.QuadPart; usecSincePosixEpoch = ( curFileTime - posixEpoch.QuadPart ) / 10; - timePtr->sec = (time_t) ( usecSincePosixEpoch / 1000000 ); + timePtr->sec = (long) ( usecSincePosixEpoch / 1000000 ); timePtr->usec = (unsigned long ) ( usecSincePosixEpoch % 1000000 ); useFtime = 0; } @@ -434,7 +434,7 @@ Tcl_GetTime(timePtr) /* High resolution timer is not available. Just use ftime */ ftime(&t); - timePtr->sec = t.time; + timePtr->sec = (long)t.time; timePtr->usec = t.millitm * 1000; } } @@ -636,9 +636,9 @@ TclpGetDate(t, useGMT) } time /= 24; - tmPtr->tm_mday += time; - tmPtr->tm_yday += time; - tmPtr->tm_wday = (tmPtr->tm_wday + time) % 7; + tmPtr->tm_mday += (int)time; + tmPtr->tm_yday += (int)time; + tmPtr->tm_wday = (tmPtr->tm_wday + (int)time) % 7; } } else { tmPtr = ComputeGMT(tp); @@ -679,8 +679,8 @@ ComputeGMT(tp) * Compute the 4 year span containing the specified time. */ - tmp = *tp / SECSPER4YEAR; - rem = *tp % SECSPER4YEAR; + tmp = (long)(*tp / SECSPER4YEAR); + rem = (LONG)(*tp % SECSPER4YEAR); /* * Correct for weird mod semantics so the remainder is always positive. @@ -746,7 +746,7 @@ ComputeGMT(tp) * Compute day of week. Epoch started on a Thursday. */ - tmPtr->tm_wday = (*tp / SECSPERDAY) + 4; + tmPtr->tm_wday = (long)(*tp / SECSPERDAY) + 4; if ((*tp % SECSPERDAY) < 0) { tmPtr->tm_wday--; } -- cgit v0.12