2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis
19 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(win32
)
24 /*********************************************************************
25 * Process_ClockTimeToFileTime
26 * (olorin@fandra.org, 20-Sep-1998)
27 * Converts clock_t into FILETIME.
28 * Used by GetProcessTime.
29 * Differences to UnixTimeToFileTime:
30 * 1) Divided by CLK_TCK
31 * 2) Time is relative. There is no 'starting date', so there is
32 * no need in offset correction, like in UnixTimeToFileTime
33 * FIXME: This function should be moved to a more appropriate .c file
34 * FIXME: On floating point operations, it is assumed that
35 * floating values are truncated on convertion to integer.
37 void Process_ClockTimeToFileTime( clock_t unix_time
, LPFILETIME filetime
)
39 double td
= (unix_time
*10000000.0)/CLK_TCK
;
40 /* Yes, double, because long int might overflow here. */
41 #if SIZEOF_LONG_LONG >= 8
42 unsigned long long t
= td
;
43 filetime
->dwLowDateTime
= (UINT
) t
;
44 filetime
->dwHighDateTime
= (UINT
) (t
>> 32);
46 double divider
= 1. * (1 << 16) * (1 << 16);
47 filetime
->dwHighDateTime
= (UINT
) (td
/ divider
);
48 filetime
->dwLowDateTime
= (UINT
) (td
- filetime
->dwHighDateTime
*divider
);
49 /* using floor() produces wierd results, better leave this as it is
50 * ( with (UINT32) convertion )
55 /*********************************************************************
56 * GetProcessTimes [KERNEL32.262]
58 * FIXME: lpCreationTime, lpExitTime are NOT INITIALIZED.
59 * olorin@fandra.org: Would be nice to substract the cpu time,
60 * used by Wine at startup.
61 * Also, there is a need to separate times
62 * used by different applications.
64 BOOL WINAPI
GetProcessTimes(
65 HANDLE hprocess
,LPFILETIME lpCreationTime
,LPFILETIME lpExitTime
,
66 LPFILETIME lpKernelTime
, LPFILETIME lpUserTime
71 Process_ClockTimeToFileTime(tms
.tms_utime
,lpUserTime
);
72 Process_ClockTimeToFileTime(tms
.tms_stime
,lpKernelTime
);