mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 14:45:41 +12:00
* PCSX2 fastmem depression * Move away from PCSX2 fastmem * Add enum_flag_ops.hpp * Finally building on Windows * Almost got a PoC * Fix arm64 builds * This somehow works * This also works... * Properly fix fastmem * Add free region manager * Update boost * Add ScopeExit * Comment out asserts on Linux/Mac/Android * Comment out ASSERT_MSG asserts too * Fix derp * Attempt to fix Android * Disable fastmem on Android * Fix Android again maybe pt 2 * android pls * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Update host_memory.cpp * Properly reset memory arena on reset * Proper ashmem code for Android * more * Add temporary Android buildjet script for faster prototype builds * Fix fastmem (again) * Clean up shared memory
47 lines
No EOL
999 B
C++
47 lines
No EOL
999 B
C++
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#else
|
|
#include <sys/mman.h>
|
|
#endif
|
|
|
|
#include "host_memory/virtual_buffer.h"
|
|
|
|
namespace Common {
|
|
|
|
void* AllocateMemoryPages(std::size_t size) noexcept {
|
|
#ifdef _WIN32
|
|
void* base{VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE)};
|
|
#else
|
|
void* base{mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0)};
|
|
|
|
if (base == MAP_FAILED) {
|
|
base = nullptr;
|
|
}
|
|
#endif
|
|
|
|
if (!base) {
|
|
Helpers::panic("Failed to allocate memory pages");
|
|
}
|
|
|
|
return base;
|
|
}
|
|
|
|
void FreeMemoryPages(void* base, [[maybe_unused]] std::size_t size) noexcept {
|
|
if (!base) {
|
|
return;
|
|
}
|
|
#ifdef _WIN32
|
|
if (!VirtualFree(base, 0, MEM_RELEASE)) {
|
|
Helpers::panic("Failed to free memory pages");
|
|
}
|
|
#else
|
|
if (munmap(base, size) != 0) {
|
|
Helpers::panic("Failed to free memory pages");
|
|
}
|
|
#endif
|
|
}
|
|
|
|
} // namespace Common
|