[PATCH] CPU-time clocks
Tue May 17 09:11:00 GMT 2011
On Tue, 2011-05-17 at 07:58 +0200, Corinna Vinschen wrote:
> Thank you. You can apply it, but while I was looking into it,
> this occured to me:
> This conversion arithmetic from FILETIME to long long happens a lot
> in times.cc, even though it's absolutely not necessary.
> The FILETIME struct is actually a LARGE_INTEGER in which just the
> QuadPart member is missing, unfortunately. What we can do is to
> replace the bit shifting stuff with a simple cast:
> x = ((PLARGE_INTEGER) &kernel_time)->QuadPart
> + ((PLARGE_INTEGER) &user_time)->QuadPart;
The MSDN docs on FILETIME state:
> Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER*
> or __int64* value because it can cause alignment faults on 64-bit Windows.
As I am by no means an expert on Win32 programming, I take that at face
> Alternatively we can define kernel_time etc as LARGE_INTEGER and cast in
> the call to GetProcessTimes or just call NtQueryInformationProcess.
I have chosen the latter. Revised patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 12696 bytes
Desc: not available
More information about the Cygwin-patches