mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
111 lines
4.3 KiB
Diff
111 lines
4.3 KiB
Diff
From c3acb24297b1b4e41746ba13f7e997bbe7e0c64a 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 dde9f5d..fe459e4 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
|
|
|