NtQueryPerformanceCounter should return a frequency of 1193182Hz and

counts like in Windows. Some applications depend on that.
Simplify QueryPerformanceCounter a bit.
This commit is contained in:
Rein Klazes 2005-02-23 20:29:17 +00:00 committed by Alexandre Julliard
parent 494a34bfda
commit 288ebd3244
2 changed files with 16 additions and 7 deletions

View File

@ -192,8 +192,7 @@ static void create_registry_keys( const SYSTEM_INFO *info )
*/
BOOL WINAPI QueryPerformanceCounter(PLARGE_INTEGER counter)
{
LARGE_INTEGER frequency;
NtQueryPerformanceCounter( counter, &frequency );
NtQueryPerformanceCounter( counter, NULL );
return TRUE;
}

View File

@ -37,6 +37,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
/* FIXME: fixed at 2005/2/22 */
static LONGLONG boottime = (LONGLONG)1275356510 * 100000000;
/* Structures used by NtConnectPort */
typedef struct LpcSectionInfo
@ -512,8 +515,10 @@ NTSTATUS WINAPI NtSetIntervalProfile(DWORD x1,DWORD x2) {
/******************************************************************************
* NtQueryPerformanceCounter [NTDLL.@]
*
* Note: Windows uses a timer clocked at a multiple of 1193182 Hz.
*
* Note: Windows uses a timer clocked at a multiple of 1193182 Hz. There is a
* good number of applications that crash when the returned frequency is either
* lower or higher then what Windows gives. Also too high counter values are
* reported to give problems.
*/
NTSTATUS WINAPI NtQueryPerformanceCounter(
OUT PLARGE_INTEGER Counter,
@ -523,9 +528,14 @@ NTSTATUS WINAPI NtQueryPerformanceCounter(
if (!Counter) return STATUS_ACCESS_VIOLATION;
NtQuerySystemTime( &time );
Counter->QuadPart = time.QuadPart;
time.QuadPart -= boottime;
/* convert a counter that increments at a rate of 10 MHz
* to one of 1193182 Hz, with some care for arithmetic
* overflow ( will not overflow until 3396 or so ) and
* good accuracy ( 21/176 = 0.119318182) */
Counter->QuadPart = (time.QuadPart * 21) / 176;
if (Frequency)
Frequency->QuadPart = 10000000;
Frequency->QuadPart = 1193182;
return 0;
}
@ -625,7 +635,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
SYSTEM_TIMEOFDAY_INFORMATION* sti = (SYSTEM_TIMEOFDAY_INFORMATION*)SystemInformation;
if (Length >= sizeof(*sti))
{
sti->liKeBootTime.QuadPart = 0; /* FIXME */
sti->liKeBootTime.QuadPart = boottime;
sti->liKeSystemTime.QuadPart = 0; /* FIXME */
sti->liExpTimeZoneBias.QuadPart = 0; /* FIXME */
sti->uCurrentTimeZoneId = 0; /* FIXME */