mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-06 06:55:09 +00:00
rx/mem: cross platform implementation
Some checks are pending
Formatting check / formatting-check (push) Waiting to run
Build RPCSX / build-linux (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.1-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.2-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.4-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.5-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv9-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv9.1-a) (push) Waiting to run
Build RPCSX / build-android (x86_64, x86-64) (push) Waiting to run
Some checks are pending
Formatting check / formatting-check (push) Waiting to run
Build RPCSX / build-linux (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.1-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.2-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.4-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv8.5-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv9-a) (push) Waiting to run
Build RPCSX / build-android (arm64-v8a, armv9.1-a) (push) Waiting to run
Build RPCSX / build-android (x86_64, x86-64) (push) Waiting to run
fixed compilation errors avoid memfd_create usage on android
This commit is contained in:
parent
0bc167ea87
commit
3ffece2d77
10 changed files with 293 additions and 163 deletions
|
|
@ -2,21 +2,11 @@
|
|||
|
||||
#include "AddressRange.hpp"
|
||||
#include "EnumBitSet.hpp"
|
||||
#include "mem.hpp"
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
namespace rx {
|
||||
enum class Protection {
|
||||
R,
|
||||
W,
|
||||
X,
|
||||
|
||||
bitset_last = X
|
||||
};
|
||||
|
||||
std::errc reserveVirtualSpace(rx::AddressRange range);
|
||||
std::errc releaseVirtualSpace(rx::AddressRange range, std::size_t alignment);
|
||||
|
||||
class Mappable {
|
||||
#ifdef _WIN32
|
||||
using NativeHandle = void *;
|
||||
|
|
@ -46,7 +36,8 @@ public:
|
|||
static std::pair<Mappable, std::errc> CreateMemory(std::size_t size);
|
||||
static std::pair<Mappable, std::errc> CreateSwap(std::size_t size);
|
||||
std::errc map(rx::AddressRange virtualRange, std::size_t offset,
|
||||
rx::EnumBitSet<Protection> protection, std::size_t alignment);
|
||||
rx::EnumBitSet<mem::Protection> protection,
|
||||
std::size_t alignment);
|
||||
|
||||
[[nodiscard]] NativeHandle release() {
|
||||
return std::exchange(m_handle, kInvalidHandle);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include "AddressRange.hpp"
|
||||
#include "EnumBitSet.hpp"
|
||||
#include <cstddef>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
namespace rx::mem {
|
||||
enum class Protection {
|
||||
R,
|
||||
W,
|
||||
X,
|
||||
|
||||
bitset_last = X
|
||||
};
|
||||
|
||||
struct VirtualQueryEntry : rx::AddressRange {
|
||||
rx::EnumBitSet<Protection> flags{};
|
||||
|
||||
VirtualQueryEntry() = default;
|
||||
VirtualQueryEntry(rx::AddressRange range, rx::EnumBitSet<Protection> prot)
|
||||
: AddressRange(range), flags(prot) {}
|
||||
};
|
||||
|
||||
extern const std::size_t pageSize;
|
||||
void *map(void *address, std::size_t size, int prot, int flags, int fd = -1,
|
||||
std::ptrdiff_t offset = 0);
|
||||
void *reserve(std::size_t size);
|
||||
bool reserve(void *address, std::size_t size);
|
||||
bool protect(void *address, std::size_t size, int prot);
|
||||
bool unmap(void *address, std::size_t size);
|
||||
void printStats();
|
||||
std::errc reserve(rx::AddressRange range);
|
||||
std::errc release(rx::AddressRange range, std::size_t alignment);
|
||||
std::errc protect(rx::AddressRange range, rx::EnumBitSet<Protection> prot);
|
||||
std::vector<VirtualQueryEntry> query(rx::AddressRange range);
|
||||
} // namespace rx::mem
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue