Re-fix the detection of CPU architecture on an Apple OS
Commit d56c6cf7a4 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>
bb10
parent
bc93ee060a
commit
6ae801875e
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue