Skip to content

Commit 87b795e

Browse files
committed
Common: Remove unused functions
1 parent 2eabebc commit 87b795e

File tree

3 files changed

+0
-96
lines changed

3 files changed

+0
-96
lines changed

common/HostSys.h

-9
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,11 @@ static __fi PageProtectionMode PageAccess_Any()
9090
// --------------------------------------------------------------------------------------
9191
namespace HostSys
9292
{
93-
// Maps a block of memory for use as a recompiled code buffer.
94-
// Returns NULL on allocation failure.
95-
extern void* Mmap(void* base, size_t size, const PageProtectionMode& mode);
96-
97-
// Unmaps a block allocated by SysMmap
98-
extern void Munmap(void* base, size_t size);
99-
10093
extern void MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode);
10194

10295
extern std::string GetFileMappingName(const char* prefix);
10396
extern void* CreateSharedMemory(const char* name, size_t size);
10497
extern void DestroySharedMemory(void* ptr);
105-
extern void* MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, const PageProtectionMode& mode);
106-
extern void UnmapSharedMemory(void* baseaddr, size_t size);
10798

10899
/// JIT write protect for Apple Silicon. Needs to be called prior to writing to any RWX pages.
109100
#if !defined(__APPLE__) || !defined(_M_ARM64)

common/Linux/LnxHostSys.cpp

-48
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,6 @@ static __ri uint LinuxProt(const PageProtectionMode& mode)
3939
return lnxmode;
4040
}
4141

42-
void* HostSys::Mmap(void* base, size_t size, const PageProtectionMode& mode)
43-
{
44-
pxAssertMsg((size & (__pagesize - 1)) == 0, "Size is page aligned");
45-
46-
if (mode.IsNone())
47-
return nullptr;
48-
49-
const u32 prot = LinuxProt(mode);
50-
51-
u32 flags = MAP_PRIVATE | MAP_ANONYMOUS;
52-
53-
void* res = mmap(base, size, prot, flags, -1, 0);
54-
if (res == MAP_FAILED)
55-
return nullptr;
56-
57-
return res;
58-
}
59-
60-
void HostSys::Munmap(void* base, size_t size)
61-
{
62-
if (!base)
63-
return;
64-
65-
munmap((void*)base, size);
66-
}
67-
6842
void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode)
6943
{
7044
pxAssertMsg((size & (__pagesize - 1)) == 0, "Size is page aligned");
@@ -114,28 +88,6 @@ void HostSys::DestroySharedMemory(void* ptr)
11488
close(static_cast<int>(reinterpret_cast<intptr_t>(ptr)));
11589
}
11690

117-
void* HostSys::MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, const PageProtectionMode& mode)
118-
{
119-
const uint lnxmode = LinuxProt(mode);
120-
121-
int flags = MAP_SHARED;
122-
#ifdef __APPLE__
123-
if (mode.CanExecute())
124-
flags |= MAP_JIT;
125-
#endif
126-
void* ptr = mmap(0, size, lnxmode, flags, static_cast<int>(reinterpret_cast<intptr_t>(handle)), static_cast<off_t>(offset));
127-
if (ptr == MAP_FAILED)
128-
return nullptr;
129-
130-
return ptr;
131-
}
132-
133-
void HostSys::UnmapSharedMemory(void* baseaddr, size_t size)
134-
{
135-
if (munmap(baseaddr, size) != 0)
136-
pxFailRel("Failed to unmap shared memory");
137-
}
138-
13991
#ifndef __APPLE__
14092

14193
size_t HostSys::GetRuntimePageSize()

common/Windows/WinHostSys.cpp

-39
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,6 @@ static DWORD ConvertToWinApi(const PageProtectionMode& mode)
3535
return winmode;
3636
}
3737

38-
void* HostSys::Mmap(void* base, size_t size, const PageProtectionMode& mode)
39-
{
40-
if (mode.IsNone())
41-
return nullptr;
42-
43-
return VirtualAlloc(base, size, MEM_RESERVE | MEM_COMMIT, ConvertToWinApi(mode));
44-
}
45-
46-
void HostSys::Munmap(void* base, size_t size)
47-
{
48-
if (!base)
49-
return;
50-
51-
VirtualFree((void*)base, 0, MEM_RELEASE);
52-
}
53-
5438
void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode)
5539
{
5640
pxAssert((size & (__pagesize - 1)) == 0);
@@ -77,29 +61,6 @@ void HostSys::DestroySharedMemory(void* ptr)
7761
CloseHandle(static_cast<HANDLE>(ptr));
7862
}
7963

80-
void* HostSys::MapSharedMemory(void* handle, size_t offset, void* baseaddr, size_t size, const PageProtectionMode& mode)
81-
{
82-
void* ret = MapViewOfFileEx(static_cast<HANDLE>(handle), FILE_MAP_READ | FILE_MAP_WRITE,
83-
static_cast<DWORD>(offset >> 32), static_cast<DWORD>(offset), size, baseaddr);
84-
if (!ret)
85-
return nullptr;
86-
87-
const DWORD prot = ConvertToWinApi(mode);
88-
if (prot != PAGE_READWRITE)
89-
{
90-
DWORD old_prot;
91-
if (!VirtualProtect(ret, size, prot, &old_prot))
92-
pxFail("Failed to protect memory mapping");
93-
}
94-
return ret;
95-
}
96-
97-
void HostSys::UnmapSharedMemory(void* baseaddr, size_t size)
98-
{
99-
if (!UnmapViewOfFile(baseaddr))
100-
pxFail("Failed to unmap shared memory");
101-
}
102-
10364
size_t HostSys::GetRuntimePageSize()
10465
{
10566
SYSTEM_INFO si = {};

0 commit comments

Comments
 (0)