diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-05 10:52:02 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-07 15:54:14 +0000 |
commit | 6ae801875ea3c654f808b7ed519b403807653068 (patch) | |
tree | 5dd5369c9e920e6c0a4958cd1e0a4784dcbc3578 /src/corelib | |
parent | bc93ee060abcd746cbed906a51f2379e3da6f379 (diff) |
Re-fix the detection of CPU architecture on an Apple OS
Commit d56c6cf7a4fe2b7e5543d58a786efc768b7370c2 was incorrect. It was a
nice try, but on a 64-bit Mac machine (x86_64 CPU), it returned
hw.cputype = 7, which is CPU_TYPE_X86. CPU_TYPE_X86_64 is only used in
Mach-O slices for fat binaries and does not reflect hw.cputype.
Task-number: QTBUG-61205
Change-Id: Ia3e896da908f42939148fffd14c54b3050b8e64b
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 2176bd8d4a..583acef377 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -86,12 +86,6 @@ # include <sys/systeminfo.h> #endif -#if defined(Q_OS_DARWIN) -# include <mach/machine.h> -# include <sys/sysctl.h> -# include <sys/types.h> -#endif - #ifdef Q_OS_UNIX #include <sys/utsname.h> #include <private/qcore_unix_p.h> @@ -2443,20 +2437,9 @@ QString QSysInfo::currentCpuArchitecture() case PROCESSOR_ARCHITECTURE_IA64: return QStringLiteral("ia64"); } -#elif defined(Q_OS_DARWIN) - cpu_type_t type; - size_t size = sizeof(type); - sysctlbyname("hw.cputype", &type, &size, NULL, 0); - switch (type) { - case CPU_TYPE_X86: - return QStringLiteral("i386"); - case CPU_TYPE_X86_64: - return QStringLiteral("x86_64"); - case CPU_TYPE_ARM: - return QStringLiteral("arm"); - case CPU_TYPE_ARM64: - return QStringLiteral("arm64"); - } +#elif defined(Q_OS_DARWIN) && !defined(Q_OS_MACOS) + // iOS-based OSes do not return the architecture on uname(2)'s result. + return buildCpuArchitecture(); #elif defined(Q_OS_UNIX) long ret = -1; struct utsname u; |