mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
reuse x86_cpuid from performance.c
This commit is contained in:
parent
8da07f277b
commit
8ecae597e9
@ -49,6 +49,17 @@
|
|||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
#include "platform_linux.h"
|
#include "platform_linux.h"
|
||||||
|
|
||||||
|
/* This small data type is used to represent a CPU list / mask, as read
|
||||||
|
* from sysfs on Linux. See http://www.kernel.org/doc/Documentation/cputopology.txt
|
||||||
|
*
|
||||||
|
* For now, we don't expect more than 32 cores on mobile devices, so keep
|
||||||
|
* everything simple.
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t mask;
|
||||||
|
} CpuList;
|
||||||
|
|
||||||
static bool cpu_inited_once;
|
static bool cpu_inited_once;
|
||||||
static cpu_family g_cpuFamily;
|
static cpu_family g_cpuFamily;
|
||||||
static uint64_t g_cpuFeatures;
|
static uint64_t g_cpuFeatures;
|
||||||
@ -63,24 +74,7 @@ static int g_cpuCount;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
static void cpu_x86_cpuid(int func, int values[4])
|
void x86_cpuid(int func, int flags[4]);
|
||||||
{
|
|
||||||
int a, b, c, d;
|
|
||||||
/* We need to preserve ebx since we're compiling PIC code */
|
|
||||||
/* this means we can't use "=b" for the second output register */
|
|
||||||
__asm__ __volatile__ ( \
|
|
||||||
"push %%ebx\n"
|
|
||||||
"cpuid\n" \
|
|
||||||
"mov %1, %%ebx\n"
|
|
||||||
"pop %%ebx\n"
|
|
||||||
: "=a" (a), "=r" (b), "=c" (c), "=d" (d) \
|
|
||||||
: "a" (func) \
|
|
||||||
);
|
|
||||||
values[0] = a;
|
|
||||||
values[1] = b;
|
|
||||||
values[2] = c;
|
|
||||||
values[3] = d;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __ARM_ARCH__
|
#ifdef __ARM_ARCH__
|
||||||
@ -203,16 +197,6 @@ static const char *parse_decimal(const char* input, const char* limit, int* resu
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This small data type is used to represent a CPU list / mask, as read
|
|
||||||
* from sysfs on Linux. See http://www.kernel.org/doc/Documentation/cputopology.txt
|
|
||||||
*
|
|
||||||
* For now, we don't expect more than 32 cores on mobile devices, so keep
|
|
||||||
* everything simple.
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t mask;
|
|
||||||
} CpuList;
|
|
||||||
|
|
||||||
/* Parse a textual list of cpus and store the result inside a CpuList object.
|
/* Parse a textual list of cpus and store the result inside a CpuList object.
|
||||||
* Input format is the following:
|
* Input format is the following:
|
||||||
@ -431,12 +415,12 @@ static void linux_cpu_init(void)
|
|||||||
#define VENDOR_INTEL_c 0x6c65746e
|
#define VENDOR_INTEL_c 0x6c65746e
|
||||||
#define VENDOR_INTEL_d 0x49656e69
|
#define VENDOR_INTEL_d 0x49656e69
|
||||||
|
|
||||||
cpu_x86_cpuid(0, regs);
|
x86_cpuid(0, regs);
|
||||||
int vendorIsIntel = (regs[1] == VENDOR_INTEL_b &&
|
int vendorIsIntel = (regs[1] == VENDOR_INTEL_b &&
|
||||||
regs[2] == VENDOR_INTEL_c &&
|
regs[2] == VENDOR_INTEL_c &&
|
||||||
regs[3] == VENDOR_INTEL_d);
|
regs[3] == VENDOR_INTEL_d);
|
||||||
|
|
||||||
cpu_x86_cpuid(1, regs);
|
x86_cpuid(1, regs);
|
||||||
if ((regs[2] & (1 << 9)) != 0)
|
if ((regs[2] & (1 << 9)) != 0)
|
||||||
g_cpuFeatures |= CPU_X86_FEATURE_SSSE3;
|
g_cpuFeatures |= CPU_X86_FEATURE_SSSE3;
|
||||||
if ((regs[2] & (1 << 23)) != 0)
|
if ((regs[2] & (1 << 23)) != 0)
|
||||||
|
@ -305,7 +305,7 @@ retro_time_t retro_get_time_usec(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CPU_X86
|
#ifdef CPU_X86
|
||||||
static void x86_cpuid(int func, int flags[4])
|
void x86_cpuid(int func, int flags[4])
|
||||||
{
|
{
|
||||||
/* On Android, we compile RetroArch with PIC, and we
|
/* On Android, we compile RetroArch with PIC, and we
|
||||||
* are not allowed to clobber the ebx register. */
|
* are not allowed to clobber the ebx register. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user