diff --git a/Makefile.common b/Makefile.common index 74bb2d092c..e7343ea7ec 100644 --- a/Makefile.common +++ b/Makefile.common @@ -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 diff --git a/griffin/griffin.c b/griffin/griffin.c index 8b1f610538..f98ac56ede 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -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" diff --git a/performance.c b/performance.c index f1133bb27c..337f5354a0 100644 --- a/performance.c +++ b/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) diff --git a/performance/performance_android.h b/performance/performance_android.h deleted file mode 100644 index 7bec3ddd0a..0000000000 --- a/performance/performance_android.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef CPU_FEATURES_H -#define CPU_FEATURES_H - -#include -#include - -#include - -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 */ diff --git a/performance/performance_android.c b/performance/performance_linux.c similarity index 96% rename from performance/performance_android.c rename to performance/performance_linux.c index a16fef2899..a31a118005 100644 --- a/performance/performance_android.c +++ b/performance/performance_linux.c @@ -2,15 +2,19 @@ #include #include #include +#include +#ifdef ANDROID #include +#endif #ifdef __arm__ #include #endif #include #include -#include "performance_android.h" +#include +#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; } diff --git a/performance/performance_linux.h b/performance/performance_linux.h new file mode 100644 index 0000000000..3083305346 --- /dev/null +++ b/performance/performance_linux.h @@ -0,0 +1,38 @@ +#ifndef PERFORMANCE_LINUX_H +#define PERFORMANCE_LINUX_H + +#include +#include + +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