summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-09-07 13:53:12 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-09-07 13:53:12 (GMT)
commit2b93599ffd06e74e9e904fbafd83196839390119 (patch)
tree1b8c25e5676c48afd7166788986db231c11a6f21 /win
parentd0f808008dd96dd8b4ba1988087dbb644ac63283 (diff)
parent3179298819aa21980bfe9e77759c6e5f7291e77a (diff)
downloadtcl-2b93599ffd06e74e9e904fbafd83196839390119.zip
tcl-2b93599ffd06e74e9e904fbafd83196839390119.tar.gz
tcl-2b93599ffd06e74e9e904fbafd83196839390119.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)
Diffstat (limited to 'win')
-rw-r--r--win/tclWinPort.h6
-rw-r--r--win/tclWinTime.c25
2 files changed, 20 insertions, 11 deletions
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index b14aa6b..c30d346 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -14,13 +14,9 @@
#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
#define WIN32_LEAN_AND_MEAN
diff --git a/win/tclWinTime.c b/win/tclWinTime.c
index c3c22a4..1204ec7 100644
--- a/win/tclWinTime.c
+++ b/win/tclWinTime.c
@@ -845,6 +845,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)
@@ -877,15 +882,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
@@ -893,10 +898,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();
@@ -932,7 +937,7 @@ TclpGetDate(
tmPtr->tm_wday = (tmPtr->tm_wday + (int)time) % 7;
}
} else {
- tmPtr = ComputeGMT(t);
+ tmPtr = ComputeGMT(&t2);
}
return tmPtr;
}
@@ -1466,7 +1471,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
}
/*
@@ -1498,7 +1507,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
}
/*