wine_openpty is not properly declared (either missing or mismatched
[wine] / win32 / process.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis
5  */
6
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"
20
21
22 /**********************************************************************
23  *  ContinueDebugEvent [KERNEL32.146]
24  */
25 BOOL32 WINAPI ContinueDebugEvent(DWORD pid,DWORD tid,DWORD contstatus) {
26     FIXME(win32,"(0x%lx,%ld,%ld): stub\n",pid,tid,contstatus);
27         return TRUE;
28 }
29
30 /*********************************************************************
31  *      Process_ClockTimeToFileTime
32  *      (olorin@fandra.org, 20-Sep-1998)
33  *      Converts clock_t into FILETIME.
34  *      Used by GetProcessTime.
35  *      Differences to UnixTimeToFileTime:
36  *          1) Divided by CLK_TCK
37  *          2) Time is relative. There is no 'starting date', so there is 
38  *             no need in offset correction, like in UnixTimeToFileTime
39  *      FIXME: This function should be moved to a more appropriate .c file
40  *      FIXME: On floating point operations, it is assumed that
41  *             floating values are truncated on convertion to integer.
42  */
43 void Process_ClockTimeToFileTime( clock_t unix_time, LPFILETIME filetime )
44 {
45     double td = (unix_time*10000000.0)/CLK_TCK;
46     /* Yes, double, because long int might overflow here. */
47 #if (SIZEOF_LONG_LONG >= 8)
48     unsigned long long t = td;
49     filetime->dwLowDateTime  = (UINT32) t;
50     filetime->dwHighDateTime = (UINT32) (t >> 32);
51 #else
52     double divider = 1. * (1 << 16) * (1 << 16);
53     filetime->dwHighDateTime = (UINT32) (td / divider);
54     filetime->dwLowDateTime  = (UINT32) (td - filetime->dwHighDateTime*divider);
55     /* using floor() produces wierd results, better leave this as it is 
56      * ( with (UINT32) convertion )
57      */
58 #endif
59 }
60
61 /*********************************************************************
62  *      GetProcessTimes                         [KERNEL32.262]
63  *
64  * FIXME: lpCreationTime, lpExitTime are NOT INITIALIZED.
65  * olorin@fandra.org: Would be nice to substract the cpu time,
66  *                    used by Wine at startup.
67  *                    Also, there is a need to separate times
68  *                    used by different applications.
69  */
70 BOOL32 WINAPI GetProcessTimes(
71         HANDLE32 hprocess,LPFILETIME lpCreationTime,LPFILETIME lpExitTime,
72         LPFILETIME lpKernelTime, LPFILETIME lpUserTime
73 ) {
74         struct tms tms;
75
76         times(&tms);
77         Process_ClockTimeToFileTime(tms.tms_utime,lpUserTime);
78         Process_ClockTimeToFileTime(tms.tms_stime,lpKernelTime);
79         return TRUE;
80 }
81