1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-24 11:43:05 +01:00

Implement proper macOS version check (#11352)

This commit is contained in:
nastys 2022-01-11 23:17:26 +01:00 committed by GitHub
parent 0d1c0e72a6
commit ef66b002e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#import <Foundation/Foundation.h>
namespace Darwin_Version
{
NSOperatingSystemVersion osver = NSProcessInfo.processInfo.operatingSystemVersion;
int getNSmajorVersion()
{
return osver.majorVersion;
}
int getNSminorVersion()
{
return osver.minorVersion;
}
int getNSpatchVersion()
{
return osver.patchVersion;
}
}

View File

@ -59,6 +59,11 @@ target_sources(rpcs3_emu PRIVATE
../../Utilities/Thread.cpp
../../Utilities/version.cpp
)
if(APPLE)
target_sources(rpcs3_emu PRIVATE
../../darwin/util/sysinfo_darwin.mm
)
endif()
target_include_directories(rpcs3_emu PUBLIC "${CMAKE_SOURCE_DIR}")

View File

@ -12,9 +12,11 @@
#else
#include <unistd.h>
#include <sys/resource.h>
#ifndef __APPLE__
#include <sys/utsname.h>
#include <errno.h>
#endif
#endif
#include "util/asm.hpp"
@ -47,6 +49,16 @@ inline u64 utils::get_xgetbv(u32 xcr)
#endif
}
#ifdef __APPLE__
// sysinfo_darwin.mm
namespace Darwin_Version
{
extern int getNSmajorVersion();
extern int getNSminorVersion();
extern int getNSpatchVersion();
}
#endif
bool utils::has_ssse3()
{
static const bool g_value = get_cpuid(0, 0)[0] >= 0x1 && get_cpuid(1, 0)[2] & 0x200;
@ -343,6 +355,13 @@ std::string utils::get_OS_version()
fmt::append(output,
"Operating system: Windows, Major: %lu, Minor: %lu, Build: %u, Service Pack: %s, Compatibility mode: %llu",
version_major, version_minor, build, has_sp ? holder.data() : "none", compatibility_mode);
#elif defined (__APPLE__)
const int major_version = Darwin_Version::getNSmajorVersion();
const int minor_version = Darwin_Version::getNSminorVersion();
const int patch_version = Darwin_Version::getNSpatchVersion();
fmt::append(output, "Operating system: macOS, Version: %d.%d.%d",
major_version, minor_version, patch_version);
#else
struct utsname details = {};