Common: Remove unused functions

This commit is contained in:
TellowKrinkle 2024-08-21 03:03:21 -05:00
parent 2eabebc82a
commit 87b795e1c6
3 changed files with 0 additions and 96 deletions

View File

@ -90,20 +90,11 @@ static __fi PageProtectionMode PageAccess_Any()
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
namespace HostSys namespace HostSys
{ {
// Maps a block of memory for use as a recompiled code buffer.
// Returns NULL on allocation failure.
extern void* Mmap(void* base, size_t size, const PageProtectionMode& mode);
// Unmaps a block allocated by SysMmap
extern void Munmap(void* base, size_t size);
extern void MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode); extern void MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode);
extern std::string GetFileMappingName(const char* prefix); extern std::string GetFileMappingName(const char* prefix);
extern void* CreateSharedMemory(const char* name, size_t size); extern void* CreateSharedMemory(const char* name, size_t size);
extern void DestroySharedMemory(void* ptr); extern void DestroySharedMemory(void* ptr);
extern void* MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, const PageProtectionMode& mode);
extern void UnmapSharedMemory(void* baseaddr, size_t size);
/// JIT write protect for Apple Silicon. Needs to be called prior to writing to any RWX pages. /// JIT write protect for Apple Silicon. Needs to be called prior to writing to any RWX pages.
#if !defined(__APPLE__) || !defined(_M_ARM64) #if !defined(__APPLE__) || !defined(_M_ARM64)

View File

@ -39,32 +39,6 @@ static __ri uint LinuxProt(const PageProtectionMode& mode)
return lnxmode; return lnxmode;
} }
void* HostSys::Mmap(void* base, size_t size, const PageProtectionMode& mode)
{
pxAssertMsg((size & (__pagesize - 1)) == 0, "Size is page aligned");
if (mode.IsNone())
return nullptr;
const u32 prot = LinuxProt(mode);
u32 flags = MAP_PRIVATE | MAP_ANONYMOUS;
void* res = mmap(base, size, prot, flags, -1, 0);
if (res == MAP_FAILED)
return nullptr;
return res;
}
void HostSys::Munmap(void* base, size_t size)
{
if (!base)
return;
munmap((void*)base, size);
}
void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode) void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode)
{ {
pxAssertMsg((size & (__pagesize - 1)) == 0, "Size is page aligned"); pxAssertMsg((size & (__pagesize - 1)) == 0, "Size is page aligned");
@ -114,28 +88,6 @@ void HostSys::DestroySharedMemory(void* ptr)
close(static_cast<int>(reinterpret_cast<intptr_t>(ptr))); close(static_cast<int>(reinterpret_cast<intptr_t>(ptr)));
} }
void* HostSys::MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, const PageProtectionMode& mode)
{
const uint lnxmode = LinuxProt(mode);
int flags = MAP_SHARED;
#ifdef __APPLE__
if (mode.CanExecute())
flags |= MAP_JIT;
#endif
void* ptr = mmap(0, size, lnxmode, flags, static_cast<int>(reinterpret_cast<intptr_t>(handle)), static_cast<off_t>(offset));
if (ptr == MAP_FAILED)
return nullptr;
return ptr;
}
void HostSys::UnmapSharedMemory(void* baseaddr, size_t size)
{
if (munmap(baseaddr, size) != 0)
pxFailRel("Failed to unmap shared memory");
}
#ifndef __APPLE__ #ifndef __APPLE__
size_t HostSys::GetRuntimePageSize() size_t HostSys::GetRuntimePageSize()

View File

@ -35,22 +35,6 @@ static DWORD ConvertToWinApi(const PageProtectionMode& mode)
return winmode; return winmode;
} }
void* HostSys::Mmap(void* base, size_t size, const PageProtectionMode& mode)
{
if (mode.IsNone())
return nullptr;
return VirtualAlloc(base, size, MEM_RESERVE | MEM_COMMIT, ConvertToWinApi(mode));
}
void HostSys::Munmap(void* base, size_t size)
{
if (!base)
return;
VirtualFree((void*)base, 0, MEM_RELEASE);
}
void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode) void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode)
{ {
pxAssert((size & (__pagesize - 1)) == 0); pxAssert((size & (__pagesize - 1)) == 0);
@ -77,29 +61,6 @@ void HostSys::DestroySharedMemory(void* ptr)
CloseHandle(static_cast<HANDLE>(ptr)); CloseHandle(static_cast<HANDLE>(ptr));
} }
void* HostSys::MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, const PageProtectionMode& mode)
{
void* ret = MapViewOfFileEx(static_cast<HANDLE>(handle), FILE_MAP_READ | FILE_MAP_WRITE,
static_cast<DWORD>(offset >> 32), static_cast<DWORD>(offset), size, baseaddr);
if (!ret)
return nullptr;
const DWORD prot = ConvertToWinApi(mode);
if (prot != PAGE_READWRITE)
{
DWORD old_prot;
if (!VirtualProtect(ret, size, prot, &old_prot))
pxFail("Failed to protect memory mapping");
}
return ret;
}
void HostSys::UnmapSharedMemory(void* baseaddr, size_t size)
{
if (!UnmapViewOfFile(baseaddr))
pxFail("Failed to unmap shared memory");
}
size_t HostSys::GetRuntimePageSize() size_t HostSys::GetRuntimePageSize()
{ {
SYSTEM_INFO si = {}; SYSTEM_INFO si = {};