Chromium Code Reviews| Index: webrtc/base/macutils.cc |
| diff --git a/webrtc/base/macutils.cc b/webrtc/base/macutils.cc |
| index c05526affb73fb36d0f8f28113ebc951849b7f98..eb69b73c8902178de447c09c652d63d76c34de76 100644 |
| --- a/webrtc/base/macutils.cc |
| +++ b/webrtc/base/macutils.cc |
| @@ -8,10 +8,11 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| +#include <cstring> |
| #include <memory> |
| #include <sstream> |
| -#include <CoreServices/CoreServices.h> |
| +#include <sys/utsname.h> |
| #include "webrtc/base/common.h" |
| #include "webrtc/base/logging.h" |
| @@ -70,34 +71,25 @@ void DecodeFourChar(UInt32 fc, std::string* out) { |
| out->append(ss.str()); |
| } |
| -static bool GetGestalt(OSType ostype, int* value) { |
| - ASSERT(NULL != value); |
| - SInt32 native_value; |
| - OSStatus result = Gestalt(ostype, &native_value); |
| - if (noErr == result) { |
| - *value = native_value; |
| - return true; |
| - } |
| - std::string str; |
| - DecodeFourChar(ostype, &str); |
| - LOG_E(LS_ERROR, OS, result) << "Gestalt(" << str << ")"; |
| - return false; |
| -} |
| - |
| static bool GetOSVersion(int* major, int* minor, int* bugfix) { |
| ASSERT(major && minor && bugfix); |
| - if (!GetGestalt(gestaltSystemVersion, major)) { |
| + struct utsname uname_info; |
| + if (uname(&uname_info) != 0) |
| return false; |
| - } |
| - if (*major < 0x1040) { |
| - *bugfix = *major & 0xF; |
| - *minor = (*major >> 4) & 0xF; |
| - *major = (*major >> 8); |
| - return true; |
| - } |
| - return GetGestalt(gestaltSystemVersionMajor, major) && |
| - GetGestalt(gestaltSystemVersionMinor, minor) && |
| - GetGestalt(gestaltSystemVersionBugFix, bugfix); |
| + |
| + if (strcmp(uname_info.sysname, "Darwin") != 0) |
| + return false; |
| + *major = 10; |
| + |
| + // The market version of macOS is always 4 lower than the internal version. |
|
kthelgason
2016/10/05 18:23:26
This should not be relied upon. Though there has b
erikchen
2016/10/05 20:16:35
-[NSProcessInfo operatingSystemVersion] isn't avai
Sergey Ulanov
2016/10/05 23:04:45
Maybe add CHECK(atoi(uname_info.release) >= 6) her
erikchen
2016/10/05 23:48:43
Done.
|
| + *minor = atoi(uname_info.release) - 4; |
| + |
| + char delimiter = '.'; |
| + const char* dot = strchr(uname_info.release, &delimiter); |
|
Sergey Ulanov
2016/10/05 23:04:45
strchr() takes char as the second argument, but yo
erikchen
2016/10/05 23:48:43
webrtc uses an inlined strchr that has a different
Sergey Ulanov
2016/10/07 00:08:46
This is a wchar_t version, which I don't think is
erikchen
2016/10/07 00:31:02
ah, yup, switched to ::strchr().
|
| + if (!dot) |
| + return false; |
| + *bugfix = atoi(dot + 1); |
| + return true; |
| } |
| MacOSVersionName GetOSVersionName() { |