Commit 407d863a authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

Get rid of the rdtsc cpu instruction method for calculation of the

performance counter. Put the calculation (based on gettimeofday) in NtQueryPerformanceCounter() and use that in the kernel functions.
parent 7a29b065
......@@ -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;
}
......
......@@ -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;
}
/******************************************************************************
......
......@@ -179,7 +179,7 @@
@ 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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment