gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit ed8606f27bf72a2b4950f0253a74c12f1635a547
parent ff6393af86b4fd478a9c0fa048b4cc802c209dbf
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue, 23 Apr 2024 21:10:55 +0200

add warning if running under Rosetta

Diffstat:
Msource/synthLib/os.cpp | 22++++++++++++++++++++++
Msource/synthLib/os.h | 2++
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/source/synthLib/os.cpp b/source/synthLib/os.cpp @@ -30,6 +30,11 @@ #include <immintrin.h> #endif +#ifdef __APPLE__ +#include <sys/types.h> +#include <sys/sysctl.h> +#endif + namespace synthLib { std::string getModulePath(bool _stripPluginComponentFolders/* = true*/) @@ -390,4 +395,21 @@ namespace synthLib return fopen(_name.c_str(), _mode); #endif } + + bool isRunningUnderRosetta() + { +#ifdef __APPLE__ + int ret = 0; + size_t size = sizeof(ret); + if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) + { + if (errno == ENOENT) + return false; // no, native + return false; // unable to tell, assume native + } + return ret == 1; // Rosetta if result is 1 +#else + return false; +#endif + } } // namespace synthLib diff --git a/source/synthLib/os.h b/source/synthLib/os.h @@ -44,4 +44,6 @@ namespace synthLib bool readFile(std::vector<uint8_t>& _data, const std::string& _filename); FILE* openFile(const std::string& _name, const char* _mode); + + bool isRunningUnderRosetta(); } // namespace synthLib