dolphin/Source/Core/Common/MemArena.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
845 B
C
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
2015-05-17 23:08:10 +00:00
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <cstddef>
#ifdef _WIN32
#include <windows.h>
#endif
#include "Common/CommonTypes.h"
namespace Common
{
// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
// Multiple views can mirror the same section of the block, which makes it very convenient for
// emulating
// memory mirrors.
class MemArena
{
public:
void GrabSHMSegment(size_t size);
void ReleaseSHMSegment();
2016-01-21 20:16:51 +00:00
void* CreateView(s64 offset, size_t size, void* base = nullptr);
void ReleaseView(void* view, size_t size);
// This finds 1 GB in 32-bit, 16 GB in 64-bit.
2016-01-21 20:16:51 +00:00
static u8* FindMemoryBase();
private:
#ifdef _WIN32
HANDLE hMemoryMapping;
#else
int fd;
#endif
};
} // namespace Common