Added FIXME message in PostMessage32x if parameters are truncated
[wine/multimedia.git] / win32 / process.c
blobf18817d28022892201016c07b40ab8a66eca0bab
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 "windows.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 "debug.h"
22 /**********************************************************************
23 * GetProcessAffinityMask
25 BOOL32 WINAPI GetProcessAffinityMask(HANDLE32 hProcess,
26 LPDWORD lpProcessAffinityMask,
27 LPDWORD lpSystemAffinityMask)
29 TRACE(task,"(%x,%lx,%lx)\n",
30 hProcess,(lpProcessAffinityMask?*lpProcessAffinityMask:0),
31 (lpSystemAffinityMask?*lpSystemAffinityMask:0));
32 /* It is definitely important for a process to know on what processor
33 it is running :-) */
34 if(lpProcessAffinityMask)
35 *lpProcessAffinityMask=1;
36 if(lpSystemAffinityMask)
37 *lpSystemAffinityMask=1;
38 return TRUE;
41 /**********************************************************************
42 * SetThreadAffinityMask
43 * Works now like the Windows95 (no MP support) version
45 BOOL32 WINAPI SetThreadAffinityMask(HANDLE32 hThread, DWORD dwThreadAffinityMask)
47 THDB *thdb = THREAD_GetPtr( hThread, THREAD_SET_INFORMATION, NULL );
49 if (!thdb)
50 return FALSE;
51 if (dwThreadAffinityMask!=1) {
52 WARN(thread,"(%d,%ld): only 1 processor supported.\n",
53 (int)hThread,dwThreadAffinityMask);
54 K32OBJ_DecCount((K32OBJ*)thdb);
55 return FALSE;
57 K32OBJ_DecCount((K32OBJ*)thdb);
58 return TRUE;
61 /**********************************************************************
62 * ContinueDebugEvent [KERNEL32.146]
64 BOOL32 WINAPI ContinueDebugEvent(DWORD pid,DWORD tid,DWORD contstatus) {
65 FIXME(win32,"(0x%lx,%ld,%ld): stub\n",pid,tid,contstatus);
66 return TRUE;
69 /*********************************************************************
70 * Process_ClockTimeToFileTime
71 * (olorin@fandra.org, 20-Sep-1998)
72 * Converts clock_t into FILETIME.
73 * Used by GetProcessTime.
74 * Differences to UnixTimeToFileTime:
75 * 1) Divided by CLK_TCK
76 * 2) Time is relative. There is no 'starting date', so there is
77 * no need in offset correction, like in UnixTimeToFileTime
78 * FIXME: This function should be moved to a more appropriate .c file
79 * FIXME: On floating point operations, it is assumed that
80 * floating values are truncated on convertion to integer.
82 void Process_ClockTimeToFileTime( clock_t unix_time, LPFILETIME filetime )
84 double td = (unix_time*10000000.0)/CLK_TCK;
85 /* Yes, double, because long int might overflow here. */
86 #if (SIZEOF_LONG_LONG >= 8)
87 unsigned long long t = td;
88 filetime->dwLowDateTime = (UINT32) t;
89 filetime->dwHighDateTime = (UINT32) (t >> 32);
90 #else
91 double divider = 1. * (1 << 16) * (1 << 16);
92 filetime->dwHighDateTime = (UINT32) (td / divider);
93 filetime->dwLowDateTime = (UINT32) (td - filetime->dwHighDateTime*divider);
94 /* using floor() produces wierd results, better leave this as it is
95 * ( with (UINT32) convertion )
97 #endif
100 /*********************************************************************
101 * GetProcessTimes [KERNEL32.262]
103 * FIXME: lpCreationTime, lpExitTime are NOT INITIALIZED.
104 * olorin@fandra.org: Would be nice to substract the cpu time,
105 * used by Wine at startup.
106 * Also, there is a need to separate times
107 * used by different applications.
109 BOOL32 WINAPI GetProcessTimes(
110 HANDLE32 hprocess,LPFILETIME lpCreationTime,LPFILETIME lpExitTime,
111 LPFILETIME lpKernelTime, LPFILETIME lpUserTime
113 struct tms tms;
115 times(&tms);
116 Process_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
117 Process_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
118 return TRUE;