From 60cb1aebd896abbbc624dc3da93efa675fca8032 Mon Sep 17 00:00:00 2001 From: Tom Lally Date: Thu, 1 Sep 2022 19:13:49 +0100 Subject: [PATCH] Use Cemu basic types. --- src/util/SystemInfo/SystemInfo.cpp | 6 +++--- src/util/SystemInfo/SystemInfo.h | 14 +++++++------- src/util/SystemInfo/SystemInfoUnix.cpp | 18 +++++++++--------- src/util/SystemInfo/SystemInfoWin.cpp | 8 ++++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/util/SystemInfo/SystemInfo.cpp b/src/util/SystemInfo/SystemInfo.cpp index 54f7e10e..fa7d8ecd 100644 --- a/src/util/SystemInfo/SystemInfo.cpp +++ b/src/util/SystemInfo/SystemInfo.cpp @@ -1,11 +1,11 @@ #include "util/SystemInfo/SystemInfo.h" -uint64_t ProcessorTime::work() +uint64 ProcessorTime::work() { return user + kernel; } -uint64_t ProcessorTime::total() +uint64 ProcessorTime::total() { return idle + user + kernel; } @@ -20,7 +20,7 @@ double ProcessorTime::Compare(ProcessorTime &last, ProcessorTime &now) void QueryProcTime(ProcessorTime &out) { - uint64_t now, user, kernel; + uint64 now, user, kernel; QueryProcTime(now, user, kernel); out.idle = now - (user + kernel); diff --git a/src/util/SystemInfo/SystemInfo.h b/src/util/SystemInfo/SystemInfo.h index 14bb0f38..1b140380 100644 --- a/src/util/SystemInfo/SystemInfo.h +++ b/src/util/SystemInfo/SystemInfo.h @@ -2,16 +2,16 @@ struct ProcessorTime { - uint64_t idle{}, kernel{}, user{}; + uint64 idle{}, kernel{}, user{}; - uint64_t work(); - uint64_t total(); + uint64 work(); + uint64 total(); static double Compare(ProcessorTime &last, ProcessorTime &now); }; -uint32_t GetProcessorCount(); -uint64_t QueryRamUsage(); -void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel); +uint32 GetProcessorCount(); +uint64 QueryRamUsage(); +void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel); void QueryProcTime(ProcessorTime &out); -void QueryCoreTimes(uint32_t count, ProcessorTime out[]); \ No newline at end of file +void QueryCoreTimes(uint32 count, ProcessorTime out[]); \ No newline at end of file diff --git a/src/util/SystemInfo/SystemInfoUnix.cpp b/src/util/SystemInfo/SystemInfoUnix.cpp index fd29956d..3127e6a7 100644 --- a/src/util/SystemInfo/SystemInfoUnix.cpp +++ b/src/util/SystemInfo/SystemInfoUnix.cpp @@ -7,42 +7,42 @@ #include -uint32_t GetProcessorCount() +uint32 GetProcessorCount() { return std::thread::hardware_concurrency(); } -uint64_t QueryRamUsage() +uint64 QueryRamUsage() { long page_size = sysconf(_SC_PAGESIZE); std::ifstream file("/proc/self/statm"); file.ignore(std::numeric_limits::max(), ' '); - uint64_t no_pages; + uint64 no_pages; file >> no_pages; return no_pages * page_size; } -void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel) +void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel) { struct tms time_info; clock_t clock_now = times(&time_info); clock_t clock_user = time_info.tms_utime; clock_t clock_kernel = time_info.tms_stime; - out_now = static_cast(clock_now); - out_user = static_cast(clock_user); - out_kernel = static_cast(clock_kernel); + out_now = static_cast(clock_now); + out_user = static_cast(clock_user); + out_kernel = static_cast(clock_kernel); } -void QueryCoreTimes(uint32_t count, ProcessorTime out[]) +void QueryCoreTimes(uint32 count, ProcessorTime out[]) { std::ifstream file("/proc/stat"); file.ignore(std::numeric_limits::max(), '\n'); for (auto i = 0; i < count; ++i) { - uint64_t user, nice, kernel, idle; + uint64 user, nice, kernel, idle; file.ignore(std::numeric_limits::max(), ' '); file >> user >> nice >> kernel >> idle; file.ignore(std::numeric_limits::max(), '\n'); diff --git a/src/util/SystemInfo/SystemInfoWin.cpp b/src/util/SystemInfo/SystemInfoWin.cpp index a9b43d25..f955d4af 100644 --- a/src/util/SystemInfo/SystemInfoWin.cpp +++ b/src/util/SystemInfo/SystemInfoWin.cpp @@ -6,14 +6,14 @@ #include #pragma comment(lib, "ntdll.lib") -uint32_t GetProcessorCount() +uint32 GetProcessorCount() { SYSTEM_INFO sys_info; GetSystemInfo(&sys_info); return sys_info.dwNumberOfProcessors; } -uint64_t QueryRamUsage() +uint64 QueryRamUsage() { PROCESS_MEMORY_COUNTERS pmc{}; pmc.cb = sizeof(pmc); @@ -21,7 +21,7 @@ uint64_t QueryRamUsage() return pmc.WorkingSetSize; } -void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel) +void QueryProcTime(uint64 &out_now, uint64 &out_user, uint64 &out_kernel) { FILETIME ftime, fkernel, fuser; LARGE_INTEGER now, kernel, user; @@ -41,7 +41,7 @@ void QueryProcTime(uint64_t &out_now, uint64_t &out_user, uint64_t &out_kernel) out_kernel = kernel.QuadPart; } -void QueryCoreTimes(uint32_t count, ProcessorTime out[]) +void QueryCoreTimes(uint32 count, ProcessorTime out[]) { std::vector sppi(count); if (NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, sppi.data(), sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION) * count, nullptr)))