[PATCH] CPU-time clocks
Yaakov (Cygwin/X)
yselkowitz@users.sourceforge.net
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[1] 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
value.
> 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.
Yaakov
[1] http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cpuclockid.patch
Type: text/x-patch
Size: 12696 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20110517/a1869cf3/attachment.bin>
More information about the Cygwin-patches
mailing list