wine-staging/patches/kernel32-GetSystemTimes/0002-kernel32-Implement-GetSystemTimes.patch

111 lines
4.3 KiB
Diff
Raw Normal View History

From c7d23fced92e26c724cdeb389f827c436294b05d Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Sun, 27 Jul 2014 12:38:29 -0600
Subject: kernel32: Implement GetSystemTimes.
---
dlls/kernel32/tests/time.c | 12 +++++------
dlls/kernel32/time.c | 51 ++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/dlls/kernel32/tests/time.c b/dlls/kernel32/tests/time.c
index 6f5c03d..d3d3939 100644
--- a/dlls/kernel32/tests/time.c
+++ b/dlls/kernel32/tests/time.c
@@ -751,13 +751,13 @@ static void test_GetSystemTimes(void)
return;
}
- todo_wine ok( pGetSystemTimes(NULL, NULL, NULL), "GetSystemTimes failed unexpectedly\n" );
+ ok( pGetSystemTimes(NULL, NULL, NULL), "GetSystemTimes failed unexpectedly\n" );
memset( &idletime, 0x0, sizeof(idletime) );
memset( &kerneltime, 0x0, sizeof(kerneltime) );
memset( &usertime, 0x0, sizeof(usertime) );
- todo_wine ok( pGetSystemTimes(&idletime, &kerneltime , &usertime),
- "GetSystemTimes failed unexpectedly\n" );
+ ok( pGetSystemTimes(&idletime, &kerneltime , &usertime),
+ "GetSystemTimes failed unexpectedly\n" );
ul1.LowPart = idletime.dwLowDateTime;
ul1.HighPart = idletime.dwHighDateTime;
@@ -801,9 +801,9 @@ static void test_GetSystemTimes(void)
trace( "total_idletime %f total_kerneltime %f total_usertime %f \n", total_idletime,
total_kerneltime, total_usertime );
- todo_wine ok( (total_idletime - (double)ul1.QuadPart/10000000.0) < 1.0, "test idletime failed\n" );
- todo_wine ok( (total_kerneltime - (double)ul2.QuadPart/10000000.0) < 1.0, "test kerneltime failed\n" );
- todo_wine ok( (total_usertime - (double)ul3.QuadPart/10000000.0) < 1.0, "test usertime failed\n" );
+ ok( (total_idletime - (double)ul1.QuadPart/10000000.0) < 1.0, "test idletime failed\n" );
+ ok( (total_kerneltime - (double)ul2.QuadPart/10000000.0) < 1.0, "test kerneltime failed\n" );
+ ok( (total_usertime - (double)ul3.QuadPart/10000000.0) < 1.0, "test usertime failed\n" );
HeapFree(GetProcessHeap(), 0, sppi);
}
diff --git a/dlls/kernel32/time.c b/dlls/kernel32/time.c
index 21ac120..0100dd0 100644
--- a/dlls/kernel32/time.c
+++ b/dlls/kernel32/time.c
@@ -1090,9 +1090,56 @@ BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
*/
BOOL WINAPI GetSystemTimes(LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime)
{
- FIXME("(%p,%p,%p): Stub!\n", lpIdleTime, lpKernelTime, lpUserTime);
+ LARGE_INTEGER idle_time, kernel_time, user_time;
+ SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi;
+ SYSTEM_BASIC_INFORMATION sbi;
+ NTSTATUS status;
+ ULONG ret_size;
+ int i;
+
+ TRACE("(%p,%p,%p)\n", lpIdleTime, lpKernelTime, lpUserTime);
+
+
+ status = NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), &ret_size );
+ if (status != STATUS_SUCCESS) return FALSE;
+
+ sppi = HeapAlloc( GetProcessHeap(), 0,
+ sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * sbi.NumberOfProcessors);
- return FALSE;
+
+ status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi, sizeof(*sppi),
+ &ret_size);
+ if (status != STATUS_SUCCESS)
+ {
+ HeapFree( GetProcessHeap(), 0, sppi );
+ return FALSE;
+ }
+ idle_time.QuadPart = 0;
+ kernel_time.QuadPart = 0;
+ user_time.QuadPart = 0;
+ for (i = 0; i < sbi.NumberOfProcessors; i++)
+ {
+ idle_time.QuadPart += sppi[i].IdleTime.QuadPart;
+ kernel_time.QuadPart += sppi[i].KernelTime.QuadPart;
+ user_time.QuadPart += sppi[i].UserTime.QuadPart;
+ }
+ if (lpIdleTime)
+ {
+ lpIdleTime->dwLowDateTime += idle_time.u.LowPart;
+ lpIdleTime->dwHighDateTime += idle_time.u.HighPart;
+ }
+ if (lpKernelTime)
+ {
+ lpKernelTime->dwLowDateTime += kernel_time.u.LowPart;
+ lpKernelTime->dwHighDateTime += kernel_time.u.HighPart;
+ }
+ if (lpUserTime)
+ {
+ lpUserTime->dwLowDateTime += user_time.u.LowPart;
+ lpUserTime->dwHighDateTime += user_time.u.HighPart;
+ }
+ HeapFree( GetProcessHeap(), 0, sppi );
+ return TRUE;
}
/***********************************************************************
--
1.7.9.5