+ if( freq == I64C(-1) )
+ {
+ /* Extract from the Tcl source code:
+ * (http://www.cs.man.ac.uk/fellowsd-bin/TIP/7.html)
+ *
+ * Some hardware abstraction layers use the CPU clock
+ * in place of the real-time clock as a performance counter
+ * reference. This results in:
+ * - inconsistent results among the processors on
+ * multi-processor systems.
+ * - unpredictable changes in performance counter frequency
+ * on "gearshift" processors such as Transmeta and
+ * SpeedStep.
+ * There seems to be no way to test whether the performance
+ * counter is reliable, but a useful heuristic is that
+ * if its frequency is 1.193182 MHz or 3.579545 MHz, it's
+ * derived from a colorburst crystal and is therefore
+ * the RTC rather than the TSC. If it's anything else, we
+ * presume that the performance counter is unreliable.
+ */
+
+ freq = ( QueryPerformanceFrequency( (LARGE_INTEGER *)&freq ) &&
+ (freq == I64C(1193182) || freq == I64C(3579545) ) )
+ ? freq : 0;
+ }
+
+ if( freq != 0 )