[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:
parent
22ef265057
commit
2c7009ca80
|
@ -88,7 +88,8 @@ FileMappingHandle CreateFileMappingHandle(const std::filesystem::path& path,
|
||||||
}
|
}
|
||||||
|
|
||||||
oflag |= O_CREAT;
|
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) {
|
if (ret > 0) {
|
||||||
ftruncate64(ret, length);
|
ftruncate64(ret, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,10 @@ FileMappingHandle CreateFileMappingHandle(const std::filesystem::path& path,
|
||||||
bool commit) {
|
bool commit) {
|
||||||
DWORD protect =
|
DWORD protect =
|
||||||
ToWin32ProtectFlags(access) | (commit ? SEC_COMMIT : SEC_RESERVE);
|
ToWin32ProtectFlags(access) | (commit ? SEC_COMMIT : SEC_RESERVE);
|
||||||
|
auto full_path = "Local" / path;
|
||||||
return CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, protect,
|
return CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, protect,
|
||||||
static_cast<DWORD>(length >> 32),
|
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); }
|
void CloseFileMappingHandle(FileMappingHandle handle) { CloseHandle(handle); }
|
||||||
|
|
|
@ -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") {
|
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(
|
auto memory = xe::memory::CreateFileMappingHandle(
|
||||||
path, 0x100, xe::memory::PageAccess::kReadWrite, true);
|
path, 0x100, xe::memory::PageAccess::kReadWrite, true);
|
||||||
REQUIRE(memory);
|
REQUIRE(memory);
|
||||||
|
@ -426,7 +426,7 @@ TEST_CASE("create_and_close_file_mapping", "Virtual Memory Mapping") {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("map_view", "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;
|
const size_t length = 0x100;
|
||||||
auto memory = xe::memory::CreateFileMappingHandle(
|
auto memory = xe::memory::CreateFileMappingHandle(
|
||||||
path, length, xe::memory::PageAccess::kReadWrite, true);
|
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") {
|
TEST_CASE("read_write_view", "Virtual Memory Mapping") {
|
||||||
const size_t length = 0x100;
|
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(
|
auto memory = xe::memory::CreateFileMappingHandle(
|
||||||
path, length, xe::memory::PageAccess::kReadWrite, true);
|
path, length, xe::memory::PageAccess::kReadWrite, true);
|
||||||
REQUIRE(memory);
|
REQUIRE(memory);
|
||||||
|
|
|
@ -63,8 +63,7 @@ bool X64CodeCache::Initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create mmap file. This allows us to share the code cache with the debugger.
|
// Create mmap file. This allows us to share the code cache with the debugger.
|
||||||
file_name_ =
|
file_name_ = fmt::format("xenia_code_cache_{}", Clock::QueryHostTickCount());
|
||||||
fmt::format("Local\\xenia_code_cache_{}", Clock::QueryHostTickCount());
|
|
||||||
mapping_ = xe::memory::CreateFileMappingHandle(
|
mapping_ = xe::memory::CreateFileMappingHandle(
|
||||||
file_name_, kGeneratedCodeSize, xe::memory::PageAccess::kExecuteReadWrite,
|
file_name_, kGeneratedCodeSize, xe::memory::PageAccess::kExecuteReadWrite,
|
||||||
false);
|
false);
|
||||||
|
|
|
@ -125,8 +125,7 @@ Memory::~Memory() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Memory::Initialize() {
|
bool Memory::Initialize() {
|
||||||
file_name_ =
|
file_name_ = fmt::format("xenia_memory_{}", Clock::QueryHostTickCount());
|
||||||
fmt::format("Local\\xenia_memory_{}", Clock::QueryHostTickCount());
|
|
||||||
|
|
||||||
// Create main page file-backed mapping. This is all reserved but
|
// Create main page file-backed mapping. This is all reserved but
|
||||||
// uncommitted (so it shouldn't expand page file).
|
// uncommitted (so it shouldn't expand page file).
|
||||||
|
|
Loading…
Reference in New Issue