Improve CPU architecture and model name identification for Miyoo (#13704)

* features_cpu: Return model name on non-x86 Linux platforms

Extract model name from /proc/cpuinfo.

* platform/unix: Rework identification of classic Arm CPUs

Identify pre-ARMv7 CPUs based on the machine hardware name starting with
"arm" instead of matching every individual variant. This will then
include the ARM926EJ-S which has armv5tejl as its machine hardware name.
This commit is contained in:
jSTE0 2022-03-09 20:27:12 +00:00 committed by GitHub
parent c67806dbd7
commit 715c054de5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 8 deletions

View File

@ -1274,12 +1274,7 @@ static enum frontend_architecture frontend_unix_get_arch(void)
string_is_equal(val, "armv7b")
)
return FRONTEND_ARCH_ARMV7;
else if (
string_is_equal(val, "armv6l") ||
string_is_equal(val, "armv6b") ||
string_is_equal(val, "armv5tel") ||
string_is_equal(val, "arm")
)
else if (string_starts_with(val, "arm"))
return FRONTEND_ARCH_ARM;
else if (string_is_equal(val, "x86_64"))
return FRONTEND_ARCH_X86_64;

View File

@ -46,8 +46,8 @@
#if defined(_XBOX360)
#include <PPCIntrinsics.h>
#elif !defined(__MACH__) && (defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) || defined(__PPC64__) || defined(__powerpc64__))
#ifndef _PPU_INTRINSICS_H
#include <ppu_intrinsics.h>
#ifndef _PPU_INTRINSICS_H
#include <ppu_intrinsics.h>
#endif
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(ANDROID) || defined(__QNX__) || defined(DJGPP)
/* POSIX_MONOTONIC_CLOCK is not being defined in Android headers despite support being present. */
@ -871,6 +871,35 @@ end:
size_t len_size = len;
sysctlbyname("machdep.cpu.brand_string", name, &len_size, NULL, 0);
}
#elif defined(__linux__)
if (!name)
return;
{
char *model_name, line[128];
RFILE *fp = filestream_open("/proc/cpuinfo",
RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (!fp)
return;
while (filestream_gets(fp, line, sizeof(line)))
{
if (strncmp(line, "model name", 10))
continue;
if ((model_name = strstr(line + 10, ": ")))
{
model_name += 2;
strncpy(name, model_name, len);
name[len - 1] = '\0';
}
break;
}
filestream_close(fp);
}
#else
if (!name)
return;