[Linux] Implement virtual memory allocation

This commit is contained in:
uytvbn 2017-10-24 23:12:33 +02:00 committed by Sandy Carter
parent f1b9e1afce
commit 0beed6a9b6
1 changed files with 8 additions and 2 deletions
src/xenia/base

View File

@ -40,7 +40,13 @@ void* AllocFixed(void* base_address, size_t length,
AllocationType allocation_type, PageAccess access) {
// mmap does not support reserve / commit, so ignore allocation_type.
uint32_t prot = ToPosixProtectFlags(access);
return mmap(base_address, length, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
void* result = mmap(base_address, length, prot,
MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);
if (result == MAP_FAILED) {
return nullptr;
} else {
return result;
}
}
bool DeallocFixed(void* base_address, size_t length,
@ -90,7 +96,7 @@ FileMappingHandle CreateFileMappingHandle(std::wstring path, size_t length,
}
void CloseFileMappingHandle(FileMappingHandle handle) {
close((intptr_t)handle);
close(static_cast<int>(reinterpret_cast<int64_t>(handle)));
}
void* MapFileView(FileMappingHandle handle, void* base_address, size_t length,