macOS: Add helper function to check whether we're running under Rosetta
As described in https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment?language=objc#Determine-Whether-Your-App-Is-Running-as-a-Translated-Binary Pick-to: 6.2 Change-Id: I16fa4be20e4a55c87c2eb760d671d27ee4de1703 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>bb10
parent
25170b324b
commit
df62fdb51c
|
|
@ -54,6 +54,7 @@
|
|||
#include <cxxabi.h>
|
||||
#include <objc/runtime.h>
|
||||
#include <mach-o/dyld.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <qdebug.h>
|
||||
|
||||
|
|
@ -366,6 +367,15 @@ bool qt_mac_applicationIsInDarkMode()
|
|||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool qt_mac_runningUnderRosetta()
|
||||
{
|
||||
int translated = 0;
|
||||
auto size = sizeof(translated);
|
||||
if (sysctlbyname("sysctl.proc_translated", &translated, &size, nullptr, 0) == 0)
|
||||
return translated;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool qt_apple_isApplicationExtension()
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ private:
|
|||
|
||||
#ifdef Q_OS_MACOS
|
||||
Q_CORE_EXPORT bool qt_mac_applicationIsInDarkMode();
|
||||
Q_CORE_EXPORT bool qt_mac_runningUnderRosetta();
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
|
|
|||
Loading…
Reference in New Issue