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.
This commit is contained in:
parent
7a29b06555
commit
407d863a8a
|
@ -181,22 +181,8 @@ static void create_registry_keys( const SYSTEM_INFO *info )
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
|
BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER time;
|
LARGE_INTEGER frequency;
|
||||||
|
NtQueryPerformanceCounter( counter, &frequency );
|
||||||
#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;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,19 +204,8 @@ BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
|
BOOL WINAPI QueryPerformanceFrequency(PLARGE_INTEGER frequency)
|
||||||
{
|
{
|
||||||
#if defined(__i386__) && defined(__GNUC__)
|
LARGE_INTEGER counter;
|
||||||
if (IsProcessorFeaturePresent( PF_RDTSC_INSTRUCTION_AVAILABLE )) {
|
NtQueryPerformanceCounter( &counter, frequency );
|
||||||
/* 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;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,14 +467,19 @@ NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* NtQueryPerformanceCounter [NTDLL.@]
|
* NtQueryPerformanceCounter [NTDLL.@]
|
||||||
|
*
|
||||||
|
* Note: Windows uses a timer clocked at a multiple of 1193182 Hz.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
NTSTATUS WINAPI NtQueryPerformanceCounter(
|
NTSTATUS WINAPI NtQueryPerformanceCounter(
|
||||||
IN PLARGE_INTEGER Counter,
|
OUT PLARGE_INTEGER Counter,
|
||||||
IN PLARGE_INTEGER Frequency)
|
OUT PLARGE_INTEGER Frequency)
|
||||||
{
|
{
|
||||||
FIXME("(%p, 0%p) stub\n",
|
LARGE_INTEGER time;
|
||||||
Counter, Frequency);
|
NtQuerySystemTime( &time );
|
||||||
return 0;
|
Counter->QuadPart = time.QuadPart;
|
||||||
|
Frequency->QuadPart = 10000000;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -179,7 +179,7 @@
|
||||||
@ stdcall NtQueryMutant(long long ptr long ptr)
|
@ stdcall NtQueryMutant(long long ptr long ptr)
|
||||||
@ stdcall NtQueryObject(long long long long long)
|
@ stdcall NtQueryObject(long long long long long)
|
||||||
@ stub NtQueryOpenSubKeys
|
@ stub NtQueryOpenSubKeys
|
||||||
@ stdcall NtQueryPerformanceCounter (long long)
|
@ stdcall NtQueryPerformanceCounter(ptr ptr)
|
||||||
@ stdcall NtQuerySection (long long long long long)
|
@ stdcall NtQuerySection (long long long long long)
|
||||||
@ stdcall NtQuerySecurityObject (long long long long long)
|
@ stdcall NtQuerySecurityObject (long long long long long)
|
||||||
@ stdcall NtQuerySemaphore (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 NtQueryKey(HKEY,KEY_INFORMATION_CLASS,void *,DWORD,DWORD *);
|
||||||
NTSTATUS WINAPI NtQueryMultipleValueKey(HKEY,PVALENTW,ULONG,PVOID,ULONG,PULONG);
|
NTSTATUS WINAPI NtQueryMultipleValueKey(HKEY,PVALENTW,ULONG,PVOID,ULONG,PULONG);
|
||||||
NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, 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 NtQuerySecurityObject(HANDLE,SECURITY_INFORMATION,PSECURITY_DESCRIPTOR,ULONG,PULONG);
|
||||||
NTSTATUS WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
|
NTSTATUS WINAPI NtQuerySystemInformation(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
|
||||||
NTSTATUS WINAPI NtQuerySystemTime(PLARGE_INTEGER);
|
NTSTATUS WINAPI NtQuerySystemTime(PLARGE_INTEGER);
|
||||||
|
|
Loading…
Reference in New Issue