summaryrefslogtreecommitdiff
path: root/Source/Core/Common/ArmCPUDetect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/ArmCPUDetect.cpp')
-rw-r--r--Source/Core/Common/ArmCPUDetect.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/Source/Core/Common/ArmCPUDetect.cpp b/Source/Core/Common/ArmCPUDetect.cpp
index 90cc0f7b44..68a29caa45 100644
--- a/Source/Core/Common/ArmCPUDetect.cpp
+++ b/Source/Core/Common/ArmCPUDetect.cpp
@@ -18,13 +18,18 @@
#elif defined(__linux__)
#include <asm/hwcap.h>
#include <sys/auxv.h>
-#elif defined(__FreeBSD__)
+#elif defined(HAVE_ELF_AUX_INFO)
#include <sys/auxv.h>
#elif defined(__OpenBSD__)
#include <machine/armreg.h>
#include <machine/cpu.h>
-#include <sys/sysctl.h>
+#endif
+
+#ifdef __OpenBSD__
+// clang-format off
#include <sys/types.h>
+#include <sys/sysctl.h>
+// clang-format on
#endif
#include <fmt/format.h>
@@ -142,13 +147,13 @@ static bool Read_MIDR_EL1_Sysfs(u64* value)
#endif
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
static u32 ReadHwCap(u32 type)
{
#if defined(__linux__)
return getauxval(type);
-#elif defined(__FreeBSD__)
+#elif defined(HAVE_ELF_AUX_INFO)
u_long hwcap = 0;
elf_aux_info(type, &hwcap, sizeof(hwcap));
return hwcap;
@@ -189,7 +194,7 @@ static bool Read_MIDR_EL1(u64* value)
#endif
-#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__)
+#if defined(_WIN32) || defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
static std::string MIDRToString(u64 midr)
{
@@ -254,11 +259,21 @@ void CPUInfo::Detect()
{
cpu_id = MIDRToString(reg);
}
-#elif defined(__linux__) || defined(__FreeBSD__)
- // Linux, Android, and FreeBSD
+#elif defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
+ // Linux, Android, FreeBSD and OpenBSD with elf_aux_info
#if defined(__FreeBSD__)
SysctlByName(&model_name, "hw.model");
+#elif defined(__OpenBSD__)
+ int mib[2];
+ size_t len;
+ char hwmodel[256];
+
+ mib[0] = CTL_HW;
+ mib[1] = HW_MODEL;
+ len = std::size(hwmodel);
+ if (sysctl(mib, 2, &hwmodel, &len, nullptr, 0) != -1)
+ model_name = std::string(hwmodel, len - 1);
#elif defined(__linux__)
if (!ReadDeviceTree(&model_name, "model"))
{