Fix the CPU name detection on AARCH64 macOS

This commit is contained in:
Stan 2024-09-25 23:34:43 +02:00
parent 86a4092e55
commit 67464ebbaa
No known key found for this signature in database
GPG key ID: 244943DFF8370D60

View file

@ -27,8 +27,35 @@
#include "precompiled.h"
#include "lib/sysdep/cpu.h"
#include "lib/sysdep/os.h"
#if defined OS_MAC
#include <cstdlib>
#include <cstddef>
#include <sys/sysctl.h>
#endif
const char* cpu_IdentifierString()
{
#if defined(OS_MAC)
size_t bufferSize = 0;
if (sysctlbyname("machdep.cpu.brand_string", nullptr, &bufferSize, nullptr, 0) != 0) {
return "unknown";
}
char* result = static_cast<char*>(malloc(bufferSize));
if (!result) {
return "unknown";
}
if (sysctlbyname("machdep.cpu.brand_string", result, &bufferSize, nullptr, 0) != 0) {
free(result);
return "unknown";
}
return result;
#else
return "unknown"; // TODO
#endif
}