summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tcl.h2
-rw-r--r--generic/tclBasic.c10
-rw-r--r--tests/cmdAH.test20
-rwxr-xr-xwin/configure20
-rw-r--r--win/configure.in14
-rw-r--r--win/makefile.vc4
-rw-r--r--win/rules.vc12
-rw-r--r--win/tclWinPort.h6
-rw-r--r--win/tclWinTest.c23
9 files changed, 105 insertions, 6 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 64c4683..bc4d9a6 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -414,7 +414,7 @@ typedef unsigned TCL_WIDE_INT_TYPE Tcl_WideUInt;
#if defined(__WIN32__)
# ifdef __BORLANDC__
typedef struct stati64 Tcl_StatBuf;
-# elif defined(_WIN64)
+# elif defined(_WIN64) || defined(__MINGW_USE_VC2005_COMPAT) || 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 3b9fca9..f59c161 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -413,7 +413,15 @@ Tcl_CreateInterp(void)
Tcl_Panic("Tcl_CallFrame must not be smaller than CallFrame");
}
-#if defined(_WIN32) && !defined(_WIN64)
+#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
+ * 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");
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index 516505c..e4205f1 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -18,6 +18,10 @@ if {[lsearch [namespace children] ::tcltest] == -1} {
testConstraint testchmod [llength [info commands testchmod]]
testConstraint testsetplatform [llength [info commands testsetplatform]]
testConstraint testvolumetype [llength [info commands testvolumetype]]
+testConstraint time64bit [expr {
+ $::tcl_platform(pointerSize) >= 8 ||
+ [llength [info command testsize]] && [testsize time_t] >= 8
+}]
testConstraint linkDirectory [expr {
![testConstraint win] ||
($::tcl_platform(osVersion) >= 5.0
@@ -1278,6 +1282,22 @@ test cmdAH-24.13 {Tcl_FileObjCmd: directory mtime} -setup {
file delete -force $dirname
} -result {0 1}
+# 3155760000 is 64-bit unix time, Wed Jan 01 00:00:00 GMT 2070:
+test cmdAH-24.20.1 {Tcl_FileObjCmd: atime 64-bit time_t, bug [4718b41c56]} -constraints {time64bit} -setup {
+ set filename [makeFile "" foo.text]
+} -body {
+ list [file atime $filename 3155760000] [file atime $filename]
+} -cleanup {
+ removeFile $filename
+} -result {3155760000 3155760000}
+test cmdAH-24.20.2 {Tcl_FileObjCmd: mtime 64-bit time_t, bug [4718b41c56]} -constraints {time64bit} -setup {
+ set filename [makeFile "" foo.text]
+} -body {
+ list [file mtime $filename 3155760000] [file mtime $filename]
+} -cleanup {
+ file delete -force $filename
+} -result {3155760000 3155760000}
+
# owned
test cmdAH-25.1 {Tcl_FileObjCmd: owned} {
diff --git a/win/configure b/win/configure
index 5fdb738..d9e945b 100755
--- a/win/configure
+++ b/win/configure
@@ -1381,6 +1381,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-threads build with threads (default: off)
--enable-shared build and link with shared libraries (default: on)
+ --enable-time64bit force 64-bit time_t for 32-bit build (default: off)
--enable-64bit enable 64bit support (where applicable)
--enable-wince enable Win/CE support (where applicable)
--enable-symbols build with debugging symbols (default: off)
@@ -3756,6 +3757,25 @@ $as_echo "#define STATIC_BUILD 1" >>confdefs.h
#--------------------------------------------------------------------
+# Check whether --enable-time64bit was given.
+#--------------------------------------------------------------------
+
+echo "$as_me:$LINENO: checking force of 64-bit time_t" >&5
+echo $ECHO_N "checking force of 64-bit time_t... $ECHO_C" >&6
+# Check whether --enable-time64bit or --disable-time64bit was given.
+if test "${enable_time64bit+set}" = set; then
+ enableval="$enable_time64bit"
+ tcl_ok=$enableval
+else
+ tcl_ok=no
+fi;
+echo "$as_me:$LINENO: result: \"$tcl_ok\"" >&5
+echo "${ECHO_T}\"$tcl_ok\"" >&6
+if test "$tcl_ok" = "yes"; then
+ CFLAGS="${CFLAGS} -D_USE_64BIT_TIME_T"
+fi
+
+#--------------------------------------------------------------------
# The statements below define a collection of compile flags. This
# macro depends on the value of SHARED_BUILD, and should be called
# after SC_ENABLE_SHARED checks the configure switches.
diff --git a/win/configure.in b/win/configure.in
index 12c81ed..dc597b9 100644
--- a/win/configure.in
+++ b/win/configure.in
@@ -91,6 +91,20 @@ SC_TCL_CFG_ENCODING
SC_ENABLE_SHARED
#--------------------------------------------------------------------
+# Check whether --enable-time64bit was given.
+#--------------------------------------------------------------------
+
+AC_MSG_CHECKING([force of 64-bit time_t])
+AC_ARG_ENABLE(time64bit,
+ AC_HELP_STRING([--enable-time64bit],
+ [force 64-bit time_t for 32-bit build (default: off)]),
+ [tcl_ok=$enableval], [tcl_ok=no])
+AC_MSG_RESULT("$tcl_ok")
+if test "$tcl_ok" = "yes"; then
+ CFLAGS="${CFLAGS} -D_USE_64BIT_TIME_T"
+fi
+
+#--------------------------------------------------------------------
# The statements below define a collection of compile flags. This
# macro depends on the value of SHARED_BUILD, and should be called
# after SC_ENABLE_SHARED checks the configure switches.
diff --git a/win/makefile.vc b/win/makefile.vc
index cc340a8..fc6191f 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -70,7 +70,7 @@ the build instructions.
# Sets where to install Tcl from the built binaries.
# C:\Progra~1\Tcl is assumed when not specified.
#
-# OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,unchecked,none
+# OPTS=loimpact,msvcrt,static,staticpkg,symbols,threads,profile,unchecked,time64bit,none
# Sets special options for the core. The default is for none.
# Any combination of the above may be used (comma separated).
# 'none' will over-ride everything to nothing.
@@ -94,6 +94,8 @@ the build instructions.
# unchecked = Allows a symbols build to not use the debug
# enabled runtime (msvcrt.dll not msvcrtd.dll
# or libcmt.lib not libcmtd.lib).
+# time64bit = Forces a build using 64-bit time_t for 32-bit build
+# (CRT library should support this).
#
# STATS=compdbg,memdbg,none
# Sets optional memory and bytecode compiler debugging code added
diff --git a/win/rules.vc b/win/rules.vc
index 33ebfe2..812e607 100644
--- a/win/rules.vc
+++ b/win/rules.vc
@@ -253,12 +253,16 @@ TCL_USE_STATIC_PACKAGES = 0
!endif
!if [nmakehlp -f $(OPTS) "threads"]
!message *** Doing threads
-TCL_THREADS = 1
+TCL_THREADS = 1
USE_THREAD_ALLOC = 1
!else
-TCL_THREADS = 0
+TCL_THREADS = 0
USE_THREAD_ALLOC = 0
!endif
+!if [nmakehlp -f $(OPTS) "time64bit"]
+!message *** Force 64-bit time_t
+_USE_64BIT_TIME_T = 1
+!endif
!if [nmakehlp -f $(OPTS) "symbols"]
!message *** Doing symbols
DEBUG = 1
@@ -488,6 +492,10 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
!endif
+!if "$(_USE_64BIT_TIME_T)" == "1"
+OPTDEFINES = $(OPTDEFINES) -D_USE_64BIT_TIME_T
+!endif
+
#----------------------------------------------------------
# Locate the Tcl headers to build against
#----------------------------------------------------------
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index c30d1bd..b14aa6b 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -14,7 +14,11 @@
#ifndef _TCLWINPORT
#define _TCLWINPORT
-#ifndef _WIN64
+/* 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
#endif
diff --git a/win/tclWinTest.c b/win/tclWinTest.c
index 7f49b63..dd5a60e 100644
--- a/win/tclWinTest.c
+++ b/win/tclWinTest.c
@@ -39,6 +39,8 @@ static int TestwinclockCmd(ClientData dummy, Tcl_Interp* interp,
int objc, Tcl_Obj *const objv[]);
static int TestwinsleepCmd(ClientData dummy, Tcl_Interp* interp,
int objc, Tcl_Obj *const objv[]);
+static int TestSizeCmd(ClientData dummy, Tcl_Interp* interp,
+ int objc, Tcl_Obj *const objv[]);
static Tcl_ObjCmdProc TestExceptionCmd;
static int TestplatformChmod(const char *nativePath, int pmode);
static int TestchmodCmd(ClientData dummy,
@@ -76,6 +78,7 @@ TclplatformtestInit(
Tcl_CreateObjCommand(interp, "testwinclock", TestwinclockCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testwinsleep", TestwinsleepCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testexcept", TestExceptionCmd, NULL, NULL);
+ Tcl_CreateObjCommand(interp, "testsize", TestSizeCmd, NULL, NULL);
return TCL_OK;
}
@@ -309,6 +312,26 @@ TestwinsleepCmd(
return TCL_OK;
}
+static int
+TestSizeCmd(
+ ClientData clientData, /* Unused */
+ Tcl_Interp* interp, /* Tcl interpreter */
+ int objc, /* Parameter count */
+ Tcl_Obj *const * objv) /* Parameter vector */
+{
+ if (objc != 2) {
+ goto syntax;
+ }
+ if (strcmp(Tcl_GetString(objv[1]), "time_t") == 0) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(sizeof(time_t)));
+ return TCL_OK;
+ }
+
+syntax:
+ Tcl_WrongNumArgs(interp, 1, objv, "time_t");
+ return TCL_ERROR;
+}
+
/*
*----------------------------------------------------------------------
*