aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/misc/mptOS.h
blob: c6640bd2ac320a2c3da36849e0d8de923d845e86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
 * mptOS.h
 * -------
 * Purpose: Operating system version information.
 * Notes  : (currently none)
 * Authors: OpenMPT Devs
 * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
 */


#pragma once

#include "openmpt/all/BuildSettings.hpp"

#include "mpt/library/library.hpp"
#include "mpt/osinfo/class.hpp"
#include "mpt/osinfo/windows_version.hpp"


OPENMPT_NAMESPACE_BEGIN


namespace mpt
{
namespace OS
{
namespace Windows
{

namespace Version
{

	inline constexpr auto WinNT4 = mpt::osinfo::windows::Version::WinNT4;
	inline constexpr auto Win2000 = mpt::osinfo::windows::Version::Win2000;
	inline constexpr auto WinXP = mpt::osinfo::windows::Version::WinXP;
	inline constexpr auto WinXP64 = mpt::osinfo::windows::Version::WinXP64;
	inline constexpr auto WinVista = mpt::osinfo::windows::Version::WinVista;
	inline constexpr auto Win7 = mpt::osinfo::windows::Version::Win7;
	inline constexpr auto Win8 = mpt::osinfo::windows::Version::Win8;
	inline constexpr auto Win81 = mpt::osinfo::windows::Version::Win81;
	inline constexpr auto Win10 = mpt::osinfo::windows::Version::Win10;
	inline constexpr auto WinNewer = mpt::osinfo::windows::Version::WinNewer;

	mpt::osinfo::windows::Version Current() noexcept;

	mpt::ustring GetName(mpt::osinfo::windows::Version version);
	mpt::ustring GetNameShort(mpt::osinfo::windows::Version version);

	mpt::osinfo::windows::Version GetMinimumKernelLevel() noexcept;
	mpt::osinfo::windows::Version GetMinimumAPILevel() noexcept;

} // namespace Version

#if MPT_OS_WINDOWS

enum class Architecture
{
	unknown = -1,

	x86     = 0x0401,
	amd64   = 0x0801,
	arm     = 0x0402,
	arm64   = 0x0802,

	mips    = 0x0403,
	ppc     = 0x0404,
	shx     = 0x0405,

	alpha   = 0x0406,
	alpha64 = 0x0806,

	ia64    = 0x0807,
};

enum class EmulationLevel
{
	Native,
	Virtual,
	Hardware,
	Software,
	NA,
};

int Bitness(Architecture arch) noexcept;

mpt::ustring Name(Architecture arch);

Architecture GetHostArchitecture() noexcept;
Architecture GetProcessArchitecture() noexcept;

EmulationLevel HostCanRun(Architecture host, Architecture process) noexcept;

std::vector<Architecture> GetSupportedProcessArchitectures(Architecture host);

uint64 GetSystemMemorySize();

#endif // MPT_OS_WINDOWS


#if defined(MODPLUG_TRACKER)

void PreventWineDetection();

bool IsOriginal();
bool IsWine();

#endif // MODPLUG_TRACKER

} // namespace Windows
} // namespace OS
} // namespace mpt


namespace mpt
{
namespace OS
{
namespace Wine
{

class Version
	: public mpt::osinfo::windows::wine::version
{
public:
	Version();
	Version(uint8 vmajor, uint8 vminor, uint8 vupdate);
	explicit Version(const mpt::ustring &version);
public:
	mpt::ustring AsString() const;
};

mpt::OS::Wine::Version GetMinimumWineVersion();

class VersionContext
{
protected:
	bool m_IsWine;
	std::string m_RawVersion;
	std::string m_RawBuildID;
	std::string m_RawHostSysName;
	std::string m_RawHostRelease;
	mpt::OS::Wine::Version m_Version;
	mpt::osinfo::osclass m_HostClass;
public:
	VersionContext();
public:
	bool IsWine() const { return m_IsWine; }
	std::string RawVersion() const { return m_RawVersion; }
	std::string RawBuildID() const { return m_RawBuildID; }
	std::string RawHostSysName() const { return m_RawHostSysName; }
	std::string RawHostRelease() const { return m_RawHostRelease; }
	mpt::OS::Wine::Version Version() const { return m_Version; }
	mpt::osinfo::osclass HostClass() const { return m_HostClass; }
};

} // namespace Wine
} // namespace OS
} // namespace mpt


OPENMPT_NAMESPACE_END