PerformanceCounterFrequency fix.
Rein Klazes
wijn at wanadoo.nl
Wed Jan 19 07:23:20 CST 2005
Hi,
This fixes a bug reported on the users list. The program (an installer)
crashes on a counter frequency that is less then 1 MHz, according to the
comments in wine's code there are other applications that crash on a
value that is too high. So return a value of 1193182 Hz, which is the
clock of timer0 of any IBM PC compatible and all current Windows PC's
here.
Changelog:
dlls/kernel : cpu.c
Return a fixed frequency of 1193182 Hz for the Performance
Counter.
Rein.
-------------- next part --------------
--- wine/dlls/kernel/cpu.c 2004-12-29 12:09:47.000000000 +0100
+++ mywine/dlls/kernel/cpu.c 2005-01-19 12:39:15.000000000 +0100
@@ -188,7 +188,8 @@ BOOL WINAPI QueryPerformanceCounter(PLAR
/* i586 optimized version */
__asm__ __volatile__ ( "rdtsc"
: "=a" (counter->u.LowPart), "=d" (counter->u.HighPart) );
- counter->QuadPart = counter->QuadPart / 1000; /* see below */
+ /* see below */
+ counter->QuadPart = counter->QuadPart / ( cpuHz / 1193182 ) ;
return TRUE;
}
#endif
@@ -219,10 +220,12 @@ BOOL WINAPI QueryPerformanceFrequency(PL
{
#if defined(__i386__) && defined(__GNUC__)
if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE )) {
- /* The way Windows calculates this value is unclear, however simply using the CPU frequency
- gives a value out by approximately a thousand. That can cause some applications to crash,
- so we divide here to make our number more similar to the one Windows gives */
- frequency->QuadPart = cpuHz / 1000;
+ /* On a standard PC, Windows returns the clock frequency for the
+ * 8253 Programmable Interrupt Timer, which has been 1193182 Hz
+ * since the first IBM PC (cpuHz/4). There are applications that
+ * crash when the returned frequency is much higher or lower, so
+ * do not try to be smart */
+ frequency->QuadPart = 1193182;
return TRUE;
}
#endif
More information about the wine-patches
mailing list