Files
FEX-Emu--FEX/Source/Tests/LinuxSyscalls/LinuxAllocator.h
T
Ryan Houdek bb7f542813 Linux: Emulate MAP_32BIT on mmap
Previous we were just using an address hint to emulate MAP_32BIT.
Seemingly this behaviour has changed on AArch64 where it now isn't
guaranteed to scan up from the hint provided if exact allocation fails.

Now we pull in the full 32-bit allocator and add support for MAP_32BIT
in it. This limits the allocations there in to the first 2GB which Linux
expects.

Necessary for Mono's trampolines to work since it requires code to be in
the first 2GB on x86-64.
2021-11-12 21:25:15 -08:00

22 lines
758 B
C++

#pragma once
#include <cstdint>
#include <memory>
namespace FEX::HLE {
constexpr uint32_t X86_64_MAP_32BIT = 0x40;
class MemAllocator {
public:
virtual ~MemAllocator() = default;
virtual void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) = 0;
virtual int munmap(void *addr, size_t length) = 0;
virtual void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address) = 0;
virtual uint64_t shmat(int shmid, const void* shmaddr, int shmflg, uint32_t *ResultAddress) = 0;
virtual uint64_t shmdt(const void* shmaddr) = 0;
};
std::unique_ptr<FEX::HLE::MemAllocator> Create32BitAllocator();
std::unique_ptr<FEX::HLE::MemAllocator> CreatePassthroughAllocator();
}