mirror of https://github.com/PCSX2/pcsx2.git
Darwin: Don't pass MAP_ANON to mmap when file mapping and mmap ret -1.
This appeared to work under x86, but on ARM this (rightfully) fails.
This commit is contained in:
parent
a572c80896
commit
e6c6cd82bf
|
@ -364,7 +364,7 @@ void* HostSys::MapMapping(void* handle, size_t size, const PageProtectionMode& m
|
||||||
{
|
{
|
||||||
const u32 mmap_prot = (mode.CanWrite() ? (PROT_READ | PROT_WRITE) : (PROT_READ)) | (mode.CanExecute() ? PROT_EXEC : 0);
|
const u32 mmap_prot = (mode.CanWrite() ? (PROT_READ | PROT_WRITE) : (PROT_READ)) | (mode.CanExecute() ? PROT_EXEC : 0);
|
||||||
|
|
||||||
return mmap(nullptr, size, mmap_prot, MAP_PRIVATE | MAP_ANON, static_cast<int>(reinterpret_cast<intptr_t>(handle)), 0);
|
return mmap(nullptr, size, mmap_prot, MAP_PRIVATE, static_cast<int>(reinterpret_cast<intptr_t>(handle)), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HostSys::DestroyMapping(void* handle)
|
void HostSys::DestroyMapping(void* handle)
|
||||||
|
|
|
@ -338,28 +338,22 @@ void FileMemoryCard::Open()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_file[slot])
|
if (!m_file[slot])
|
||||||
{
|
goto memoryCardOpenFailed;
|
||||||
Host::ReportErrorAsync(TRANSLATE_SV("MemoryCard", "Memory Card Read Failed"),
|
|
||||||
fmt::format(TRANSLATE_FS("MemoryCard", "Unable to access memory card:\n\n{}\n\n"
|
|
||||||
"Another instance of PCSX2 may be using this memory card "
|
|
||||||
"or the memory card is stored in a write-protected folder.\n"
|
|
||||||
"Close any other instances of PCSX2, or restart your computer.\n"),
|
|
||||||
fname));
|
|
||||||
}
|
|
||||||
else // Load memory map and checksum
|
|
||||||
{
|
|
||||||
m_fileSize[slot] = FileSystem::FSize64(m_file[slot]);
|
m_fileSize[slot] = FileSystem::FSize64(m_file[slot]);
|
||||||
|
|
||||||
m_mapping_handles[slot] = HostSys::CreateMappingFromFile(m_file[slot]);
|
m_mapping_handles[slot] = HostSys::CreateMappingFromFile(m_file[slot]);
|
||||||
if (!m_mapping_handles[slot])
|
if (!m_mapping_handles[slot])
|
||||||
{
|
{
|
||||||
Console.Warning("CreateMappingFromFile failed!");
|
Console.Warning("MemoryCardFile: CreateMappingFromFile failed!");
|
||||||
|
goto memoryCardOpenFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mappings[slot] = static_cast<u8*>(HostSys::MapMapping(m_mapping_handles[slot], m_fileSize[slot], PageAccess_ReadWrite()));
|
m_mappings[slot] = static_cast<u8*>(HostSys::MapMapping(m_mapping_handles[slot], m_fileSize[slot], PageAccess_ReadWrite()));
|
||||||
if (!m_mappings[slot])
|
if (!m_mappings[slot] || reinterpret_cast<intptr_t>(m_mappings[slot]) < 0)
|
||||||
{
|
{
|
||||||
Console.Warning("MapSharedMemory failed! %d. %s", errno, strerror(errno));
|
Console.Warning("MemoryCardFile: MapSharedMemory failed! %d. %s", errno, strerror(errno));
|
||||||
|
goto memoryCardOpenFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLnFmt(Color_Green, "McdSlot {} [File]: {} [{} MB, {}]", slot, Path::GetFileName(fname),
|
Console.WriteLnFmt(Color_Green, "McdSlot {} [File]: {} [{} MB, {}]", slot, Path::GetFileName(fname),
|
||||||
|
@ -374,7 +368,30 @@ void FileMemoryCard::Open()
|
||||||
{
|
{
|
||||||
std::memcpy(&m_chksum[slot], m_mappings[slot] + m_chkaddr, sizeof(m_chksum[slot]));
|
std::memcpy(&m_chksum[slot], m_mappings[slot] + m_chkaddr, sizeof(m_chksum[slot]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memoryCardOpenFailed:
|
||||||
|
Host::ReportErrorAsync(TRANSLATE_SV("MemoryCard", "Memory Card Read Failed"),
|
||||||
|
fmt::format(TRANSLATE_FS("MemoryCard", "Unable to access memory card:\n\n{}\n\n"
|
||||||
|
"Another instance of PCSX2 may be using this memory card "
|
||||||
|
"or the memory card is stored in a write-protected folder.\n"
|
||||||
|
"Close any other instances of PCSX2, or restart your computer.\n"),
|
||||||
|
fname));
|
||||||
|
|
||||||
|
if(m_mapping_handles[slot])
|
||||||
|
{
|
||||||
|
HostSys::DestroyMapping(m_mapping_handles[slot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_file[slot])
|
||||||
|
{
|
||||||
|
std::fclose(m_file[slot]);
|
||||||
|
m_file[slot] = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_filenames[slot] = {};
|
||||||
|
m_fileSize[slot] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue