Skip to content
Permalink
Browse files
Merge pull request #8910 from OatmealDome/os-deprecated-cleanup
Analytics: Replace usage of Gestalt for retrieving macOS version
  • Loading branch information
Tilka committed Aug 8, 2020
2 parents f17b5dd + 0a22df3 commit 6356cc8
Showing 1 changed file with 21 additions and 15 deletions.
@@ -12,7 +12,7 @@
#if defined(_WIN32)
#include <windows.h>
#elif defined(__APPLE__)
#include <CoreServices/CoreServices.h>
#include <objc/message.h>
#elif defined(ANDROID)
#include <functional>
#include "Common/AndroidAnalytics.h"
@@ -268,20 +268,26 @@ void DolphinAnalytics::MakeBaseBuilder()
#elif defined(__APPLE__)
builder.AddData("os-type", "osx");

SInt32 osxmajor, osxminor, osxbugfix;
// Gestalt is deprecated, but the replacement (NSProcessInfo
// operatingSystemVersion) is only available on OS X 10.10, so we need to use
// it anyway. Change this someday when Dolphin depends on 10.10+.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Gestalt(gestaltSystemVersionMajor, &osxmajor);
Gestalt(gestaltSystemVersionMinor, &osxminor);
Gestalt(gestaltSystemVersionBugFix, &osxbugfix);
#pragma GCC diagnostic pop

builder.AddData("osx-ver-major", osxmajor);
builder.AddData("osx-ver-minor", osxminor);
builder.AddData("osx-ver-bugfix", osxbugfix);
// id processInfo = [NSProcessInfo processInfo]
id processInfo = reinterpret_cast<id (*)(Class, SEL)>(objc_msgSend)(
objc_getClass("NSProcessInfo"), sel_getUid("processInfo"));
if (processInfo)
{
struct OSVersion // NSOperatingSystemVersion
{
s64 major_version; // NSInteger majorVersion
s64 minor_version; // NSInteger minorVersion
s64 patch_version; // NSInteger patchVersion
};

// NSOperatingSystemVersion version = [processInfo operatingSystemVersion]
OSVersion version = reinterpret_cast<OSVersion (*)(id, SEL)>(objc_msgSend_stret)(
processInfo, sel_getUid("operatingSystemVersion"));

builder.AddData("osx-ver-major", version.major_version);
builder.AddData("osx-ver-minor", version.minor_version);
builder.AddData("osx-ver-bugfix", version.patch_version);
}
#elif defined(__linux__)
builder.AddData("os-type", "linux");
#elif defined(__FreeBSD__)

0 comments on commit 6356cc8

Please sign in to comment.