CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/MemArena.h
Views: 1401
1
// Copyright (C) 2003 Dolphin Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official SVN repository and contact information can be found at
16
// http://code.google.com/p/dolphin-emu/
17
18
#pragma once
19
20
#include <cstdint>
21
22
#ifdef _WIN32
23
#include "CommonWindows.h"
24
#elif defined(__APPLE__)
25
#include <mach/mach.h>
26
#endif
27
28
#include "Common/CommonTypes.h"
29
30
// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
31
// Multiple views can mirror the same section of the block, which makes it very convient for emulating
32
// memory mirrors.
33
34
struct MemArenaData;
35
36
class MemArena {
37
public:
38
size_t roundup(size_t x);
39
bool GrabMemSpace(size_t size);
40
void ReleaseSpace();
41
void *CreateView(s64 offset, size_t size, void *base = 0);
42
void ReleaseView(s64 offset, void *view, size_t size);
43
44
// This only finds 1 GB in 32-bit
45
u8 *Find4GBBase();
46
bool NeedsProbing();
47
48
private:
49
#ifdef _WIN32
50
HANDLE hMemoryMapping;
51
SYSTEM_INFO sysInfo;
52
#elif defined(__APPLE__)
53
size_t vm_size;
54
vm_address_t vm_mem; // same type as vm_address_t
55
#else
56
int fd = -1;
57
#endif
58
};
59
60