QueryPerformanceFrequency bugfix

Mike Hearn mike at theoretic.com
Sun Jun 29 11:04:40 CDT 2003

On Sun, 29 Jun 2003 17:14:11 +0200, Sir Andreas Mohr scribed thus:
> First, it's 1000000, which is one zero more than what you wrote
> (and what the code used: +1000000.0).
> Second, one MHz *IS* 1000000Hz.

[small voice] i knew that! [/small voice]

   egg -> face :)

> So there are two possibilities:
> a) the code should calculate the result in units of kHz (then your observation
> would be correct)
> b) you are (completely? ;) wrong

  c) Windows doesn't use the RDTSC instruction at all, so never gives
     a frequency that high.

The default response here is 1Mhz, as opposed to the 1299Mhz that Wine
gives the app when RDTSC is available, which seems to make it barf.

The function should return "the current performance-counter frequency, in
counts per second", so Hz is right.

If you look at the disassembly it does (in pseudo-code):

(do something with result)
a = 0
if (result <= 0) a++
b = result / a

so it crashes with a div by zero exception if result is too high at that

I'm not sure how important this is. Does it matter if we tell the app that
the machine has "only" a 1Mhz counter?

Hopefully I will be able to test what this function does on Windows later (but at the
moment I can't get to a copy of VC++) - if somebody feels like beating me
to it, please go ahead.

More information about the wine-devel mailing list