Refactor performance_android.c to performance_linux.c - compile it in for Linux too
This commit is contained in:
parent
83d082000f
commit
7bd5ec0ffe
|
@ -81,6 +81,7 @@ ifneq ($(findstring Linux,$(OS)),)
|
|||
JOYCONFIG_LIBS += -lrt -lpthread
|
||||
OBJ += input/drivers/linuxraw_input.o \
|
||||
input/drivers_joypad/linuxraw_joypad.o \
|
||||
performance/performance_linux.o \
|
||||
frontend/drivers/platform_linux.o
|
||||
endif
|
||||
|
||||
|
|
|
@ -49,8 +49,8 @@ CONSOLE EXTENSIONS
|
|||
PERFORMANCE
|
||||
============================================================ */
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "../performance/performance_android.c"
|
||||
#if defined(__linux__)
|
||||
#include "../performance/performance_linux.c"
|
||||
#endif
|
||||
|
||||
#include "../performance.c"
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include "general.h"
|
||||
#include "compat/strl.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
#include "performance/performance_android.h"
|
||||
#if defined(__linux__)
|
||||
#include "performance/performance_linux.h"
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(RARCH_CONSOLE)
|
||||
|
@ -364,7 +364,7 @@ unsigned rarch_get_cpu_cores(void)
|
|||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
#elif defined(ANDROID)
|
||||
return android_getCpuCount();
|
||||
return linux_get_cpu_count();
|
||||
#elif defined(GEKKO)
|
||||
return 1;
|
||||
#elif defined(PSP)
|
||||
|
@ -505,7 +505,7 @@ uint64_t rarch_get_cpu_features(void)
|
|||
}
|
||||
|
||||
#elif defined(ANDROID) && defined(ANDROID_ARM)
|
||||
cpu_flags = android_getCpuFeatures();
|
||||
cpu_flags = linux_get_cpu_features();
|
||||
|
||||
#ifdef __ARM_NEON__
|
||||
if (cpu_flags & CPU_ARM_FEATURE_NEON)
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef CPU_FEATURES_H
|
||||
#define CPU_FEATURES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <retro_log.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CPU_FAMILY_UNKNOWN = 0,
|
||||
CPU_FAMILY_ARM,
|
||||
CPU_FAMILY_X86,
|
||||
CPU_FAMILY_MIPS,
|
||||
|
||||
CPU_FAMILY_MAX /* do not remove */
|
||||
} cpu_family;
|
||||
|
||||
/* Return family of the device's CPU */
|
||||
extern cpu_family android_getCpuFamily(void);
|
||||
|
||||
enum
|
||||
{
|
||||
CPU_ARM_FEATURE_ARMv7 = (1 << 0),
|
||||
CPU_ARM_FEATURE_VFPv3 = (1 << 1),
|
||||
CPU_ARM_FEATURE_NEON = (1 << 2),
|
||||
CPU_ARM_FEATURE_LDREX_STREX = (1 << 3)
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CPU_X86_FEATURE_SSSE3 = (1 << 0),
|
||||
CPU_X86_FEATURE_POPCNT = (1 << 1),
|
||||
CPU_X86_FEATURE_MOVBE = (1 << 2)
|
||||
};
|
||||
|
||||
extern uint64_t android_getCpuFeatures(void);
|
||||
|
||||
/* Return the number of CPU cores detected on this device. */
|
||||
extern int android_getCpuCount(void);
|
||||
|
||||
#endif /* CPU_FEATURES_H */
|
|
@ -2,15 +2,19 @@
|
|||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <sys/system_properties.h>
|
||||
#endif
|
||||
#ifdef __arm__
|
||||
#include <machine/cpu-features.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include "performance_android.h"
|
||||
#include <retro_log.h>
|
||||
#include "performance_linux.h"
|
||||
|
||||
static pthread_once_t g_once;
|
||||
static cpu_family g_cpuFamily;
|
||||
|
@ -68,6 +72,7 @@ static int cpu_read_file(const char *pathname, char *buffer, size_t buffsize)
|
|||
return len;
|
||||
}
|
||||
|
||||
#ifdef __ARM_ARCH__
|
||||
/* Extract the content of a the first occurence of a given field in
|
||||
* the content of /proc/cpuinfo and return it as a heap-allocated
|
||||
* string that must be freed by the caller.
|
||||
|
@ -154,6 +159,8 @@ static int has_list_item(const char* list, const char* item)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Parse an decimal integer starting from 'input', but not going further
|
||||
* than 'limit'. Return the value into '*result'.
|
||||
|
@ -296,7 +303,7 @@ static int get_cpu_count(void)
|
|||
return __builtin_popcount(cpus_present->mask);
|
||||
}
|
||||
|
||||
static void android_cpuInit(void)
|
||||
static void linux_cpu_init(void)
|
||||
{
|
||||
char cpuinfo[4096];
|
||||
int cpuinfo_len;
|
||||
|
@ -328,7 +335,7 @@ static void android_cpuInit(void)
|
|||
*/
|
||||
char* cpu_arch = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "CPU architecture");
|
||||
|
||||
if (cpu_arch != NULL)
|
||||
if (cpu_arch)
|
||||
{
|
||||
char* end;
|
||||
int has_armv7 = 0;
|
||||
|
@ -384,7 +391,7 @@ static void android_cpuInit(void)
|
|||
/* Extract the list of CPU features from 'Features' field */
|
||||
char* cpu_features = extract_cpuinfo_field(cpuinfo, cpuinfo_len, "Features");
|
||||
|
||||
if (cpu_features != NULL)
|
||||
if (cpu_features)
|
||||
{
|
||||
RARCH_LOG("found cpu_features = '%s'\n", cpu_features);
|
||||
|
||||
|
@ -431,23 +438,23 @@ static void android_cpuInit(void)
|
|||
|
||||
#ifdef _MIPS_ARCH
|
||||
g_cpuFamily = CPU_FAMILY_MIPS;
|
||||
#endif /* _MIPS_ARCH */
|
||||
#endif
|
||||
}
|
||||
|
||||
cpu_family android_getCpuFamily(void)
|
||||
cpu_family linux_get_cpu_platform(void)
|
||||
{
|
||||
pthread_once(&g_once, android_cpuInit);
|
||||
pthread_once(&g_once, linux_cpu_init);
|
||||
return g_cpuFamily;
|
||||
}
|
||||
|
||||
uint64_t android_getCpuFeatures(void)
|
||||
uint64_t linux_get_cpu_features(void)
|
||||
{
|
||||
pthread_once(&g_once, android_cpuInit);
|
||||
pthread_once(&g_once, linux_cpu_init);
|
||||
return g_cpuFeatures;
|
||||
}
|
||||
|
||||
int android_getCpuCount(void)
|
||||
int linux_get_cpu_count(void)
|
||||
{
|
||||
pthread_once(&g_once, android_cpuInit);
|
||||
pthread_once(&g_once, linux_cpu_init);
|
||||
return g_cpuCount;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#ifndef PERFORMANCE_LINUX_H
|
||||
#define PERFORMANCE_LINUX_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CPU_FAMILY_UNKNOWN = 0,
|
||||
CPU_FAMILY_ARM,
|
||||
CPU_FAMILY_X86,
|
||||
CPU_FAMILY_MIPS,
|
||||
|
||||
CPU_FAMILY_MAX /* do not remove */
|
||||
} cpu_family;
|
||||
|
||||
enum
|
||||
{
|
||||
CPU_ARM_FEATURE_ARMv7 = (1 << 0),
|
||||
CPU_ARM_FEATURE_VFPv3 = (1 << 1),
|
||||
CPU_ARM_FEATURE_NEON = (1 << 2),
|
||||
CPU_ARM_FEATURE_LDREX_STREX = (1 << 3)
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CPU_X86_FEATURE_SSSE3 = (1 << 0),
|
||||
CPU_X86_FEATURE_POPCNT = (1 << 1),
|
||||
CPU_X86_FEATURE_MOVBE = (1 << 2)
|
||||
};
|
||||
|
||||
cpu_family linux_get_cpu_family(void);
|
||||
|
||||
uint64_t linux_get_cpu_features(void);
|
||||
|
||||
int linux_get_cpu_count(void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue