Common: Rename General to HostSys

Actually fits what it's doing.
This commit is contained in:
Stenzek 2023-12-26 21:25:10 +10:00 committed by Connor McLaughlin
parent 911d7f6533
commit 59d29b3648
35 changed files with 63 additions and 88 deletions

View File

@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#include "Threading.h"
#include "General.h"
#include "Assertions.h"
#include "CrashHandler.h"
#include "HostSys.h"
#include "Threading.h"
#include <mutex>
#include "fmt/core.h"

View File

@ -6,6 +6,7 @@
#include "common/Pcsx2Defs.h"
#include <bit>
#include <cstring>
#ifdef _MSC_VER
@ -84,3 +85,16 @@ namespace Common
return std::countl_zero(static_cast<u32>(n));
}
} // namespace Common
template <typename T>
[[maybe_unused]] __fi static T GetBufferT(u8* buffer, u32 offset)
{
T value;
std::memcpy(&value, buffer + offset, sizeof(value));
return value;
}
[[maybe_unused]] __fi static u8 GetBufferU8(u8* buffer, u32 offset) { return GetBufferT<u8>(buffer, offset); }
[[maybe_unused]] __fi static u16 GetBufferU16(u8* buffer, u32 offset) { return GetBufferT<u16>(buffer, offset); }
[[maybe_unused]] __fi static u32 GetBufferU32(u8* buffer, u32 offset) { return GetBufferT<u32>(buffer, offset); }
[[maybe_unused]] __fi static u64 GetBufferU64(u8* buffer, u32 offset) { return GetBufferT<u64>(buffer, offset); }

View File

@ -17,11 +17,10 @@ target_sources(common PRIVATE
Error.cpp
FastJmp.cpp
FileSystem.cpp
General.cpp
HostSys.cpp
Image.cpp
HTTPDownloader.cpp
MemorySettingsInterface.cpp
Misc.cpp
MD5Digest.cpp
PrecompiledHeader.cpp
Perf.cpp
@ -72,8 +71,8 @@ target_sources(common PRIVATE
FPControl.h
FastJmp.h
FileSystem.h
General.h
HashCombine.h
HostSys.h
HeterogeneousContainers.h
Image.h
LRUCache.h

View File

@ -7,7 +7,7 @@
#include "CocoaTools.h"
#include "Console.h"
#include "General.h"
#include "HostSys.h"
#include "WindowInfo.h"
#include <dlfcn.h>
#include <mutex>

View File

@ -16,7 +16,7 @@
#include "common/Pcsx2Types.h"
#include "common/Console.h"
#include "common/General.h"
#include "common/HostSys.h"
#include "common/Threading.h"
#include "common/WindowInfo.h"

View File

@ -1,26 +0,0 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#include "General.h"
// --------------------------------------------------------------------------------------
// PageProtectionMode (implementations)
// --------------------------------------------------------------------------------------
std::string PageProtectionMode::ToString() const
{
std::string modeStr;
if (m_read)
modeStr += "Read";
if (m_write)
modeStr += "Write";
if (m_exec)
modeStr += "Exec";
if (modeStr.empty())
return "NoAccess";
if (modeStr.length() <= 5)
modeStr += "Only";
return modeStr;
}

View File

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
// SPDX-License-Identifier: LGPL-3.0+
#include "General.h"
#include "HostSys.h"
#include "Console.h"
#include "VectorIntrin.h"

View File

@ -9,20 +9,6 @@
#include <map>
#include <memory>
#include <string>
#include <cstring>
template <typename T>
[[maybe_unused]] __fi static T GetBufferT(u8* buffer, u32 offset)
{
T value;
std::memcpy(&value, buffer + offset, sizeof(value));
return value;
}
[[maybe_unused]] __fi static u8 GetBufferU8(u8* buffer, u32 offset) { return GetBufferT<u8>(buffer, offset); }
[[maybe_unused]] __fi static u16 GetBufferU16(u8* buffer, u32 offset) { return GetBufferT<u16>(buffer, offset); }
[[maybe_unused]] __fi static u32 GetBufferU32(u8* buffer, u32 offset) { return GetBufferT<u32>(buffer, offset); }
[[maybe_unused]] __fi static u64 GetBufferU64(u8* buffer, u32 offset) { return GetBufferT<u64>(buffer, offset); }
// --------------------------------------------------------------------------------------
// PageProtectionMode
@ -30,46 +16,41 @@ template <typename T>
class PageProtectionMode
{
protected:
bool m_read;
bool m_write;
bool m_exec;
bool m_read = false;
bool m_write = false;
bool m_exec = false;
public:
PageProtectionMode()
{
All(false);
}
__fi constexpr PageProtectionMode() = default;
PageProtectionMode& Read(bool allow = true)
__fi constexpr PageProtectionMode& Read(bool allow = true)
{
m_read = allow;
return *this;
}
PageProtectionMode& Write(bool allow = true)
__fi constexpr PageProtectionMode& Write(bool allow = true)
{
m_write = allow;
return *this;
}
PageProtectionMode& Execute(bool allow = true)
__fi constexpr PageProtectionMode& Execute(bool allow = true)
{
m_exec = allow;
return *this;
}
PageProtectionMode& All(bool allow = true)
__fi constexpr PageProtectionMode& All(bool allow = true)
{
m_read = m_write = m_exec = allow;
return *this;
}
bool CanRead() const { return m_read; }
bool CanWrite() const { return m_write; }
bool CanExecute() const { return m_exec && m_read; }
bool IsNone() const { return !m_read && !m_write; }
std::string ToString() const;
__fi constexpr bool CanRead() const { return m_read; }
__fi constexpr bool CanWrite() const { return m_write; }
__fi constexpr bool CanExecute() const { return m_exec && m_read; }
__fi constexpr bool IsNone() const { return !m_read && !m_write; }
};
static __fi PageProtectionMode PageAccess_None()

View File

@ -20,7 +20,7 @@
#include "common/BitUtils.h"
#include "common/Assertions.h"
#include "common/Console.h"
#include "common/General.h"
#include "common/HostSys.h"
// Apple uses the MAP_ANON define instead of MAP_ANONYMOUS, but they mean
// the same thing.

View File

@ -4,7 +4,7 @@
#if !defined(_WIN32) && !defined(__APPLE__)
#include "common/Pcsx2Types.h"
#include "common/General.h"
#include "common/HostSys.h"
#include "common/ScopedGuard.h"
#include "common/StringUtil.h"
#include "common/Threading.h"

View File

@ -3,6 +3,7 @@
#include "common/Threading.h"
#include "common/Assertions.h"
#include "common/HostSys.h"
#ifdef _WIN32
#include "common/RedtapeWindows.h"

View File

@ -4,7 +4,6 @@
#pragma once
#include "common/Pcsx2Defs.h"
#include "common/General.h"
#if defined(__APPLE__)
#include <mach/semaphore.h>

View File

@ -6,7 +6,7 @@
#include "common/BitUtils.h"
#include "common/RedtapeWindows.h"
#include "common/Console.h"
#include "common/General.h"
#include "common/HostSys.h"
#include "common/StringUtil.h"
#include "common/AlignedMalloc.h"
#include "common/Assertions.h"

View File

@ -3,11 +3,10 @@
#if defined(_WIN32)
#include "common/Pcsx2Defs.h"
#include "common/HostSys.h"
#include "common/RedtapeWindows.h"
#include "common/StringUtil.h"
#include "common/Threading.h"
#include "common/General.h"
#include "common/WindowInfo.h"
#include "fmt/core.h"

View File

@ -55,7 +55,6 @@
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="FileSystem.cpp" />
<ClCompile Include="General.cpp" />
<ClCompile Include="Image.cpp" />
<ClCompile Include="HTTPDownloader.cpp" />
<ClCompile Include="HTTPDownloaderCurl.cpp">
@ -84,7 +83,7 @@
<ClCompile Include="Windows\WinHostSys.cpp" />
<ClCompile Include="Windows\WinMisc.cpp" />
<ClCompile Include="Windows\WinThreads.cpp" />
<ClCompile Include="Misc.cpp" />
<ClCompile Include="HostSys.cpp" />
<ClCompile Include="Semaphore.cpp" />
<ClCompile Include="emitter\avx.cpp" />
<ClCompile Include="emitter\bmi.cpp" />
@ -135,7 +134,7 @@
<ClInclude Include="SettingsWrapper.h" />
<ClInclude Include="Assertions.h" />
<ClInclude Include="Console.h" />
<ClInclude Include="General.h" />
<ClInclude Include="HostSys.h" />
<ClInclude Include="Path.h" />
<ClInclude Include="PrecompiledHeader.h" />
<ClInclude Include="ReadbackSpinManager.h" />

View File

@ -40,7 +40,7 @@
<ClCompile Include="emitter\movs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Misc.cpp">
<ClCompile Include="HostSys.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Perf.cpp">
@ -124,9 +124,6 @@
<ClCompile Include="FileSystem.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="General.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Error.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -159,7 +156,7 @@
<ClInclude Include="emitter\implement\dwshift.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="General.h">
<ClInclude Include="HostSys.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="emitter\implement\group1.h">

View File

@ -22,7 +22,6 @@
#include "common/Console.h"
#include "common/Error.h"
#include "common/FileSystem.h"
#include "common/General.h"
#include "common/HTTPDownloader.h"
#include "common/MD5Digest.h"
#include "common/Path.h"

View File

@ -17,6 +17,7 @@
#include "IopDma.h"
#include "VMManager.h"
#include "common/BitUtils.h"
#include "common/Error.h"
#include "common/FileSystem.h"
#include "common/Path.h"

View File

@ -3,7 +3,7 @@
#pragma once
#include "common/General.h"
#include "common/Pcsx2Defs.h"
#include "common/FPControl.h"
#include <array>
#include <string>

View File

@ -6,7 +6,6 @@
#include "GS.h"
#include "common/boost_spsc_queue.hpp"
#include "common/Assertions.h"
#include "common/General.h"
#include "common/Threading.h"
#include <condition_variable>
#include <functional>

View File

@ -4,6 +4,8 @@
#include "GSPerfMon.h"
#include "GS.h"
#include <cstring>
GSPerfMon g_perfmon;
GSPerfMon::GSPerfMon() = default;

View File

@ -6,6 +6,8 @@
#include "GS/GSExtra.h"
#include "GS/Renderers/SW/GSScanlineEnvironment.h"
#include "common/HostSys.h"
template <class KEY, class VALUE>
class GSFunctionMap
{

View File

@ -14,6 +14,7 @@
#include "common/Console.h"
#include "common/BitUtils.h"
#include "common/HostSys.h"
#include "common/ScopedGuard.h"
#include "common/StringUtil.h"

View File

@ -8,6 +8,7 @@
#include "GS/GSPerfMon.h"
#include "common/Console.h"
#include "common/HostSys.h"
#include "imgui.h"

View File

@ -6,6 +6,7 @@
#include "GS/GSPerfMon.h"
#include "common/BitUtils.h"
#include "common/Console.h"
#include "common/HostSys.h"
#ifdef __APPLE__

View File

@ -11,7 +11,6 @@
#include "common/AlignedMalloc.h"
#include "common/Console.h"
#include "common/General.h"
#include "common/StringUtil.h"
#define ENABLE_DRAW_STATS 0

View File

@ -14,6 +14,7 @@
#include "common/Console.h"
#include "common/BitUtils.h"
#include "common/HostSys.h"
#include "common/Path.h"
#include "common/ScopedGuard.h"

View File

@ -8,6 +8,7 @@
#include "common/FPControl.h"
#include <cstring>
#include <optional>
#include <string>
#include <string_view>

View File

@ -14,8 +14,6 @@
#include "IPU/yuv2rgb.h"
#include "IPU/IPU_MultiISA.h"
#include "common/General.h"
// the IPU is fixed to 16 byte strides (128-bit / QWC resolution):
static const uint decoder_stride = 16;

View File

@ -19,6 +19,7 @@
#include "fmt/core.h"
#include <array>
#include <atomic>
#include <memory>
#include <mutex>
#include <sstream>

View File

@ -10,6 +10,8 @@
#include "common/Assertions.h"
#include "common/Console.h"
#include <cstring>
#define MC_LOG_ENABLE 0
#define MC_LOG if (MC_LOG_ENABLE) DevCon

View File

@ -9,6 +9,8 @@
#include "Host.h"
#include "IconsFontAwesome5.h"
#include <atomic>
_mcd mcds[2][4];
_mcd *mcd;

View File

@ -5,6 +5,8 @@
#include "SPU2/spu2.h" // hopefully temporary, until I resolve lClocks depdendency
#include "IopMem.h"
#include <cstring>
namespace SPU2Savestate
{
// Arbitrary ID to identify SPU2 saves.

View File

@ -1023,7 +1023,7 @@ bool vtlb_GetGuestAddress(uptr host_addr, u32* guest_addr)
return true;
}
void vtlb_UpdateFastmemProtection(u32 paddr, u32 size, const PageProtectionMode& prot)
void vtlb_UpdateFastmemProtection(u32 paddr, u32 size, PageProtectionMode prot)
{
if (!CHECK_FASTMEM)
return;

View File

@ -5,7 +5,7 @@
#include "MemoryTypes.h"
#include "common/General.h"
#include "common/HostSys.h"
#include "common/SingleRegisterTypes.h"
static const uptr VTLB_AllocUpperBounds = _1gb * 2;
@ -73,7 +73,7 @@ extern void vtlb_VMapBuffer(u32 vaddr,void* buffer,u32 sz);
extern void vtlb_VMapUnmap(u32 vaddr,u32 sz);
extern bool vtlb_ResolveFastmemMapping(uptr* addr);
extern bool vtlb_GetGuestAddress(uptr host_addr, u32* guest_addr);
extern void vtlb_UpdateFastmemProtection(u32 paddr, u32 size, const PageProtectionMode& prot);
extern void vtlb_UpdateFastmemProtection(u32 paddr, u32 size, PageProtectionMode prot);
extern bool vtlb_BackpatchLoadStore(uptr code_address, uptr fault_address);
extern void vtlb_ClearLoadStoreInfo();