Hi there,
I need to be able to check whether a plugin is being run in rosetta as there are some tricky compatibility issues.
I tried using:
#if (JUCE_ARM && JUCE_MAC)
which works for detecting an M1 mac not running Rossetta - but presumably the JUCE_ARM define is set to false if ran as translated from x86-64
Thanks
1 Like
chkn
3
Quick Solution
#ifdef JUCE_INTEL
if (SystemStats::getCpuModel().containsIgnoreCase ("Apple"))
{
runsUnderRosetta = true;
};
#endif
2 Likes
int rosetta = 0;
size_t rosettaSize = sizeof ( rosetta );
if ( sysctlbyname ( "sysctl.proc_translated", &rosetta, &rosettaSize, nullptr, 0) == 0)
{
if ( rosetta == 1 )
{
return true;
}
}
3 Likes
Based on @RolandMR’s answer, this is my complete snippet for desktop applications.
#ifdef JUCE_MAC
#include <sys/types.h>
#include <sys/sysctl.h>
// Source: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment
int processIsTranslated() {
int ret = 0;
size_t size = sizeof(ret);
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1)
{
if (errno == ENOENT)
return 0;
return -1;
}
return ret;
}
#endif
String cpuDescription()
{
String cpuType = "Intel";
#ifdef JUCE_MAC
if (processIsTranslated() == 1) {
cpuType = "Intel (Rosetta)";
} else if (SystemStats::getCpuModel().containsIgnoreCase("Apple")) {
cpuType = "Apple Silicon";
}
#endif
return cpuType;
}