2014-09-09 07:36:13 -07:00
|
|
|
From eaccccc716b398e0841c5f2e7de5ba6cea3666ab Mon Sep 17 00:00:00 2001
|
2014-07-27 11:54:01 -07:00
|
|
|
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
|
|
|
|
Date: Sun, 27 Jul 2014 12:38:29 -0600
|
|
|
|
Subject: kernel32: Implement GetSystemTimes.
|
|
|
|
|
|
|
|
---
|
2014-09-09 07:36:13 -07:00
|
|
|
dlls/kernel32/tests/time.c | 12 ++++-----
|
|
|
|
dlls/kernel32/time.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
|
2 files changed, 66 insertions(+), 8 deletions(-)
|
2014-07-27 11:54:01 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/kernel32/tests/time.c b/dlls/kernel32/tests/time.c
|
2014-09-09 07:14:39 -07:00
|
|
|
index c524343..63ab35a 100644
|
2014-07-27 11:54:01 -07:00
|
|
|
--- a/dlls/kernel32/tests/time.c
|
|
|
|
+++ b/dlls/kernel32/tests/time.c
|
2014-08-08 15:13:19 -07:00
|
|
|
@@ -751,13 +751,13 @@ static void test_GetSystemTimes(void)
|
2014-07-27 11:54:01 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- todo_wine ok( pGetSystemTimes(NULL, NULL, NULL), "GetSystemTimes failed unexpectedly\n" );
|
|
|
|
+ ok( pGetSystemTimes(NULL, NULL, NULL), "GetSystemTimes failed unexpectedly\n" );
|
2014-08-21 08:23:49 -07:00
|
|
|
|
2014-09-09 07:14:39 -07:00
|
|
|
memset( &idletime, 0x11, sizeof(idletime) );
|
|
|
|
memset( &kerneltime, 0x11, sizeof(kerneltime) );
|
|
|
|
memset( &usertime, 0x11, sizeof(usertime) );
|
2014-07-27 11:54:01 -07:00
|
|
|
- todo_wine ok( pGetSystemTimes(&idletime, &kerneltime , &usertime),
|
|
|
|
- "GetSystemTimes failed unexpectedly\n" );
|
|
|
|
+ ok( pGetSystemTimes(&idletime, &kerneltime , &usertime),
|
|
|
|
+ "GetSystemTimes failed unexpectedly\n" );
|
2014-08-21 08:23:49 -07:00
|
|
|
|
2014-07-27 11:54:01 -07:00
|
|
|
ul1.LowPart = idletime.dwLowDateTime;
|
|
|
|
ul1.HighPart = idletime.dwHighDateTime;
|
2014-09-09 07:14:39 -07:00
|
|
|
@@ -800,9 +800,9 @@ static void test_GetSystemTimes(void)
|
2014-07-27 11:54:01 -07:00
|
|
|
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
|
2014-09-09 07:36:13 -07:00
|
|
|
index 21ac120..b877adc 100644
|
2014-07-27 11:54:01 -07:00
|
|
|
--- a/dlls/kernel32/time.c
|
|
|
|
+++ b/dlls/kernel32/time.c
|
2014-09-09 07:36:13 -07:00
|
|
|
@@ -1090,9 +1090,67 @@ BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
|
2014-07-27 11:54:01 -07:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
+
|
2014-07-27 12:12:46 -07:00
|
|
|
+ TRACE("(%p,%p,%p)\n", lpIdleTime, lpKernelTime, lpUserTime);
|
2014-07-27 11:54:01 -07:00
|
|
|
+
|
|
|
|
+ status = NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), &ret_size );
|
2014-09-09 07:36:13 -07:00
|
|
|
+ if (status != STATUS_SUCCESS)
|
|
|
|
+ {
|
|
|
|
+ SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
2014-07-27 11:54:01 -07:00
|
|
|
|
|
|
|
- return FALSE;
|
2014-09-09 07:14:39 -07:00
|
|
|
+ sppi = HeapAlloc( GetProcessHeap(), 0,
|
|
|
|
+ sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * sbi.NumberOfProcessors);
|
|
|
|
+ if (!sppi)
|
|
|
|
+ {
|
|
|
|
+ SetLastError( ERROR_OUTOFMEMORY );
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
2014-07-27 11:54:01 -07:00
|
|
|
+
|
2014-11-05 18:13:28 -08:00
|
|
|
+ status = NtQuerySystemInformation( SystemProcessorPerformanceInformation, sppi, sizeof(*sppi) * sbi.NumberOfProcessors,
|
2014-09-09 07:36:13 -07:00
|
|
|
+ &ret_size );
|
2014-07-27 11:54:01 -07:00
|
|
|
+ if (status != STATUS_SUCCESS)
|
|
|
|
+ {
|
|
|
|
+ HeapFree( GetProcessHeap(), 0, sppi );
|
2014-09-09 07:36:13 -07:00
|
|
|
+ SetLastError( RtlNtStatusToDosError(status) );
|
2014-07-27 11:54:01 -07:00
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
2014-09-09 07:36:13 -07:00
|
|
|
+
|
2014-07-27 11:54:01 -07:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2014-09-09 07:14:39 -07:00
|
|
|
+
|
2014-07-27 11:54:01 -07:00
|
|
|
+ if (lpIdleTime)
|
|
|
|
+ {
|
2014-09-09 07:14:39 -07:00
|
|
|
+ lpIdleTime->dwLowDateTime = idle_time.u.LowPart;
|
|
|
|
+ lpIdleTime->dwHighDateTime = idle_time.u.HighPart;
|
2014-07-27 11:54:01 -07:00
|
|
|
+ }
|
|
|
|
+ if (lpKernelTime)
|
|
|
|
+ {
|
2014-09-09 07:14:39 -07:00
|
|
|
+ lpKernelTime->dwLowDateTime = kernel_time.u.LowPart;
|
|
|
|
+ lpKernelTime->dwHighDateTime = kernel_time.u.HighPart;
|
2014-07-27 11:54:01 -07:00
|
|
|
+ }
|
|
|
|
+ if (lpUserTime)
|
|
|
|
+ {
|
2014-09-09 07:14:39 -07:00
|
|
|
+ lpUserTime->dwLowDateTime = user_time.u.LowPart;
|
|
|
|
+ lpUserTime->dwHighDateTime = user_time.u.HighPart;
|
2014-07-27 11:54:01 -07:00
|
|
|
+ }
|
2014-09-09 07:14:39 -07:00
|
|
|
+
|
2014-07-27 11:54:01 -07:00
|
|
|
+ HeapFree( GetProcessHeap(), 0, sppi );
|
|
|
|
+ return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
--
|
2014-09-09 07:14:39 -07:00
|
|
|
2.1.0
|
2014-07-27 11:54:01 -07:00
|
|
|
|