1
0

mptOS.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * mptOS.h
  3. * -------
  4. * Purpose: Operating system version information.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include "mpt/library/library.hpp"
  12. #include "mpt/osinfo/class.hpp"
  13. #include "mpt/osinfo/windows_version.hpp"
  14. OPENMPT_NAMESPACE_BEGIN
  15. namespace mpt
  16. {
  17. namespace OS
  18. {
  19. namespace Windows
  20. {
  21. namespace Version
  22. {
  23. inline constexpr auto WinNT4 = mpt::osinfo::windows::Version::WinNT4;
  24. inline constexpr auto Win2000 = mpt::osinfo::windows::Version::Win2000;
  25. inline constexpr auto WinXP = mpt::osinfo::windows::Version::WinXP;
  26. inline constexpr auto WinXP64 = mpt::osinfo::windows::Version::WinXP64;
  27. inline constexpr auto WinVista = mpt::osinfo::windows::Version::WinVista;
  28. inline constexpr auto Win7 = mpt::osinfo::windows::Version::Win7;
  29. inline constexpr auto Win8 = mpt::osinfo::windows::Version::Win8;
  30. inline constexpr auto Win81 = mpt::osinfo::windows::Version::Win81;
  31. inline constexpr auto Win10 = mpt::osinfo::windows::Version::Win10;
  32. inline constexpr auto WinNewer = mpt::osinfo::windows::Version::WinNewer;
  33. mpt::osinfo::windows::Version Current() noexcept;
  34. mpt::ustring GetName(mpt::osinfo::windows::Version version);
  35. mpt::ustring GetNameShort(mpt::osinfo::windows::Version version);
  36. mpt::osinfo::windows::Version GetMinimumKernelLevel() noexcept;
  37. mpt::osinfo::windows::Version GetMinimumAPILevel() noexcept;
  38. } // namespace Version
  39. #if MPT_OS_WINDOWS
  40. enum class Architecture
  41. {
  42. unknown = -1,
  43. x86 = 0x0401,
  44. amd64 = 0x0801,
  45. arm = 0x0402,
  46. arm64 = 0x0802,
  47. mips = 0x0403,
  48. ppc = 0x0404,
  49. shx = 0x0405,
  50. alpha = 0x0406,
  51. alpha64 = 0x0806,
  52. ia64 = 0x0807,
  53. };
  54. enum class EmulationLevel
  55. {
  56. Native,
  57. Virtual,
  58. Hardware,
  59. Software,
  60. NA,
  61. };
  62. int Bitness(Architecture arch) noexcept;
  63. mpt::ustring Name(Architecture arch);
  64. Architecture GetHostArchitecture() noexcept;
  65. Architecture GetProcessArchitecture() noexcept;
  66. EmulationLevel HostCanRun(Architecture host, Architecture process) noexcept;
  67. std::vector<Architecture> GetSupportedProcessArchitectures(Architecture host);
  68. uint64 GetSystemMemorySize();
  69. #endif // MPT_OS_WINDOWS
  70. #if defined(MODPLUG_TRACKER)
  71. void PreventWineDetection();
  72. bool IsOriginal();
  73. bool IsWine();
  74. #endif // MODPLUG_TRACKER
  75. } // namespace Windows
  76. } // namespace OS
  77. } // namespace mpt
  78. namespace mpt
  79. {
  80. namespace OS
  81. {
  82. namespace Wine
  83. {
  84. class Version
  85. : public mpt::osinfo::windows::wine::version
  86. {
  87. public:
  88. Version();
  89. Version(uint8 vmajor, uint8 vminor, uint8 vupdate);
  90. explicit Version(const mpt::ustring &version);
  91. public:
  92. mpt::ustring AsString() const;
  93. };
  94. mpt::OS::Wine::Version GetMinimumWineVersion();
  95. class VersionContext
  96. {
  97. protected:
  98. bool m_IsWine;
  99. std::string m_RawVersion;
  100. std::string m_RawBuildID;
  101. std::string m_RawHostSysName;
  102. std::string m_RawHostRelease;
  103. mpt::OS::Wine::Version m_Version;
  104. mpt::osinfo::osclass m_HostClass;
  105. public:
  106. VersionContext();
  107. public:
  108. bool IsWine() const { return m_IsWine; }
  109. std::string RawVersion() const { return m_RawVersion; }
  110. std::string RawBuildID() const { return m_RawBuildID; }
  111. std::string RawHostSysName() const { return m_RawHostSysName; }
  112. std::string RawHostRelease() const { return m_RawHostRelease; }
  113. mpt::OS::Wine::Version Version() const { return m_Version; }
  114. mpt::osinfo::osclass HostClass() const { return m_HostClass; }
  115. };
  116. } // namespace Wine
  117. } // namespace OS
  118. } // namespace mpt
  119. OPENMPT_NAMESPACE_END