diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-09-07 13:58:51 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-09-07 13:58:51 (GMT) |
commit | c92b03f0a41ea3598cc2953a87c251fac504bf7a (patch) | |
tree | cef35ca5d056f667b726c878bfa4c2a6e2eba470 | |
parent | 5ea46c24a2d2e32cd25e06728a7b81f3a949f5a8 (diff) | |
parent | 2b93599ffd06e74e9e904fbafd83196839390119 (diff) | |
download | tcl-c92b03f0a41ea3598cc2953a87c251fac504bf7a.zip tcl-c92b03f0a41ea3598cc2953a87c251fac504bf7a.tar.gz tcl-c92b03f0a41ea3598cc2953a87c251fac504bf7a.tar.bz2 |
Don't let Tcl compilation depend on USE_32BIT_TIME_T any more: Microsoft could discontinue this macro any moment, then we are prepared ....
As a bonus: time_t is now allowed to be 64-bit internally, without effect on the C API (like stub-enabled extensions)
-rw-r--r-- | generic/tcl.h | 2 | ||||
-rw-r--r-- | generic/tclBasic.c | 14 | ||||
-rw-r--r-- | win/tclWinPort.h | 6 | ||||
-rw-r--r-- | win/tclWinTime.c | 25 |
4 files changed, 25 insertions, 22 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 2077a32..1dfb200 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -440,7 +440,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt; #if defined(_WIN32) # ifdef __BORLANDC__ typedef struct stati64 Tcl_StatBuf; -# elif defined(_WIN64) || defined(__MINGW_USE_VC2005_COMPAT) || defined(_USE_64BIT_TIME_T) +# elif defined(_WIN64) || defined(_USE_64BIT_TIME_T) typedef struct __stat64 Tcl_StatBuf; # elif (defined(_MSC_VER) && (_MSC_VER < 1400)) || defined(_USE_32BIT_TIME_T) typedef struct _stati64 Tcl_StatBuf; diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 53d1158..a03f131 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -484,19 +484,13 @@ Tcl_CreateInterp(void) Tcl_Panic("Tcl_CallFrame must not be smaller than CallFrame"); } -#if defined(_WIN32) && !defined(_WIN64) && !defined(_USE_64BIT_TIME_T) \ - && !defined(__MINGW_USE_VC2005_COMPAT) - /* If Tcl is compiled on Win32 using -D_USE_64BIT_TIME_T or - * -D__MINGW_USE_VC2005_COMPAT, the result is a binary incompatible - * with the 'standard' build of Tcl: All extensions using Tcl_StatBuf - * or interal functions like TclpGetDate() need to be recompiled in +#if defined(_WIN32) && !defined(_WIN64) && !defined(_USE_64BIT_TIME_T) + /* If Tcl is compiled on Win32 using -D_USE_64BIT_TIME_T + * the result is a binary incompatible with the 'standard' build of + * Tcl: All extensions using Tcl_StatBuf need to be recompiled in * the same way. Therefore, this is not officially supported. * In stead, it is recommended to use Win64 or Tcl 9.0 (not released yet) */ - if (sizeof(time_t) != 4) { - /*NOTREACHED*/ - Tcl_Panic("<time.h> is not compatible with MSVC"); - } if ((TclOffset(Tcl_StatBuf,st_atime) != 32) || (TclOffset(Tcl_StatBuf,st_ctime) != 40)) { /*NOTREACHED*/ diff --git a/win/tclWinPort.h b/win/tclWinPort.h index fa699f0..337d88d 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -14,14 +14,10 @@ #ifndef _TCLWINPORT #define _TCLWINPORT -/* define _USE_64BIT_TIME_T (or make/configure option time64bit) to force 64-bit time_t */ -#if defined(_USE_64BIT_TIME_T) -#define __MINGW_USE_VC2005_COMPAT -#endif #if !defined(_WIN64) && !defined(__MINGW_USE_VC2005_COMPAT) /* See [Bug 3354324]: file mtime sets wrong time */ -# define _USE_32BIT_TIME_T +# define __MINGW_USE_VC2005_COMPAT #endif /* diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 42fd99f..7de0941 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -729,6 +729,11 @@ TclpGetDate( { struct tm *tmPtr; time_t time; +#if defined(_WIN64) || (defined(_USE_64BIT_TIME_T) || (defined(_MSC_VER) && _MSC_VER < 1400)) +# define t2 *t /* no need to cripple time to 32-bit */ +#else + time_t t2 = *(__time32_t *)t; +#endif if (!useGMT) { #if defined(_MSC_VER) && (_MSC_VER >= 1900) @@ -761,15 +766,15 @@ TclpGetDate( #define LOCALTIME_VALIDITY_BOUNDARY 0 #endif - if (*t >= LOCALTIME_VALIDITY_BOUNDARY) { - return TclpLocaltime(t); + if (t2 >= LOCALTIME_VALIDITY_BOUNDARY) { + return TclpLocaltime(&t2); } #if defined(_MSC_VER) && (_MSC_VER >= 1900) _get_timezone(&timezone); #endif - time = *t - timezone; + time = t2 - timezone; /* * If we aren't near to overflowing the long, just add the bias and @@ -777,10 +782,10 @@ TclpGetDate( * result at the end. */ - if (*t < (LONG_MAX - 2*SECSPERDAY) && *t > (LONG_MIN + 2*SECSPERDAY)) { + if (t2 < (LONG_MAX - 2*SECSPERDAY) && t2 > (LONG_MIN + 2*SECSPERDAY)) { tmPtr = ComputeGMT(&time); } else { - tmPtr = ComputeGMT(t); + tmPtr = ComputeGMT(&t2); tzset(); @@ -816,7 +821,7 @@ TclpGetDate( tmPtr->tm_wday = (tmPtr->tm_wday + (int)time) % 7; } } else { - tmPtr = ComputeGMT(t); + tmPtr = ComputeGMT(&t2); } return tmPtr; } @@ -1350,7 +1355,11 @@ TclpGmtime( * Posix gmtime_r function. */ +#if defined(_WIN64) || defined(_USE_64BIT_TIME_T) || (defined(_MSC_VER) && _MSC_VER < 1400) return gmtime(timePtr); +#else + return _gmtime32((CONST __time32_t *)timePtr); +#endif } /* @@ -1381,7 +1390,11 @@ TclpLocaltime( * provide a Posix localtime_r function. */ +#if defined(_WIN64) || defined(_USE_64BIT_TIME_T) || (defined(_MSC_VER) && _MSC_VER < 1400) return localtime(timePtr); +#else + return _localtime32((CONST __time32_t *)timePtr); +#endif } /* |