Commit 5926cea7 authored by Alexandre Julliard's avatar Alexandre Julliard

Partially implemented kernel/user times in GetThreadTimes (based on a

patch by Ryan Cumming).
parent 374a7abd
......@@ -481,13 +481,11 @@ VOID test_GetThreadTimes(DWORD version)
"creationTime was invalid");
ok(exitTime.dwLowDateTime!=99 || exitTime.dwHighDateTime!=99,
"exitTime was invalid");
todo_wine {
ok(kernelTime.dwLowDateTime!=99 || kernelTime.dwHighDateTime!=99,
"kernelTime was invalid");
ok(userTime.dwLowDateTime!=99 || userTime.dwHighDateTime!=99,
"userTime was invalid");
}
ok(CloseHandle(thread)!=0,"ClosewHandle failed");
ok(kernelTime.dwLowDateTime!=99 || kernelTime.dwHighDateTime!=99,
"kernelTime was invalid");
ok(userTime.dwLowDateTime!=99 || userTime.dwHighDateTime!=99,
"userTime was invalid");
ok(CloseHandle(thread)!=0,"CloseHandle failed");
}
/* Check the processor affinity functions */
......
......@@ -27,6 +27,9 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
......@@ -709,6 +712,37 @@ BOOL WINAPI GetThreadTimes(
}
SERVER_END_REQ;
}
if (ret && (kerneltime || usertime))
{
/* We call times(2) for kernel time or user time */
/* We can only (portably) do this for the current thread */
if (thread == GetCurrentThread())
{
ULONGLONG time;
struct tms time_buf;
long clocks_per_sec = sysconf(_SC_CLK_TCK);
times(&time_buf);
if (kerneltime)
{
time = (ULONGLONG)time_buf.tms_stime * 10000000 / clocks_per_sec;
kerneltime->dwHighDateTime = time >> 32;
kerneltime->dwLowDateTime = (DWORD)time;
}
if (usertime)
{
time = (ULONGLONG)time_buf.tms_utime * 10000000 / clocks_per_sec;
usertime->dwHighDateTime = time >> 32;
usertime->dwLowDateTime = (DWORD)time;
}
}
else
{
if (kerneltime) kerneltime->dwHighDateTime = kerneltime->dwLowDateTime = 0;
if (usertime) usertime->dwHighDateTime = usertime->dwLowDateTime = 0;
FIXME("Cannot get kerneltime or usertime of other threads\n");
}
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment