kernel32: Move GetSystemTimes() implementation to kernelbase.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-05-22 09:15:45 +02:00
parent 7cc9ccbd22
commit 79e3c21c3c
4 changed files with 58 additions and 74 deletions

View File

@ -835,7 +835,7 @@
@ stdcall GetSystemTimeAdjustment(ptr ptr ptr)
@ stdcall -import GetSystemTimeAsFileTime(ptr)
@ stdcall -import GetSystemTimePreciseAsFileTime(ptr)
@ stdcall GetSystemTimes(ptr ptr ptr)
@ stdcall -import GetSystemTimes(ptr ptr ptr)
@ stdcall -import GetSystemWindowsDirectoryA(ptr long)
@ stdcall -import GetSystemWindowsDirectoryW(ptr long)
@ stdcall -import GetSystemWow64DirectoryA(ptr long)

View File

@ -223,77 +223,6 @@ BOOL WINAPI FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
return TRUE;
}
/*********************************************************************
* GetSystemTimes (KERNEL32.@)
*
* Retrieves system timing information
*
* PARAMS
* lpIdleTime [O] Destination for idle time.
* lpKernelTime [O] Destination for kernel time.
* lpUserTime [O] Destination for user time.
*
* RETURNS
* TRUE if success, FALSE otherwise.
*/
BOOL WINAPI GetSystemTimes(LPFILETIME lpIdleTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime)
{
LARGE_INTEGER idle_time, kernel_time, user_time;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *sppi;
SYSTEM_BASIC_INFORMATION sbi;
ULONG ret_size;
int i;
TRACE("(%p,%p,%p)\n", lpIdleTime, lpKernelTime, lpUserTime);
if (!set_ntstatus( NtQuerySystemInformation( SystemBasicInformation, &sbi, sizeof(sbi), &ret_size )))
return FALSE;
sppi = HeapAlloc( GetProcessHeap(), 0,
sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * sbi.NumberOfProcessors);
if (!sppi)
{
SetLastError( ERROR_OUTOFMEMORY );
return FALSE;
}
if (!set_ntstatus( NtQuerySystemInformation( SystemProcessorPerformanceInformation, sppi,
sizeof(*sppi) * sbi.NumberOfProcessors, &ret_size )))
{
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;
}
/******************************************************************************
* GetTickCount64 (KERNEL32.@)
*/

View File

@ -698,7 +698,7 @@
@ stdcall GetSystemTimeAdjustment(ptr ptr ptr) kernel32.GetSystemTimeAdjustment
@ stdcall GetSystemTimeAsFileTime(ptr)
@ stdcall GetSystemTimePreciseAsFileTime(ptr)
@ stdcall GetSystemTimes(ptr ptr ptr) kernel32.GetSystemTimes
@ stdcall GetSystemTimes(ptr ptr ptr)
@ stdcall GetSystemWindowsDirectoryA(ptr long)
@ stdcall GetSystemWindowsDirectoryW(ptr long)
@ stdcall GetSystemWow64Directory2A(ptr long long)

View File

@ -124,10 +124,60 @@ static BOOL get_open_object_attributes( OBJECT_ATTRIBUTES *attr, UNICODE_STRING
/***********************************************************************
* Waits
* Time functions
***********************************************************************/
/*********************************************************************
* GetSystemTimes (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH GetSystemTimes( FILETIME *idle, FILETIME *kernel, FILETIME *user )
{
LARGE_INTEGER idle_time, kernel_time, user_time;
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION *info;
ULONG ret_size;
DWORD i, cpus = NtCurrentTeb()->Peb->NumberOfProcessors;
if (!(info = HeapAlloc( GetProcessHeap(), 0, sizeof(*info) * cpus )))
{
SetLastError( ERROR_OUTOFMEMORY );
return FALSE;
}
if (!set_ntstatus( NtQuerySystemInformation( SystemProcessorPerformanceInformation, info,
sizeof(*info) * cpus, &ret_size )))
{
HeapFree( GetProcessHeap(), 0, info );
return FALSE;
}
idle_time.QuadPart = 0;
kernel_time.QuadPart = 0;
user_time.QuadPart = 0;
for (i = 0; i < cpus; i++)
{
idle_time.QuadPart += info[i].IdleTime.QuadPart;
kernel_time.QuadPart += info[i].KernelTime.QuadPart;
user_time.QuadPart += info[i].UserTime.QuadPart;
}
if (idle)
{
idle->dwLowDateTime = idle_time.u.LowPart;
idle->dwHighDateTime = idle_time.u.HighPart;
}
if (kernel)
{
kernel->dwLowDateTime = kernel_time.u.LowPart;
kernel->dwHighDateTime = kernel_time.u.HighPart;
}
if (user)
{
user->dwLowDateTime = user_time.u.LowPart;
user->dwHighDateTime = user_time.u.HighPart;
}
HeapFree( GetProcessHeap(), 0, info );
return TRUE;
}
/******************************************************************************
* GetTickCount (kernelbase.@)
*/
@ -156,6 +206,11 @@ ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
}
/***********************************************************************
* Waits
***********************************************************************/
static HANDLE normalize_handle_if_console( HANDLE handle )
{
static HANDLE wait_event;