summaryrefslogtreecommitdiffstats
path: root/win/tclWinTime.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2004-06-05 17:25:39 (GMT)
committerKevin B Kenny <kennykb@acm.org>2004-06-05 17:25:39 (GMT)
commit76a3df0646c3adbd6aafd8a405b1ea67bf4df521 (patch)
tree617dc620eece18a088428f04a8adc51bba840ae6 /win/tclWinTime.c
parent7cdb9381ace2de8072be890f8225e4bbb21425bd (diff)
downloadtcl-76a3df0646c3adbd6aafd8a405b1ea67bf4df521.zip
tcl-76a3df0646c3adbd6aafd8a405b1ea67bf4df521.tar.gz
tcl-76a3df0646c3adbd6aafd8a405b1ea67bf4df521.tar.bz2
* generic/tcl.h: Corrected Tcl_WideInt declarations so that the mingw
build works again. * generic/tclInt.decls: Changes to the tests for * generic/tclIntPlatDecls.h: clock frequency in Tcl_WinTime * generic/tclStubInit.c: so that any clock frequency * tests/platform.test (platform-1.3): is accepted provided that * win/tclWin32Dll.c (TclWinCPUID): all CPU's in the system share * win/tclWinTest.c (TestwincpuidCmd): a common chip, and hence, * win/tclWinTime.c (Tcl_GetTime): presumably, a common clock. This change necessitated a small burst of assembly code to read CPU ID information, which was added as TclWinCPUID in the internal Stubs. To test this code in the common case of a single-processor machine, a 'testwincpuid' command was added to tclWinTest.c, and a test case in platform.test. Thanks to Jeff Godfrey and Richard Suchenwirth for reporting this bug. [Bug #976722]
Diffstat (limited to 'win/tclWinTime.c')
-rw-r--r--win/tclWinTime.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/win/tclWinTime.c b/win/tclWinTime.c
index faa7a3c..f428d52 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.4 2004/05/17 14:26:50 kennykb Exp $
+ * RCS: @(#) $Id: tclWinTime.c,v 1.14.2.5 2004/06/05 17:25:40 kennykb Exp $
*/
#include "tclWinInt.h"
@@ -311,9 +311,39 @@ Tcl_GetTime(timePtr)
* && timeInfo.nominalFreq.QuadPart != (Tcl_WideInt) 3579545
*/
&& timeInfo.nominalFreq.QuadPart > (Tcl_WideInt) 15000000 ) {
+
+ /*
+ * As an exception, if every logical processor on the system
+ * is on the same chip, we use the performance counter anyway,
+ * presuming that everyone's TSC is locked to the same
+ * oscillator.
+ */
+
+ SYSTEM_INFO systemInfo;
+ unsigned int regs[4];
+ GetSystemInfo( &systemInfo );
+ if ( TclWinCPUID( 0, regs ) == TCL_OK
+
+ && regs[1] == 0x756e6547 /* "Genu" */
+ && regs[3] == 0x49656e69 /* "ineI" */
+ && regs[2] == 0x6c65746e /* "ntel" */
+
+ && TclWinCPUID( 1, regs ) == TCL_OK
+
+ && ( (regs[0] & 0x00000F00) == 0x00000F00 /* Pentium 4 */
+ || ( (regs[0] & 0x00F00000) /* Extended family */
+ && (regs[3] & 0x10000000) ) ) /* Hyperthread */
+ && ( ( ( regs[1] & 0x00FF0000 ) >> 16 ) /* CPU count */
+ == systemInfo.dwNumberOfProcessors )
+
+ ) {
+ timeInfo.perfCounterAvailable = TRUE;
+ } else {
timeInfo.perfCounterAvailable = FALSE;
}
+ }
+
/*
* If the performance counter is available, start a thread to
* calibrate it.