Get rid of the rdtsc cpu instruction method for calculation of the
authorRein Klazes <wijn@wanadoo.nl>
Wed, 26 Jan 2005 20:41:36 +0000 (20:41 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 26 Jan 2005 20:41:36 +0000 (20:41 +0000)
performance counter. Put the calculation (based on gettimeofday) in
NtQueryPerformanceCounter() and use that in the kernel functions.

dlls/kernel/cpu.c
dlls/ntdll/nt.c
dlls/ntdll/ntdll.spec
include/winternl.h

index 224bbcd6d677cb3f63b250a0fe61ff7d753e15f4..93610d0c70676550b78c4ffdd3a9dcc4fc0b5297 100644 (file)
@@ -181,22 +181,8 @@ static void create_registry_keys( const SYSTEM_INFO *info )
  */
 BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
 {
-    LARGE_INTEGER time;
-
-#if defined(__i386__) && defined(__GNUC__)
-    if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE )) {
-       /* i586 optimized version */
-       __asm__ __volatile__ ( "rdtsc"
-                              : "=a" (counter->u.LowPart), "=d" (counter->u.HighPart) );
-        /* see below */
-       counter->QuadPart = counter->QuadPart / ( cpuHz / 1193182 ) ;
-       return TRUE;
-    }
-#endif
-
-    /* fall back to generic routine (ie, for i386, i486) */
-    NtQuerySystemTime( &time );
-    counter->QuadPart = time.QuadPart;
+    LARGE_INTEGER frequency;
+    NtQueryPerformanceCounter( counter, &frequency );
     return TRUE;
 }
 
@@ -218,19 +204,8 @@ BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
  */
 BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
 {
-#if defined(__i386__) && defined(__GNUC__)
-    if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE )) {
-        /* 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
-    frequency->u.LowPart  = 10000000;
-    frequency->u.HighPart = 0;
+    LARGE_INTEGER counter;
+    NtQueryPerformanceCounter( &counter, frequency );
     return TRUE;
 }
 
index 670f32c62738659bd39021a94c26840bc21224a9..0e0b488c6afed575d5e438c3247af9c1a592dd1c 100644 (file)
@@ -467,14 +467,19 @@ NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
 
 /******************************************************************************
  *  NtQueryPerformanceCounter  [NTDLL.@]
+ *
+ *  Note: Windows uses a timer clocked at a multiple of 1193182 Hz.
+ *  
  */
 NTSTATUS WINAPI NtQueryPerformanceCounter(
-       IN PLARGE_INTEGER Counter,
-       IN PLARGE_INTEGER Frequency)
+       OUT PLARGE_INTEGER Counter,
+       OUT PLARGE_INTEGER Frequency)
 {
-       FIXME("(%p, 0%p) stub\n",
-       Counter, Frequency);
-       return 0;
+    LARGE_INTEGER time;
+    NtQuerySystemTime( &time );
+    Counter->QuadPart = time.QuadPart;
+    Frequency->QuadPart = 10000000;
+    return 0;
 }
 
 /******************************************************************************
index 7118a304904eb118461ed5089f32cda84f319dd8..128ce00f48a7b259bcc442a8c4502484ec8271fb 100644 (file)
 @ stdcall NtQueryMutant(long long ptr long ptr)
 @ stdcall NtQueryObject(long long long long long)
 @ stub NtQueryOpenSubKeys
-@ stdcall NtQueryPerformanceCounter (long long)
+@ stdcall NtQueryPerformanceCounter(ptr ptr)
 @ stdcall NtQuerySection (long long long long long)
 @ stdcall NtQuerySecurityObject (long long long long long)
 @ stdcall NtQuerySemaphore (long long long long long)
index bccdb3d96ed8825bce77058510728730df77dc4e..b041a8e5e8a2803757571fafdc03d6600c99ef64 100644 (file)
@@ -1412,6 +1412,7 @@ NTSTATUS  WINAPI NtQueryInstallUILanguage(LANGID*);
 NTSTATUS  WINAPI NtQueryKey(HKEY,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
 NTSTATUS  WINAPI NtQueryMultipleValueKey(HKEY,PVALENTW,ULONG,PVOID,ULONG,PULONG);
 NTSTATUS  WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG);
+NTSTATUS  WINAPI NtQueryPerformanceCounter(PLARGE_INTEGER, PLARGE_INTEGER);
 NTSTATUS  WINAPI NtQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
 NTSTATUS  WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
 NTSTATUS  WINAPI NtQuerySystemTime(PLARGE_INTEGER);