mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 14:31:24 +12:00
Hotfix for shm->map_self()
Make sure mmap returns 64K-aligned results, as on Windows.
This commit is contained in:
parent
733b46d51a
commit
b05d12df0e
1 changed files with 26 additions and 2 deletions
|
@ -254,8 +254,32 @@ namespace utils
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
const u64 ptr64 = reinterpret_cast<u64>(ptr);
|
const u64 ptr64 = reinterpret_cast<u64>(ptr) & -0x10000;
|
||||||
return static_cast<u8*>(::mmap(reinterpret_cast<void*>(ptr64 & -0x10000), m_size, +prot, MAP_SHARED | (ptr ? MAP_FIXED : 0), m_file, 0));
|
|
||||||
|
if (ptr64)
|
||||||
|
{
|
||||||
|
return reinterpret_cast<u8*>(reinterpret_cast<u64>(::mmap(reinterpret_cast<void*>(ptr64), m_size, +prot, MAP_SHARED | MAP_FIXED, m_file, 0)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const u64 res64 = reinterpret_cast<u64>(::mmap(reinterpret_cast<void*>(ptr64), m_size + 0xe000, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0));
|
||||||
|
|
||||||
|
const u64 aligned = ::align(res64, 0x10000);
|
||||||
|
const auto result = ::mmap(reinterpret_cast<void*>(aligned), m_size, +prot, MAP_SHARED | MAP_FIXED, m_file, 0);
|
||||||
|
|
||||||
|
// Now cleanup remnants
|
||||||
|
if (aligned > res64)
|
||||||
|
{
|
||||||
|
verify(HERE), ::munmap(reinterpret_cast<void*>(res64), aligned - res64) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aligned < res64 + 0xe000)
|
||||||
|
{
|
||||||
|
verify(HERE), ::munmap(reinterpret_cast<void*>(aligned + m_size), (res64 + 0xe000) - (aligned)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return reinterpret_cast<u8*>(result);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue