From db9b7db531a379b4a3be76958ee1f9e2e5b93f04 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Fri, 18 Dec 2020 12:55:54 +0300 Subject: [PATCH] Cleanup and move sysinfo.h -> util/sysinfo.hpp --- Utilities/JIT.cpp | 2 +- Utilities/Thread.cpp | 2 +- rpcs3/Emu/CMakeLists.txt | 2 +- rpcs3/Emu/Cell/PPUInterpreter.cpp | 2 +- rpcs3/Emu/Cell/PPUThread.cpp | 1 - rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 2 +- rpcs3/Emu/Cell/SPUInterpreter.cpp | 2 +- rpcs3/Emu/Cell/SPURecompiler.cpp | 2 +- rpcs3/Emu/Cell/SPUThread.cpp | 2 +- rpcs3/Emu/RSX/Common/BufferUtils.cpp | 2 +- .../Emu/RSX/Overlays/overlay_perf_metrics.cpp | 3 +- rpcs3/Emu/RSX/rsx_utils.cpp | 3 +- rpcs3/Emu/System.cpp | 2 +- rpcs3/Emu/perf_meter.hpp | 3 +- rpcs3/Emu/system_config.cpp | 3 +- rpcs3/Emu/title.cpp | 3 +- rpcs3/emucore.vcxproj | 10 ++----- rpcs3/emucore.vcxproj.filters | 4 +-- rpcs3/main.cpp | 2 +- rpcs3/rpcs3qt/log_frame.cpp | 3 +- rpcs3/rpcs3qt/settings_dialog.cpp | 9 +++--- rpcs3/util/atomic2.cpp | 3 +- {Utilities => rpcs3/util}/sysinfo.cpp | 30 ++++++++++++++++--- Utilities/sysinfo.h => rpcs3/util/sysinfo.hpp | 22 ++------------ 24 files changed, 63 insertions(+), 56 deletions(-) rename {Utilities => rpcs3/util}/sysinfo.cpp (93%) rename Utilities/sysinfo.h => rpcs3/util/sysinfo.hpp (52%) diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index f1c56aca06..83e8c130a2 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -1,10 +1,10 @@ #include "util/types.hpp" +#include "util/sysinfo.hpp" #include "JIT.h" #include "StrFmt.h" #include "File.h" #include "util/logs.hpp" #include "mutex.h" -#include "sysinfo.h" #include "util/vm.hpp" #include #include diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index db480e15e9..2b5b5ceb5b 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -7,7 +7,6 @@ #include "Emu/Cell/lv2/sys_event.h" #include "Thread.h" #include "Utilities/JIT.h" -#include "sysinfo.h" #include #include #include @@ -77,6 +76,7 @@ #include "util/vm.hpp" #include "util/logs.hpp" #include "util/asm.hpp" +#include "util/sysinfo.hpp" #include "Emu/Memory/vm_locking.h" LOG_CHANNEL(sig_log, "SIG"); diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 1a4ca66deb..b13c6cc7d7 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -40,6 +40,7 @@ target_sources(rpcs3_emu PRIVATE ../util/cereal.cpp ../util/vm_native.cpp ../util/dyn_lib.cpp + ../util/sysinfo.cpp ../../Utilities/bin_patch.cpp ../../Utilities/cheat_info.cpp ../../Utilities/cond.cpp @@ -51,7 +52,6 @@ target_sources(rpcs3_emu PRIVATE ../../Utilities/rXml.cpp ../../Utilities/sema.cpp ../../Utilities/StrFmt.cpp - ../../Utilities/sysinfo.cpp ../../Utilities/Thread.cpp ../../Utilities/version.cpp ) diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index b40487cf74..c2450c1ff9 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -4,7 +4,6 @@ #include "Emu/Memory/vm_reservation.h" #include "Emu/system_config.h" #include "PPUThread.h" -#include "Utilities/sysinfo.h" #include "Emu/Cell/Common.h" #include "Emu/Cell/PPUFunction.h" @@ -13,6 +12,7 @@ #include "util/asm.hpp" #include "util/v128.hpp" +#include "util/sysinfo.hpp" #if !defined(_MSC_VER) && defined(__clang__) #pragma GCC diagnostic push diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index c4154c3bee..2e462f8e87 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#include "Utilities/sysinfo.h" #include "Utilities/JIT.h" #include "Crypto/sha1.h" #include "Emu/perf_meter.hpp" diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 41901313f0..689b6032e7 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -7,12 +7,12 @@ #include "SPUDisAsm.h" #include "SPUThread.h" #include "SPUInterpreter.h" -#include "Utilities/sysinfo.h" #include "PPUAnalyser.h" #include "Crypto/sha1.h" #include "util/asm.hpp" #include "util/v128.hpp" +#include "util/sysinfo.hpp" #include #include diff --git a/rpcs3/Emu/Cell/SPUInterpreter.cpp b/rpcs3/Emu/Cell/SPUInterpreter.cpp index 8bc1ed1060..560dcdedf0 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/SPUInterpreter.cpp @@ -2,12 +2,12 @@ #include "SPUInterpreter.h" #include "Utilities/JIT.h" -#include "Utilities/sysinfo.h" #include "SPUThread.h" #include "Emu/Cell/Common.h" #include "util/asm.hpp" #include "util/v128.hpp" +#include "util/sysinfo.hpp" #include #include diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index a89b148b72..cfac074b06 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -7,7 +7,6 @@ #include "Crypto/sha1.h" #include "Utilities/StrUtil.h" #include "Utilities/JIT.h" -#include "Utilities/sysinfo.h" #include "util/init_mutex.hpp" #include "SPUThread.h" @@ -19,6 +18,7 @@ #include #include "util/v128.hpp" +#include "util/sysinfo.hpp" extern atomic_t g_progr; extern atomic_t g_progr_ptotal; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index bdf2d05aa2..bfa0a336a9 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -1,7 +1,6 @@ #include "stdafx.h" #include "Utilities/JIT.h" #include "Utilities/date_time.h" -#include "Utilities/sysinfo.h" #include "Emu/Memory/vm.h" #include "Emu/Memory/vm_ptr.h" #include "Emu/Memory/vm_reservation.h" @@ -32,6 +31,7 @@ #include "util/vm.hpp" #include "util/asm.hpp" #include "util/v128.hpp" +#include "util/sysinfo.hpp" using spu_rdata_t = decltype(spu_thread::rdata); diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index fa24fa3b91..6bce437096 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -1,11 +1,11 @@ #include "stdafx.h" #include "BufferUtils.h" #include "../rsx_methods.h" -#include "Utilities/sysinfo.h" #include "../RSXThread.h" #include "util/v128.hpp" #include "util/to_endian.hpp" +#include "util/sysinfo.hpp" #define DEBUG_VERTEX_STREAMING 0 diff --git a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp index 7ef534d3f8..3068408919 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_perf_metrics.cpp @@ -4,12 +4,13 @@ #include "Emu/Cell/SPUThread.h" #include "Emu/Cell/RawSPUThread.h" #include "Emu/Cell/PPUThread.h" -#include "Utilities/sysinfo.h" #include #include #include +#include "util/sysinfo.hpp" + namespace rsx { namespace overlays diff --git a/rpcs3/Emu/RSX/rsx_utils.cpp b/rpcs3/Emu/RSX/rsx_utils.cpp index 397bbbeae7..a84269b58e 100644 --- a/rpcs3/Emu/RSX/rsx_utils.cpp +++ b/rpcs3/Emu/RSX/rsx_utils.cpp @@ -4,7 +4,6 @@ #include "Emu/RSX/GCM.h" #include "Common/BufferUtils.h" #include "Overlays/overlays.h" -#include "Utilities/sysinfo.h" #ifdef _MSC_VER #pragma warning(push, 0) @@ -24,6 +23,8 @@ extern "C" #pragma GCC diagnostic pop #endif +#include "util/sysinfo.hpp" + namespace rsx { atomic_t g_rsx_shared_tag{ 0 }; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 5b3311b40a..029579b2a3 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -28,10 +28,10 @@ #include "Loader/ELF.h" #include "Utilities/StrUtil.h" -#include "Utilities/sysinfo.h" #include "../Crypto/unself.h" #include "../Crypto/unpkg.h" +#include "util/sysinfo.hpp" #include "util/yaml.hpp" #include "util/logs.hpp" diff --git a/rpcs3/Emu/perf_meter.hpp b/rpcs3/Emu/perf_meter.hpp index 44d8080741..5625d562fb 100644 --- a/rpcs3/Emu/perf_meter.hpp +++ b/rpcs3/Emu/perf_meter.hpp @@ -2,12 +2,13 @@ #include "util/types.hpp" #include "util/logs.hpp" -#include "Utilities/sysinfo.h" #include "system_config.h" #include "IdManager.h" #include #include +#include "util/sysinfo.hpp" + LOG_CHANNEL(perf_log, "PERF"); // TODO: constexpr with the help of bitcast diff --git a/rpcs3/Emu/system_config.cpp b/rpcs3/Emu/system_config.cpp index fd850af104..e50a4172b9 100644 --- a/rpcs3/Emu/system_config.cpp +++ b/rpcs3/Emu/system_config.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" #include "system_config.h" #include "Utilities/StrUtil.h" -#include "Utilities/sysinfo.h" + +#include "util/sysinfo.hpp" cfg_root g_cfg; diff --git a/rpcs3/Emu/title.cpp b/rpcs3/Emu/title.cpp index fafd12014f..ff614397cb 100644 --- a/rpcs3/Emu/title.cpp +++ b/rpcs3/Emu/title.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" #include "title.h" #include "rpcs3_version.h" -#include "Utilities/sysinfo.h" + +#include "util/sysinfo.hpp" namespace rpcs3 { diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 736db5d9d6..29c79bf29b 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -165,12 +165,8 @@ NotUsing - - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing + + NotUsing @@ -546,7 +542,7 @@ - + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 0f45a6b4c8..931aff5de0 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -782,7 +782,7 @@ Emu\Cell\lv2 - + Utilities @@ -1624,7 +1624,7 @@ Utilities - + Utilities diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index e7fdc4739e..f78c45a8f1 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -37,7 +37,6 @@ DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResoluti #include #endif -#include "Utilities/sysinfo.h" #include "Utilities/Config.h" #include "Utilities/Thread.h" #include "rpcs3_version.h" @@ -46,6 +45,7 @@ DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResoluti #include #include "util/v128.hpp" +#include "util/sysinfo.hpp" inline std::string sstr(const QString& _in) { return _in.toStdString(); } diff --git a/rpcs3/rpcs3qt/log_frame.cpp b/rpcs3/rpcs3qt/log_frame.cpp index f4a420e104..f2df6fe27e 100644 --- a/rpcs3/rpcs3qt/log_frame.cpp +++ b/rpcs3/rpcs3qt/log_frame.cpp @@ -4,7 +4,6 @@ #include "stdafx.h" #include "rpcs3_version.h" -#include "Utilities/sysinfo.h" #include "Utilities/mutex.h" #include "Utilities/lockless.h" @@ -19,6 +18,8 @@ #include #include +#include "util/sysinfo.hpp" + extern fs::file g_tty; extern atomic_t g_tty_size; extern std::array, 16> g_tty_input; diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index e27a6738cc..c0761f2c1e 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -28,12 +28,13 @@ #include "Emu/system_config.h" #include "Emu/title.h" #include "Crypto/unself.h" -#include "Utilities/sysinfo.h" #include #include #include +#include "util/sysinfo.hpp" + #ifdef WITH_DISCORD_RPC #include "_discord_utils.h" #endif @@ -1043,7 +1044,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag // If no override selected (res=0), checkbox is unchecked - // Otherwise if the override does not match the default behaviour, checkbox is checked + // Otherwise if the override does not match the default behaviour, checkbox is checked item->setCheckState(res && res != (lib.second * 2 - 1) ? Qt::Checked : Qt::Unchecked); // AND initialize check state item->setToolTip(!lib.second ? tooltips.settings.lib_default_lle : @@ -1077,7 +1078,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std { return (i1->checkState() != i2->checkState()) ? (i1->checkState() > i2->checkState()) : (i1->text() < i2->text()); }; - + std::sort(items.begin(), items.end(), func); std::sort(items2.begin(), items2.end(), func); @@ -1098,7 +1099,7 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std } }; - // Sort libs + // Sort libs on_lib_state_changed({}); // Events diff --git a/rpcs3/util/atomic2.cpp b/rpcs3/util/atomic2.cpp index 7e24568950..1676d4ffe1 100644 --- a/rpcs3/util/atomic2.cpp +++ b/rpcs3/util/atomic2.cpp @@ -1,6 +1,7 @@ #include "atomic2.hpp" #include "Utilities/JIT.h" -#include "Utilities/sysinfo.h" + +#include "util/sysinfo.hpp" // static const bool s_use_rtm = utils::has_rtm(); diff --git a/Utilities/sysinfo.cpp b/rpcs3/util/sysinfo.cpp similarity index 93% rename from Utilities/sysinfo.cpp rename to rpcs3/util/sysinfo.cpp index cdd3f360e9..826ec1220d 100755 --- a/Utilities/sysinfo.cpp +++ b/rpcs3/util/sysinfo.cpp @@ -1,8 +1,8 @@ -#include "sysinfo.h" -#include "StrFmt.h" -#include "File.h" +#include "util/sysinfo.hpp" +#include "Utilities/StrFmt.h" +#include "Utilities/File.h" #include "Emu/system_config.h" -#include "Thread.h" +#include "Utilities/Thread.h" #ifdef _WIN32 #include "windows.h" @@ -15,6 +15,28 @@ #include #endif +inline std::array utils::get_cpuid(u32 func, u32 subfunc) +{ + int regs[4]; +#ifdef _MSC_VER + __cpuidex(regs, func, subfunc); +#else + __asm__ volatile("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3]) : "a" (func), "c" (subfunc)); +#endif + return {0u+regs[0], 0u+regs[1], 0u+regs[2], 0u+regs[3]}; +} + +inline u64 utils::get_xgetbv(u32 xcr) +{ +#ifdef _MSC_VER + return _xgetbv(xcr); +#else + u32 eax, edx; + __asm__ volatile("xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr)); + return eax | (u64(edx) << 32); +#endif +} + bool utils::has_ssse3() { static const bool g_value = get_cpuid(0, 0)[0] >= 0x1 && get_cpuid(1, 0)[2] & 0x200; diff --git a/Utilities/sysinfo.h b/rpcs3/util/sysinfo.hpp similarity index 52% rename from Utilities/sysinfo.h rename to rpcs3/util/sysinfo.hpp index aed1026c08..735536d53a 100755 --- a/Utilities/sysinfo.h +++ b/rpcs3/util/sysinfo.hpp @@ -5,27 +5,9 @@ namespace utils { - inline std::array get_cpuid(u32 func, u32 subfunc) - { - int regs[4]; -#ifdef _MSC_VER - __cpuidex(regs, func, subfunc); -#else - __asm__ volatile("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3]) : "a" (func), "c" (subfunc)); -#endif - return {0u+regs[0], 0u+regs[1], 0u+regs[2], 0u+regs[3]}; - } + std::array get_cpuid(u32 func, u32 subfunc); - inline u64 get_xgetbv(u32 xcr) - { -#ifdef _MSC_VER - return _xgetbv(xcr); -#else - u32 eax, edx; - __asm__ volatile( "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr)); - return eax | (u64(edx) << 32); -#endif - } + u64 get_xgetbv(u32 xcr); bool has_ssse3();