[Linux] Implement virtual memory allocation
This commit is contained in:
parent
f1b9e1afce
commit
0beed6a9b6
src/xenia/base
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue