ntdll: Change NtQuerySystemInformation to return 100ns ticks for SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION info class (try 4)
Chris Robinson
chris.kcat at gmail.com
Sun Dec 12 16:57:25 CST 2010
On Sunday, December 12, 2010 2:19:42 pm Louis Lenders wrote:
> +#define USER_HZ_TO_TICKSPERSEC(x,y) (ULONGLONG)10000000 * x / y
I'd recommend adding proper parenthesis, to avoid potential problems with
order-of-operations.
#define USER_HZ_TO_TICKSPERSEC(x,y) ((ULONGLONG)10000000 * (x) / (y))
That way it won't break if you do math in the argument for some reason, like
with
USER_HZ_TO_TICKSPERSEC(val+1, user_hz)
or
USER_HZ_TO_TICKSPERSEC(val, user_hz*2)
> + static long user_hz;
> +
> + user_hz = sysconf(_SC_CLK_TCK);
There's no real point to making it static if you're always going to (re)set
the variable. It would be better to just make the call once:
static long user_hz;
i(user_hz == 0)
user_hz = sysconf(_SC_CLK_TCK);
You could also make it an inline function to avoid making user_hz a parameter:
/* Convert system clock to 100ns tics */
static long user_hz;
static inline ULONGLONG ClockToTics(ULONGLONG val)
{
i(user_hz == 0)
user_hz = sysconf(_SC_CLK_TCK);
return val * 10000000 / user_hz;
}
...
sppi->IdleTime.QuadPart = ClockToTics(idle);
sppi->KernelTime.QuadPart = ClockToTics(sys);
...etc...
Though I'll defer judgement to others as to what's better.
More information about the wine-devel
mailing list