From 47fe8809243ccbf15458c02b61d0b496aa477032 Mon Sep 17 00:00:00 2001 From: Rein Klazes Date: Wed, 19 Jan 2005 17:01:06 +0000 Subject: [PATCH] Return a fixed frequency of 1193182 Hz for the Performance Counter. --- dlls/kernel/cpu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dlls/kernel/cpu.c b/dlls/kernel/cpu.c index 90fd6eb829..224bbcd6d6 100644 --- a/dlls/kernel/cpu.c +++ b/dlls/kernel/cpu.c @@ -188,7 +188,8 @@ BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter) /* 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(PLARGE_INTEGER frequency) { #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