From 6ae801875ea3c654f808b7ed519b403807653068 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 5 Jun 2017 10:52:02 -0700 Subject: [PATCH] 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 --- src/corelib/global/qglobal.cpp | 23 +++-------------------- 1 file 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 #endif -#if defined(Q_OS_DARWIN) -# include -# include -# include -#endif - #ifdef Q_OS_UNIX #include #include @@ -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;