diff options
Diffstat (limited to 'win/tclWinTime.c')
-rw-r--r-- | win/tclWinTime.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 38523b2..2fc9ea0 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.26 2004/05/14 21:43:29 kennykb Exp $ + * RCS: @(#) $Id: tclWinTime.c,v 1.27 2004/06/05 17:31:08 kennykb Exp $ */ #include "tclInt.h" @@ -309,7 +309,37 @@ Tcl_GetTime(timePtr) * && timeInfo.nominalFreq.QuadPart != (Tcl_WideInt) 3579545 */ && timeInfo.nominalFreq.QuadPart > (Tcl_WideInt) 15000000 ) { - timeInfo.perfCounterAvailable = FALSE; + + /* + * 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; + } + } /* |