mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Fix the CPU name detection on AARCH64 macOS
This commit is contained in:
parent
86a4092e55
commit
67464ebbaa
1 changed files with 27 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue