From c5500b60350f48a5de2b1217fa38cc678511a329 Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Thu, 17 Dec 2020 15:44:01 +0000
Subject: Simplifications when assuming VS 2015 or later

---
 generic/tcl.h           |  2 +-
 generic/tclCmdMZ.c      | 14 +++++++-------
 generic/tclInt.h        |  7 -------
 generic/tclMain.c       |  5 -----
 generic/tclThreadTest.c |  2 +-
 win/nmakehlp.c          |  9 ---------
 win/tclWin32Dll.c       |  8 --------
 win/tclWinPort.h        | 16 +++-------------
 8 files changed, 12 insertions(+), 51 deletions(-)

diff --git a/generic/tcl.h b/generic/tcl.h
index 72f9bed..e0bc708 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -361,7 +361,7 @@ typedef long LONG;
 
 #if !defined(TCL_WIDE_INT_TYPE)&&!defined(TCL_WIDE_INT_IS_LONG)
 #   if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
-#      define TCL_WIDE_INT_TYPE __int64
+#      define TCL_WIDE_INT_TYPE long long
 #      define TCL_LL_MODIFIER	"I64"
 #      if defined(_WIN64)
 #         define TCL_Z_MODIFIER	"I"
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 3906810..d020a93 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4148,14 +4148,14 @@ Tcl_TimeRateObjCmd(
     Tcl_Obj *objPtr;
     int result, i;
     Tcl_Obj *calibrate = NULL, *direct = NULL;
-    TclWideMUInt count = 0;	/* Holds repetition count */
+    Tcl_WideUInt count = 0;	/* Holds repetition count */
     Tcl_WideInt maxms = WIDE_MIN;
 				/* Maximal running time (in milliseconds) */
-    TclWideMUInt maxcnt = WIDE_MAX;
+    Tcl_WideUInt maxcnt = WIDE_MAX;
 				/* Maximal count of iterations. */
-    TclWideMUInt threshold = 1;	/* Current threshold for check time (faster
+    Tcl_WideUInt threshold = 1;	/* Current threshold for check time (faster
 				 * repeat count without time check) */
-    TclWideMUInt maxIterTm = 1;	/* Max time of some iteration as max
+    Tcl_WideUInt maxIterTm = 1;	/* Max time of some iteration as max
 				 * threshold, additionally avoiding divide to
 				 * zero (i.e., never < 1) */
     unsigned short factor = 50;	/* Factor (4..50) limiting threshold to avoid
@@ -4529,13 +4529,13 @@ Tcl_TimeRateObjCmd(
 
     {
 	Tcl_Obj *objarr[8], **objs = objarr;
-	TclWideMUInt usec, val;
+	Tcl_WideUInt usec, val;
 	int digits;
 
 	/*
 	 * Absolute execution time in microseconds or in wide clicks.
 	 */
-	usec = (TclWideMUInt)(middle - start);
+	usec = (Tcl_WideUInt)(middle - start);
 
 #ifdef TCL_WIDE_CLICKS
 	/*
@@ -4565,7 +4565,7 @@ Tcl_TimeRateObjCmd(
 		 * Estimate the time of overhead (microsecs).
 		 */
 
-		TclWideMUInt curOverhead = overhead * count;
+		Tcl_WideUInt curOverhead = overhead * count;
 
 		if (usec > curOverhead) {
 		    usec -= curOverhead;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 8088d0e..dbb06cd 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3280,13 +3280,6 @@ MODULE_SCOPE void	TclInitThreadStorage(void);
 MODULE_SCOPE void	TclFinalizeThreadDataThread(void);
 MODULE_SCOPE void	TclFinalizeThreadStorage(void);
 
-/* TclWideMUInt -- wide integer used for measurement calculations: */
-#if (!defined(_WIN32) || !defined(_MSC_VER) || (_MSC_VER >= 1400))
-#   define TclWideMUInt Tcl_WideUInt
-#else
-/* older MSVS may not allow conversions between unsigned __int64 and double) */
-#   define TclWideMUInt Tcl_WideInt
-#endif
 #ifdef TCL_WIDE_CLICKS
 MODULE_SCOPE Tcl_WideInt TclpGetWideClicks(void);
 MODULE_SCOPE double	TclpWideClicksToNanoseconds(Tcl_WideInt clicks);
diff --git a/generic/tclMain.c b/generic/tclMain.c
index 13231b5..bb48dbb 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -64,11 +64,6 @@ NewNativeObj(
  * source directory to make their own modified versions).
  */
 
-#if defined _MSC_VER && _MSC_VER < 1900
-/* isatty is always defined on MSVC 14.0, but not necessarily as CRTIMPORT. */
-extern CRTIMPORT int	isatty(int fd);
-#endif
-
 /*
  * The thread-local variables for this file's functions.
  */
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index c484fb6..cbffb0d 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -370,7 +370,7 @@ ThreadObjCmd(
 	} else {
 	    char buf[20];
 
-	    sprintf(buf, "%" TCL_LL_MODIFIER "d", id);
+	    sprintf(buf, "%lld", id);
 	    Tcl_AppendResult(interp, "cannot join thread ", buf, NULL);
 	}
 	return result;
diff --git a/win/nmakehlp.c b/win/nmakehlp.c
index 7536ede..972e8b9 100644
--- a/win/nmakehlp.c
+++ b/win/nmakehlp.c
@@ -19,15 +19,6 @@
 #include <stdio.h>
 #include <math.h>
 
-/*
- * This library is required for x64 builds with _some_ versions of MSVC
- */
-#if defined(_M_IA64) || defined(_M_AMD64)
-#if _MSC_VER >= 1400 && _MSC_VER < 1500
-#pragma comment(lib, "bufferoverflowU")
-#endif
-#endif
-
 /* ISO hack for dumb VC++ */
 #ifdef _MSC_VER
 #define   snprintf	_snprintf
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index cbcb3ed..d658ce4 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -25,14 +25,6 @@
 static HINSTANCE hInstance;	/* HINSTANCE of this DLL. */
 
 /*
- * VC++ 5.x has no 'cpuid' assembler instruction, so we must emulate it
- */
-
-#if defined(_MSC_VER) && (_MSC_VER <= 1100) && defined (_M_IX86)
-#define cpuid	__asm __emit 0fh __asm __emit 0a2h
-#endif
-
-/*
  * The following declaration is for the VC++ DLL entry point.
  */
 
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index 2c52b73..e497a23 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -454,12 +454,9 @@ typedef DWORD_PTR * PDWORD_PTR;
 
 #if defined(_MSC_VER) || defined(__MSVCRT__)
 #   define environ _environ
-#   if defined(_MSC_VER) && (_MSC_VER < 1600)
-#	define hypot _hypot
-#   endif
 #   define exception _exception
 #   undef EDEADLOCK
-#   if defined(_MSC_VER) && (_MSC_VER >= 1700)
+#   if defined(_MSC_VER)
 #	define timezone _timezone
 #   endif
 #endif /* _MSC_VER || __MSVCRT__ */
@@ -480,18 +477,11 @@ typedef DWORD_PTR * PDWORD_PTR;
 #endif
 
 
-/*
- * MSVC 8.0 started to mark many standard C library functions depreciated
- * including the *printf family and others. Tell it to shut up.
- * (_MSC_VER is 1200 for VC6, 1300 or 1310 for vc7.net, 1400 for 8.0)
- */
 #if defined(_MSC_VER)
 #   pragma warning(disable:4146)
 #   pragma warning(disable:4244)
-#   if _MSC_VER >= 1400
-#	pragma warning(disable:4267)
-#	pragma warning(disable:4996)
-#   endif
+#   pragma warning(disable:4267)
+#   pragma warning(disable:4996)
 #endif
 
 /*
-- 
cgit v0.12