[memory] Move "Local\\" prefix to win impl

CreateFileMappingHandle now takes shared memory name without a prefix.
The doc of shm_open recommends not using slashes and prefixing with "/".
The prefixing has been moved to the os implementation layer.
Invocations of CreateFileMappingHandle were all using "Local\\" so these
prefixes were removed.
This commit is contained in:
Sandy Carter 2019-07-10 22:31:16 -04:00 committed by Triang3l
parent 22ef265057
commit 2c7009ca80
5 changed files with 9 additions and 9 deletions

View File

@ -88,7 +88,8 @@ FileMappingHandle CreateFileMappingHandle(const std::filesystem::path& path,
}
oflag |= O_CREAT;
int ret = shm_open(path.c_str(), oflag, 0777);
auto full_path = "/" / path;
int ret = shm_open(full_path.c_str(), oflag, 0777);
if (ret > 0) {
ftruncate64(ret, length);
}

View File

@ -147,9 +147,10 @@ FileMappingHandle CreateFileMappingHandle(const std::filesystem::path& path,
bool commit) {
DWORD protect =
ToWin32ProtectFlags(access) | (commit ? SEC_COMMIT : SEC_RESERVE);
auto full_path = "Local" / path;
return CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, protect,
static_cast<DWORD>(length >> 32),
static_cast<DWORD>(length), path.c_str());
static_cast<DWORD>(length), full_path.c_str());
}
void CloseFileMappingHandle(FileMappingHandle handle) { CloseHandle(handle); }

View File

@ -418,7 +418,7 @@ TEST_CASE("copy_and_swap_16_in_32_unaligned", "Copy and Swap") {
}
TEST_CASE("create_and_close_file_mapping", "Virtual Memory Mapping") {
auto path = fmt::format("Local\\xenia_test_{}", Clock::QueryHostTickCount());
auto path = fmt::format("xenia_test_{}", Clock::QueryHostTickCount());
auto memory = xe::memory::CreateFileMappingHandle(
path, 0x100, xe::memory::PageAccess::kReadWrite, true);
REQUIRE(memory);
@ -426,7 +426,7 @@ TEST_CASE("create_and_close_file_mapping", "Virtual Memory Mapping") {
}
TEST_CASE("map_view", "Virtual Memory Mapping") {
auto path = fmt::format("Local\\xenia_test_{}", Clock::QueryHostTickCount());
auto path = fmt::format("xenia_test_{}", Clock::QueryHostTickCount());
const size_t length = 0x100;
auto memory = xe::memory::CreateFileMappingHandle(
path, length, xe::memory::PageAccess::kReadWrite, true);
@ -444,7 +444,7 @@ TEST_CASE("map_view", "Virtual Memory Mapping") {
TEST_CASE("read_write_view", "Virtual Memory Mapping") {
const size_t length = 0x100;
auto path = fmt::format("Local\\xenia_test_{}", Clock::QueryHostTickCount());
auto path = fmt::format("xenia_test_{}", Clock::QueryHostTickCount());
auto memory = xe::memory::CreateFileMappingHandle(
path, length, xe::memory::PageAccess::kReadWrite, true);
REQUIRE(memory);

View File

@ -63,8 +63,7 @@ bool X64CodeCache::Initialize() {
}
// Create mmap file. This allows us to share the code cache with the debugger.
file_name_ =
fmt::format("Local\\xenia_code_cache_{}", Clock::QueryHostTickCount());
file_name_ = fmt::format("xenia_code_cache_{}", Clock::QueryHostTickCount());
mapping_ = xe::memory::CreateFileMappingHandle(
file_name_, kGeneratedCodeSize, xe::memory::PageAccess::kExecuteReadWrite,
false);

View File

@ -125,8 +125,7 @@ Memory::~Memory() {
}
bool Memory::Initialize() {
file_name_ =
fmt::format("Local\\xenia_memory_{}", Clock::QueryHostTickCount());
file_name_ = fmt::format("xenia_memory_{}", Clock::QueryHostTickCount());
// Create main page file-backed mapping. This is all reserved but
// uncommitted (so it shouldn't expand page file).