Store monitor size and depth in the generic structure.
[wine/multimedia.git] / win32 / process.c
blob6a3a894a7895b46ef972918d57c90198c727d57f
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis
5 */
7 #include <string.h>
8 #include <unistd.h>
9 #include <sys/times.h>
10 #include "winbase.h"
11 #include "winerror.h"
12 #include "heap.h"
13 #include "thread.h"
14 #include "process.h"
15 #include "pe_image.h"
16 #include "file.h"
17 #include "task.h"
18 #include "toolhelp.h"
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 conversion 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);
45 #else
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 )
52 #endif
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
67 ) {
68 struct tms tms;
70 times(&tms);
71 Process_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
72 Process_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
73 return TRUE;