mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 07:39:26 +01:00
ArmCPUDetect: Add OpenBSD support for elf_aux_info
This commit is contained in:
parent
05cad38abc
commit
021e0dde7d
@ -68,6 +68,11 @@ endif()
|
|||||||
add_definitions(-D__STDC_LIMIT_MACROS)
|
add_definitions(-D__STDC_LIMIT_MACROS)
|
||||||
add_definitions(-D__STDC_CONSTANT_MACROS)
|
add_definitions(-D__STDC_CONSTANT_MACROS)
|
||||||
|
|
||||||
|
check_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
|
||||||
|
if(HAVE_ELF_AUX_INFO)
|
||||||
|
add_definitions(-DHAVE_ELF_AUX_INFO)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(Core)
|
add_subdirectory(Core)
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
add_subdirectory(Android/jni)
|
add_subdirectory(Android/jni)
|
||||||
|
@ -18,13 +18,16 @@
|
|||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#include <asm/hwcap.h>
|
#include <asm/hwcap.h>
|
||||||
#include <sys/auxv.h>
|
#include <sys/auxv.h>
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(HAVE_ELF_AUX_INFO)
|
||||||
#include <sys/auxv.h>
|
#include <sys/auxv.h>
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
#include <machine/armreg.h>
|
#include <machine/armreg.h>
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#include <sys/sysctl.h>
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
@ -142,13 +145,13 @@ static bool Read_MIDR_EL1_Sysfs(u64* value)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__)
|
#if defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
|
||||||
|
|
||||||
static u32 ReadHwCap(u32 type)
|
static u32 ReadHwCap(u32 type)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
return getauxval(type);
|
return getauxval(type);
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(HAVE_ELF_AUX_INFO)
|
||||||
u_long hwcap = 0;
|
u_long hwcap = 0;
|
||||||
elf_aux_info(type, &hwcap, sizeof(hwcap));
|
elf_aux_info(type, &hwcap, sizeof(hwcap));
|
||||||
return hwcap;
|
return hwcap;
|
||||||
@ -189,7 +192,7 @@ static bool Read_MIDR_EL1(u64* value)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__linux__) || defined(__FreeBSD__)
|
#if defined(_WIN32) || defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
|
||||||
|
|
||||||
static std::string MIDRToString(u64 midr)
|
static std::string MIDRToString(u64 midr)
|
||||||
{
|
{
|
||||||
@ -254,11 +257,21 @@ void CPUInfo::Detect()
|
|||||||
{
|
{
|
||||||
cpu_id = MIDRToString(reg);
|
cpu_id = MIDRToString(reg);
|
||||||
}
|
}
|
||||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
#elif defined(__linux__) || defined(HAVE_ELF_AUX_INFO)
|
||||||
// Linux, Android, and FreeBSD
|
// Linux, Android, FreeBSD and OpenBSD with elf_aux_info
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
SysctlByName(&model_name, "hw.model");
|
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__)
|
#elif defined(__linux__)
|
||||||
if (!ReadDeviceTree(&model_name, "model"))
|
if (!ReadDeviceTree(&model_name, "model"))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user